Jump to content
Moist

Fit an image inside GUICtrlCreatePic

Recommended Posts

Hello guys,

I'm creating a script that kinda acts like a file browser. It searches for a .bmp inside a folder and display that folder as a 125x125 icon with GUICtrlCreatePic. This is working great so far, if the picture inside is 125x125. But if the image has other size, say 100x125, it will scale the image to fit horizontally and it will crop part of the image. How can I Fit the image with the lowest measure. I don't want it to be streched or shrinked, I want it to fit and, if needed, having white bars to the sides or in the top and bottom.

I've searched for this but found nothing.

Thanks in advanceĀ 

Share this post


Link to post
Share on other sites

Hi Moist,
One important question is : what will you do if one of the bmp is greater than 125 x 125 pixels ?

If I understood well, 125 x 125 are the maximum limits you allow to display any bmp in the pic control (as shown in your example 100 x 125) but what should be done if a bmp is 200 x 150, should it be cropped, resized, rejected etc...

I tried what follows and it worked fluently :
* create your 1st pic control with any size (width, height)
* loop through your bmp folder
* new bmp found ? check its width & height (using GDI+ functions)
* delete the old pic control + create a new pic control with width & height from the new bmp
* back to loop etc...

Good luck :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...