Learn more about GDI + [21]: tgptexturebrush and tgpmatrix

Source: Internet
Author: User
In this example:


Code File:
Unit unit1; interfaceuses 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 alert (Sender: tobject ); procedure future (Sender: tobject); Procedure trackbar1change (Sender: tobject); Procedure future (Sender: tobject ); procedure trackbar5change (Sender: tobject); Procedure trackbar6change (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses gdipobj, gdipapi; Procedure plugin (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 submit (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 prepare (Sender: tobject); begin repaint; end; Procedure tform1.trackbar3change (Sender: tobject ); begin repaint; end; Procedure tform1.trackbar4change (Sender: tobject); begin repaint; end; Procedure future (Sender: tobject ); begin repaint; end.
 
   
 

Form file:

Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 170 clientwidth = 324 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false position = pow.topcenter oncreate = formcreate onpaint = formpaint pixelsperinch = 96 textheight = 13 object Panel1: tpanel left = 225 Top = 0 width = 99 Height = 170 align = alright taborder = 0 explicitleft = 288 explicitheight = 213 object button1: tbutton left = 14 top = 8 width = 75 Height = 25 caption = #21021 #22987 #21270 taborder = 0 end object trackbar1: ttrackbar left = 0 Top = 34 width = 100 Height = 20 showselrange = false taborder = 1 onchange = trackbar1change end object trackbar2: ttrackbar left = 0 Top = 56 width = 100 Height = 20 showselrange = false taborder = 2 onchange = trackbar2change end object trackbar3: ttrackbar left = 0 Top = 78 width = 100 Height = 20 showselrange = false taborder = 3 onchange = trackbar3change end object trackbar4: ttrackbar left = 0 Top = 100 width = 100 Height = 20 showselrange = false taborder = 4 onchange = trackbar4change end object trackbar5: ttrackbar left = 0 Top = 122 width = 100 Height = 20 showselrange = false taborder = 5 onchange = trackbar5change end object trackbar6: ttrackbar left = 0 Top = 144 width = 100 Height = 20 showselrange = false taborder = 6 onchange = trackbar6change end endend
 
  
 

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.