How can I scale images in Xojo Web?

I need to know how to scale images in Xojo web. I frequently create my own icons (.jpg & .png) to be used as graphical buttons, but I have not found any events, methods, or properties that allow them to be scaled in the WebImagewell, WebCanvas, or any other Xojo Web controls.

I’ve been searching for a solution for several weeks and people have speculated that it would be available in a future version of Xojo Web. If a native solution exists, please point me to it or please let me know how to get my images to render correctly for any screen size. I’m hoping that it’s just something simple that I’ve overlooked.

Thanks much,

You draw them into another picture at the size you want and send that to the browser.

Hi Greg,
Thanks for your response, but I don’t understand what you are suggesting. (BTW, I accidentally clicked the box for “This answers my question.”).

Are you saying that I should have two WebImageWell controls, for example, and copy one picture into another? Could you demonstrate with some code and specify which controls you’re using? Whenever I’ve added an image to my project and selected it in the “Picture” drop-down box in the Inspector, it always renders at some unexpected size.

Thanks again,

If your original picture was named Pic and was 100x300 and you wanted it to be 50x150:

dim p as new picture(50,150) pic,0,0,50,150,0,0,100,300 WebImageView1.Picture = p

If you put “scale image” into the forum search box, you will find many threads with example code for scaling images. For example this one .

It will end up extending the Picture class with a new method, where you pass the max width and height you want to allow and it will scale it to fit while keeping the aspect ratio:

Dim newPic as Picture = originalPic.ResizeToFit( maxWidth, maxHeight )

You can then assign newPic to your WebImageView. Or skip the newPic object and just assign originalPic.ResizeToFit() directly to the WebImageview picture property itself:

myWebImageView.picture = originalPic.ResizeToFit( maxWidth, maxHeight )

Got it - thanks.

BTW, I’ve been searching via Google, “Xojo Web Scale Image” etc… I never did find a real solution, so I greatly appreciate the help from both of you.

Thanks again,