What is the API function to get Fit image to window?

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
jorgehrl
Junior Member
Junior Member
Posts: 2
Joined: 2004-05-04, 23:16 UTC

What is the API function to get Fit image to window?

Post by *jorgehrl »

Hi all,

I need to do something similar to "Fit image to window" in the lister window.

Thanks
gigaman
Member
Member
Posts: 131
Joined: 2003-02-14, 11:28 UTC

Post by *gigaman »

You mean something like StretchBlt() ?
I am not sure about the quality (and speed) of the transformation, though - I guess many programs use their own code for resizing an image.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

On Windows 2000/XP, you should call SetStretchBltMode with parameter HALFTONE, this gives the best looking results.

Here is the description from http://msdn.microsoft.com

HALFTONE:
Maps pixels from the source rectangle into blocks of pixels in the destination rectangle. The average color over the destination block of pixels approximates the color of the source pixels.

After setting the HALFTONE stretching mode, an application must call the SetBrushOrgEx function to set the brush origin. If it fails to do so, brush misalignment occurs.

This option is not supported on Windows 95/98/Me.
Author of Total Commander
https://www.ghisler.com
Post Reply