Solved

rotation of timage

Posted on 1998-04-12
4
399 Views
Last Modified: 2011-09-20
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...
thanks in advance.....
0
Comment
Question by:kabae
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
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

by:kabae
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

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

0
 
LVL 1

Expert Comment

by:pjdb
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now