I\'m currently writing a program that requires a preview of a live display, but the preview, of course, is scaled down. However, when I scale the PictureBox
down, t
You are doing integer division.
what you need to do is this :
private void FindOptimalRes(PictureBox picBox)
{
double h = Height / 4D; // or Height / 4.0
double ratio = 4D / 3D; // or 4.0 / 3.0
picBox.Size = new Size((int)(h * ratio), (int)h); // Size is now correct [133,100]
}
when you do a mathematical operation with an integer literal (no decimal places) it is implicitly typed as an int.
Simply appending a capital D at the end of your literals (4D, 3D) will type them as doubles, and your math will be correct. Alternatively you can write 4.0, 3.0