[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 728
  • Last Modified:

transpose a bitmap

I need a function to transpose ( flip and rotate CCW 90 deg ) a bitmap simply and fast. Any ideas?
0
IOOI
Asked:
IOOI
  • 3
  • 2
1 Solution
 
rfwoolfCommented:
Google is your friend:
http://www.delphi3000.com/article.asp?ID=2764

Procedure TurnImage(Src, Dst: TImage);
var x,y: integer;
begin
  Dst.Width:= Src.Height; Dst.Height:= Src.Width;
  For x:= 0 to Src.Width-1 do begin
    For y:= 0 to Src.Height-1 do begin
      Dst.Canvas.Pixels[(Src.Height-1)-y,x]:= Src.Canvas.Pixels[x,y];
    end;
  end;
end;

You can adapt this to do what you want.
0
 
rfwoolfCommented:
Also, I actually couldn't go to that link when I found it in google - I had to check the Google cache.
But if you do go to the cache of that link you'll see  the above procedure PLUS improvements on it, stuff like being able to accept jpegs, being able to flip the image, being able to rotate it, and combinations thereof.
0
 
IOOIAuthor Commented:
I have googled a lot which is why I finally asked.

I'm aware of Canvas.Pixel but it is very slow because you can access individual pixels.

I was looking for a solution that uses scanline and simply switches x,y of individual pixels to get a transpose.
0
 
rfwoolfCommented:
If you haven't already, have a look at this page to see if there's a component or solution that might be able to help you: http://www.efg2.com/Lab/Library/Delphi/Graphics/ImageProcessing.htm
0
 
IOOIAuthor Commented:
Thanks! I got a few ideas from that page.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now