Can Delphi rotate or flip an image?

Source: Internet
Author: User
Can Delphi rotate or flip an image? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiMultimedia/html/delphi_20060929153916275.html
RT
High Efficiency
Thank you.

Sofa
Can I find a bunch of images on Google?

Procedure tform1.rotateangleclick (Sender: tobject );
VaR
Newbmp: tbitmap;
Bitmap: tbitmap;
Angle: integer;
Begin
Newbmp: = tbitmap. Create;
Bitmap: = tbitmap. Create;
Screen. cursor: = crhourglass;
Newbmp. Assign (image1.picture. Bitmap );
// Newbmp. pixelformat: = pf8bit;
// Bitmap. pixelformat: = pf8bit;
Angle: = strtoint (inputbox ('rotate bitmap ', 'Enter the rotation angular', '90 '));
BMP _rotate (newbmp, bitmap, angle );
Image1.picture. bitmap. Assign (Bitmap );
Image1.left: = (self. Width Div 2)-(bitmap. Width Div 2 );
Image1.top: = (self. Height Div 2)-(bitmap. Height Div 2 );
Screen. cursor: = crdefault;
Newbmp. Free;
Bitmap. Free;
End;


Procedure tform1.bmp _ rotate (srcbmp, destbmp: tbitmap; angle: Extended );
VaR
C1x, c1y, c2x, c2y: integer;
P1x, p1y, P2x, p2y: integer;
Radius, N: integer;
ALPHA: extended;
C0, C1, C2, C3: tcolor;
Begin
If srcbmp. width> srcbmp. Height then
Begin
Destbmp. Width: = srcbmp. width;
Destbmp. Height: = srcbmp. width;
End
Else
Destbmp. Width: = srcbmp. height;
Destbmp. Height: = srcbmp. height;
// Convert the angle to the PI value
Angle: = (angle/180) * PI;
// Calculate the center point. You can modify it.
C1x: = srcbmp. Width Div 2;
C1y: = srcbmp. Height Div 2;
C2x: = destbmp. Width Div 2;
C2y: = destbmp. Height Div 2;
// Step number
If c2x <c2y then
N: = c2y
Else
N: = c2x;
Dec (n, 1 );
// Start Rotation
For P2x: = 0 to n do
Begin
For p2y: = 0 to n do
Begin
If P2x = 0 then
ALPHA: = PI/2
Else
ALPHA: = arctan2 (p2y, P2x );
RADIUS: = round (SQRT (P2x * P2x) + (p2y * p2y )));
P1x: = round (radius * Cos (angle + alpha ));
P1y: = round (radius * sin (angle + alpha ));

C0: = srcbmp. Canvas. pixels [c1x + p1x, c1y + p1y];
C1: = srcbmp. Canvas. pixels [c1x-p1x, c1y-p1y];
C2: = srcbmp. Canvas. pixels [c1x + p1y, c1y-p1x];
C3: = srcbmp. Canvas. pixels [c1x-p1y, c1y + p1x];

Destbmp. Canvas. pixels [c2x + P2x, c2y + p2y]: = C0;
Destbmp. Canvas. pixels [c2x-P2x, c2y-p2y]: = C1;
Destbmp. Canvas. pixels [c2x + p2y, c2y-P2x]: = c2;
Destbmp. Canvas. pixels [c2x-p2y, c2y + P2x]: = C3;
End;
Application. processmessages
End;
End;

The imageen control can be used for a lot of effects and is fast

Http://www.efg2.com/Lab/ImageProcessing/RotateScanline.htm
This is done quickly with a scanning line. You can understand it and change it.

The above answers are correct.

So many points, I will answer! You can refer to the next <Delphi Digital Image Processing>!

A good component found: trotateimage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.