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:

Post a Comment

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...