views:

137

answers:

3

Does anyone know a way of rotating an image (jpg or gif) in a TWebBrowser control (using Delphi)

Update

The file would be local.

Update 2 So I guess the question should be how do I rotate an image or pdf.

A: 

Well if it's on a website (in the TWebBrowser) then you can't rotate it. The best you can do is if the image is on your website you can use PHP/ASP/etc. to load the image, and produce a rotated version of it.

Daisetsu
Actually. You can download the HTML-document from the web server, parse it and manipulate it, and then show the manipulated HTML-document in the TWebBrowser. You need tho know a little bit about the HTML-document's structure, of course... :-D
Jørn E. Angeltveit
+1  A: 

If you have control over the content return in the TWebBrowser it can be done via JavaScript.

Here is an example on JavaScript Image Rotation.

If you want to do it with a TImage there are several options listed in this Q/A.

Robert Love
That JavaScript example doesn't really rotate the image. It requires that you set up a pre-rendered set of several copies the image through multiple rotations, then it cycles through them.
Mason Wheeler
Really valid point, i missed that and I can't seem to find a good example now.
Robert Love
+1  A: 

I guess that you already use this approach to show the HTML content in your TWebBrowser.

Now, instead of JavaScript (as suggested by Robert), you use CSS in the generated HTML document.

I haven't tested this, but you should be able to rotate the image (and other HTML-elements) by using this CSS code (for IE-based browsers):

filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);

See details at MSDN

Jørn E. Angeltveit