Shrink Picture to fit on an Image-Widget.

Pr3ach3rman

New Member
Hi!

I am using the LOAD-IMAGE Methot do display JPEG Files in an IMAGE-WIDGET but i can only Stretch them to fit into it. I am looking for something like SHRINK-TO-FIT.

Thank you!
 

Pr3ach3rman

New Member
Yes, i have tried this:
DO WITH FRAME fMain:
IMAGE-1:RETAIN-SHAPE = YES.
IMAGE-1:STRETCH-TO-FIT = YES.
IMAGE-1:LOAD-IMAGE("c:\test.jpg",0,0,200,120).
END.
Images which are smaller then the Widget will be stretched to fit. Larger Images dont change.
 

Stefan

Well-Known Member
Interesting, the help file on STRETCH-TO-FIT clearly states:

Forces the image to expand or contract to fit within the image widget’s boundaries.

Note that you need to set the size of your image before loading the image on to it. The numbers you are passing in the load-image do not specify the size of the image, but specify which part of the image you want.

Code:
DEF VAR hwframe AS HANDLE NO-UNDO.
DEF VAR hwimage AS HANDLE NO-UNDO.

CREATE FRAME hwframe.
ASSIGN
   hwframe:PARENT          =  CURRENT-WINDOW
   hwframe:WIDTH-PIXELS    =  200
   hwframe:HEIGHT-PIXELS   =  200
   .

CREATE IMAGE hwimage.
ASSIGN
   hwimage:FRAME           =  hwframe
   hwimage:RETAIN-SHAPE    =  TRUE
   hwimage:STRETCH-TO-FIT  =  TRUE
   hwimage:WIDTH-PIXELS    =  150
   hwimage:HEIGHT-PIXELS   =  150
   .
hwimage:LOAD-IMAGE( "c:\temp\test.jpg" ).

hwframe:VISIBLE = TRUE

WAIT-FOR CLOSE OF THIS-PROCEDURE.

The above shrinks fine (10.2B02).
 

Pr3ach3rman

New Member
I have tried to this in a Smart-Window. It looks like it does not work with a static Image-Widget. Now i create it dynamic in the createObjects Procedure and this works fine.

Thank you for your help!
 
Top