Wednesday, March 22, 2006

Scaling Bitmaps in .Net

Coding4Fun - Rob’s Image Shrinker

"... Scaling the bitmap is quite easy. There are draw methods that can be used to draw a rectangle from one image into another. By manipulating the sizes of the source and destinations, we can resize the image to fit on our device. The only difficulty is that we have to handle the aspect ratios of the source and destination, so that we don’t clip off any parts of the image.
 
...
 
Resizing images is actually quite easy. The DrawImage method can be supplied with source and destination rectangles. The method above decides which way the source needs to be scaled and then adjusts the size and position of the destination rectangle to suit. The call of DrawImage at the bottom of the method is the part that does the actual work. ..."

Just what I needed when I needed it...I needed a simple method to scale an image to a thumbnail representation and this did the trick.

This stuff always looks so easy in hindsight...

Technorati Tags: , , ,

No comments: