ImageView1.Picture = ImageView1.Picture.rotate90MBS
The idea, well is to simply rotate the picture. Looks pretty nice, doesn't it?
But actually it's a huge waste of resources. The application will spend more than 90% of the time needed on this with encoding and decoding of a PNG. Only less than 10% are needed for the rotation.
So expand this line and use temporary variables:
dim oldWebPicture as WebPicture = ImageView1.Picture
dim oldPicture as picture = oldWebPicture
dim newPicture as picture = oldPicture.Rotate90MBS
dim newWebPicture as WebPicture = newPicture
ImageView1.Picture = newWebPicture
As you see we need five lines now. First line gets the reference for the current WebPicture object. That is typically a JPEG or PNG encoded picture for the browser to display. Next steps uses the Operator_Convert to get a picture object. And that's some heavy work as the picture is internally decompressed. That takes some CPU time. Third line does the operation on the picture and returns a new picture. In the forth line, this new picture is converted to a web picture. You can easily see in the debugger, that this makes PNG image data. Another expensive call. Finally we assign the new WebPicture to the imageview. This will put it into a global list for the internal web server and tell the image view to load the picture data.
So you see the WebPicture class is a container for holding image data. You should only use it for output, not for input. Like for assigning it to an ImageView or for a file download. To optimize the rotation above, you should keep the original picture in memory and rotate the picture. So you avoid converting from webpicture to picture, which gives you a little speed advantage.
For more details: WebPicture, Picture and Operator_Convert