Re: Scaling images

new topic     » goto parent     » topic index » view thread      » older message » newer message

Alexander Toresson wrote:
> 
> > Since graphics in Windows is my weak spot...how does one scale an image
> > (BMP, PNG, JPEG, etc.) such that when the image is shrunk by the user
> > it doesn't look funny?  What I mean by "funny" is that I have a window
> > that displays an image (using FreeImage).  I want to show the image in
> > the window for a "preview" so I use the stretchBlt function in 
> > Win32Lib to shrink the image.  But the shrunken image does not look as
> > good as say, shrinking the image in the Windows Picture and Fax Viewer in
> > XP.
> > 
> > Can this be done with stretchBlt or is more complicated than that?
> > 
> 
> Here's a way to do perfect scaling-down of images, using only a nearest-
> neighbour scaling routine and a mosaic (square) effect:
> 
> You first have to scale the original picture up to make the width and 
> height a multiple of the destination picture's size, and bigger than 
> the original. Ie if the original is 1024x768, and the destination is 
> 100x100, you'll have to scale it to 1100x800. For this operation,
> linear interpolation helps, but ain't necessary.
> 
> Then we'll apply the mosaic effect, with a size of 
> (width / dest_width)x(height / dest_height), in this example 11x8.
> 
> Then we just have to scale it down to the wanted size.
> 

That all sounds good...I was hoping for a code example, though!  

Got one?   :)

Jonas Temple
http://www.yhti.net/~jktemple

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu