Solved

rotation of timage

Posted on 1998-04-12
4
411 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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