Am I missing something? When I use my method the ratio of the old size to the new size is exactly the same but it is not proportional when it saves to disk.
The call and creation of the bitmap:
The method that returns a proportional size:
Lets say that I sent a size of 400, 295 to the method. Proportionately I get 400, 232 which is mathmatically correct. But it is not, when I look at the image proportional to the original. I used 400, 295 because that is what IrfanView says the proportions should be.
What am I missing? There must be something I dont know about resizing images.
The call and creation of the bitmap:
C#:
Bitmap b=new Bitmap(file);
Size size= a.graphics.ProportionalSize(b.Size, new Size(Convert.ToInt32(this.widthTB.Text), Convert.ToInt32(this.hieghtTB.Text)));
Bitmap B=new Bitmap(b, size);
B.Save(thisDir+"\\x\\"+im, ImageFormat.Bmp);
C#:
public static Size ProportionalSize(Size imageSize, Size newSize)
{
Size size=new Size(imageSize.Width, imageSize.Height);
int ratio= size.Width-size.Height;
if(size.Width < newSize.Width && size.Height < newSize.Height)
{
MessageBox.Show(ratio+"");
while(size.Width < newSize.Width && size.Height < newSize.Height)
{
size= new Size(size.Width+1, size.Height+1);
}
ratio= size.Width-size.Height;
MessageBox.Show(ratio+"");
}
else
{
ratio= size.Width-size.Height;
MessageBox.Show(ratio+"");
while(size.Width > newSize.Width || size.Height > newSize.Height)
{
size= new Size(size.Width-1, size.Height-1);
}
MessageBox.Show(size+" "+newSize);
}
ratio= size.Width-size.Height;
MessageBox.Show(ratio+"");
if(size.Width < 1) size=new Size(size.Width+-size.Width+1, size.Height-size.Width-1);
if(size.Height < 1) size=new Size(size.Width-size.Height-1, size.Height+-size.Height+1);
return size;
}
What am I missing? There must be something I dont know about resizing images.
Last edited by a moderator: