Quantcast
Channel: .Net Image Processor
Viewing all articles
Browse latest Browse all 33

Created Unassigned: ResizeMethod.AspectRatioFill issue [11036]

$
0
0
protected virtual Size GetNewSize(Image img, Size requestedSize, ResizeMethod method, out Size bitmapSize)
{
Size outputSize = new Size();

switch (method)
{
case ResizeMethod.AspectRatioFill:
{

float ratio = (float)img.Width / (float)img.Height;


float reqRatio = (float)requestedSize.Width / (float)requestedSize.Height;
if (ratio > reqRatio)
{
outputSize.Height = (int) ((float) requestedSize.Width/ratio);
outputSize.Width = requestedSize.Width;

}
else
{
outputSize.Width = (int)((float)requestedSize.Height * ratio);
outputSize.Height = requestedSize.Height;
}


} break;

Viewing all articles
Browse latest Browse all 33

Trending Articles