Solved

# rotation of timage

Posted on 1998-04-12
395 Views
how can i rotate a timage at a specific degree's like 90 degree's..... i tried the one posted by kabae but i dont know how it works.... a detailed sample code well be much appreciated...
0
Question by:kabae
• 2
• 2

LVL 1

Accepted Solution

pjdb earned 10 total points
ID: 1361418
Try this one :

On a form, drop a Timage (and load any image you want in it) and a button. Put the folowwing code in the onclick event :

procedure TForm1.Button1Click(Sender: TObject);
var
i, j:longint;
work:Timage;
begin
{create a new Timage in memory}
work:=Timage.create(application);
{adjust the size of the new component}
work.width:=image1.height;
work.height:=image1.width;
{for any column}
for i:=image1.canvas.cliprect.left to image1.canvas.cliprect.right do
{for any row}
for j:=image1.canvas.cliprect.top to image1.canvas.cliprect.bottom do
{transpose the pixel -> to modify the rotation, just change this line}
work.canvas.pixels[image1.canvas.cliprect.bottom - j, i]:=image1.canvas.pixels[i, j];
{determine the new size of the image on the form}
image1.height:=work.height;
image1.width:=work.width;
{put the new image in the image on the form}
image1.picture:=work.picture;
{release the image use in memory}
work.free;
end;

It seem quite quick (it rotate a 20829 pixels BMP in .7 second)

JDB
0

Author Comment

ID: 1361419
my goodness MASTER PJDB
ur d best.. u got it...i love it.. its a work of art...
where did u learn how to do that...
thank u thank u ......very very much ... i will never ever forget u in my whole life.....

from jack of the PHIL....

0

Author Comment

ID: 1361420
!!!question!!!
if i stretch the image i got a white color in the side of the image...

0

LVL 1

Expert Comment

ID: 1361421
Well to stretch the image, i suggest that you replace the line
image1.picture:=work.picture;
by :

image1.canvas.StretchDraw(rect(0, 0, newwidth, newheight), work.Picture.graphic)

where newheight and newwidth are the new size on the image.

JDB
0

## Featured Post

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.