CoolKrawat13 / imagelibrary

Automatically exported from code.google.com/p/imagelibrary
0 stars 0 forks source link

Landscape thumbnails gets cropped #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The issue: When you have an landscape image and you want to have a 
portrait thumbnail now your library will crop the image, and the same for 
portrait image and landscape thumbnail.

The fix:
In the class Kaliko.ImageLibrary.KalikoImage method 
public KalikoImage GetThumbnailImage(int width, int height, 
ThumbnailMethod method) the padding part:

else if(method == ThumbnailMethod.Pad) {
float hRatio = (float)_image.Height / (float)height;
float wRatio = (float)_image.Width / (float)width;
float newRatio = hRatio > wRatio ? hRatio : wRatio;
int imgHeight = (int)(_image.Height / newRatio);
int imgWidth = (int)(_image.Width / newRatio);

image = new KalikoImage(width, height, _backgroundColor);
Graphics g = Graphics.FromImage(image._image);
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(_image, (width - imgWidth) / 2, (height - imgHeight) / 2, 
imgWidth, imgHeight);
}

Original issue reported on code.google.com by fr3dr...@gmail.com on 3 Mar 2010 at 2:08

GoogleCodeExporter commented 8 years ago
Suggested source code implemented, tested and commited.

Thanks to Cosmin for reporting the problem and submitting the fix!

Original comment by fr3dr...@gmail.com on 7 Apr 2010 at 7:58