Using this code: where “wallpaper” is a jpg image in its native format
dim p as new picture(me.Width,me.Height)
me.Picture = p
The result of this code is that the wallpaper would scale according to the browser size but everytime it sends a huge PNG image
Where do you specify that you want a jpg? Is your computers default image format set to png?
On my harddrive the original photo is a JPG.
I put it in the project by dragging it in and appropriately call it “wallpaper”
Finally I use an ImageView control on the background of the test project
I run the code everytime the browser size changes
This is what XOJO sends to the browser:
<img src="http://127.0.0.1:8080/C4E08E9454AF83D648C11C84F66E9669702AE04F/files/6330-6125-1852-4013-1831/picture.png" alt="" border="0" style="position: absolute; width: 602px; height: 929px; top: 50%; margin-top: -464.5px; left: 50%; margin-left: -301px;" id="voFTgkTC_image" class="">
if you have a JPEG on file, you can make a web picture from it and just pass through the JPEG file.
Assigning a Picture directly to the WebImageView.Picture property is causing another conversion behind the scenes to WebPicture. If you do this conversion by making the WebPicture yourself, you can specify the format and file name.
I also wanted to point out that this technique could be a huge memory hog for your app though because the in memory representation of a WebPicture is uncompressed. A photo that is 1920x1080 uses about 8 MB. If each user has a slightly different browser size, you could have hundreds of multi-megabyte pictures in memory. Youd be much better off making a few images and choosing one based on the browser size.
Please also consider that not everyone coming to your site will have a high bandwidth connection. Even if you get the image down to 1 MB as a jpeg and the user has a 20 Mbps connection, theres going to be a noticeable delay before that image arrives.
Yes I will consider this very carefully Thanks Greg, Christian
Thanks for the answers guys, much appreciated. Made me rethink the whole thing a bit.