Re-learning gdi+[21]: Tgptexturebrush and Tgpmatrix

Source: Internet
Author: User
Tags min

This example effect chart:

Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Comctrls, Stdctrls, Extctrls;
Type
TForm1 = Class (Tform)
Panel1:tpanel;
Button1:tbutton;
Trackbar1:ttrackbar;
Trackbar2:ttrackbar;
Trackbar3:ttrackbar;
Trackbar4:ttrackbar;
Trackbar5:ttrackbar;
Trackbar6:ttrackbar;
Procedure Formcreate (Sender:tobject);
Procedure Formpaint (Sender:tobject);
Procedure Trackbar1change (Sender:tobject);
Procedure Trackbar2change (Sender:tobject);
Procedure Trackbar3change (Sender:tobject);
Procedure Trackbar4change (Sender:tobject);
Procedure Trackbar5change (Sender:tobject);
Procedure Trackbar6change (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Procedure Tform1.formcreate (Sender:tobject);
Const
n = 40;
Begin
Trackbar1.min: =-N;
Trackbar1.max: = n;
Trackbar2.min: =-N;
Trackbar2.max: = n;
Trackbar3.min: =-N;
Trackbar3.max: = n;
Trackbar4.min: =-N;
Trackbar4.max: = n;
Trackbar5.min: =-N;
Trackbar5.max: = n;
Trackbar6.min: =-N;
Trackbar6.max: = n;
Trackbar1.position: = 10;
Trackbar2.position: = 0;
Trackbar3.position: = 0;
Trackbar4.position: = 10;
Trackbar5.position: = 0;
Trackbar6.position: = 0;
Button1.onclick: = formcreate;
End
Procedure Tform1.formpaint (Sender:tobject);
Var
G:tgpgraphics;
Img:tgpimage;
Tb:tgptexturebrush;
Matrix:tgpmatrix;
M11, M12, M21, M22, DX, dy:single;
Begin
G: = Tgpgraphics.create (Canvas.handle);
IMG: = tgpimage.create (' c:\temp\small.png ');
TB: = Tgptexturebrush.create (IMG);
M11: = TRACKBAR1.POSITION/10;
M12: = TRACKBAR2.POSITION/10;
M21: = TRACKBAR3.POSITION/10;
M22: = TRACKBAR4.POSITION/10;
DX: = trackbar5.position * 10;
DY: = trackbar6.position * 10;
Matrix: = Tgpmatrix.create (M11, M12, M21, M22, DX, dy);
Tb. SetTransform (matrix);
G.fillrectangle (TB, 0, 0, clientwidth-panel1.width, clientheight);
Matrix. Free;
Img. Free;
Tb. Free;
G.free;
End
Procedure Tform1.trackbar1change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar2change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar3change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar4change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar5change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar6change (Sender:tobject);
Begin
Repaint;
End
End.

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.