Delphi GDI + Learning Record (9): Textured brush

Source: Internet
Author: User

Texture painting Brush
Var
G:tgpgraphics;
Img:tgpimage;
Tb:tgptexturebrush;
Begin
G: = Tgpgraphics.create (Canvas.handle);
IMG: = tgpimage.create (' c:\temp\small.jpg ');
TB: = Tgptexturebrush.create (IMG);
G.fillellipse (TB, 0, 0, self.clientwidth, self.clientheight);
Img. Free;
Tb. Free;
G.free;
End
Matrix
Var
G:tgpgraphics;
Img:tgpimage;
Tb:tgptexturebrush;
Matrix:tgpmatrix;
Begin
G: = Tgpgraphics.create (Canvas.handle);
IMG: = tgpimage.create (' c:\temp\x.jpg ');
TB: = Tgptexturebrush.create (IMG);
Matrix: = Tgpmatrix.create (75.0/640.0, 0.0, 0.0, 75.0/480.0, 0.0, 0.0);
Tb. SetTransform (matrix);
G.fillellipse (TB, 0, 0, self.clientwidth, self.clientheight);
Matrix. Free;
Img. Free;
Tb. Free;
G.free;
End
WrapMode
Var
G:tgpgraphics;
Img:tgpimage;
Tb:tgptexturebrush;
P:tgppen;
Begin
G: = Tgpgraphics.create (Canvas.handle);
IMG: = tgpimage.create (' c:\temp\small.jpg ');
TB: = Tgptexturebrush.create (IMG);
P: = tgppen.create (Makecolor (255, 0, 0, 0));
Tb. Setwrapmode (Wrapmodetile);
G.fillrectangle (TB, makerect (0, 0, 200, 200));
G.drawrectangle (P, makerect (0, 0, 200, 200));
Tb. Setwrapmode (WRAPMODETILEFLIPX);
G.fillrectangle (TB, makerect (200, 0, 200, 200));
G.drawrectangle (P, makerect (200, 0, 200, 200));
Tb. Setwrapmode (wrapmodetileflipy);
G.fillrectangle (TB, makerect (0, 200, 200, 200));
G.drawrectangle (P, makerect (0, 200, 200, 200));
Tb. Setwrapmode (WRAPMODETILEFLIPXY);
G.fillrectangle (TB, Makerect (200, 200, 200, 200));
G.drawrectangle (P, Makerect (200, 200, 200, 200));
Img. Free;
Tb. Free;
P.free;
G.free;
End

WrapMode option:

Delphi Microsoft Description
Wrapmodeclamp Clamp The texture or gradient is not tiled.
Wrapmodetile Tile Tile a gradient or texture.
Wrapmodetileflipx Tileflipx Water to rehabilitate a texture or gradient, and then tile the texture or gradient.
Wrapmodetileflipxy Tileflipxy Invert the texture or gradient horizontally and vertically, and then tile the texture or gradient.
Wrapmodetileflipy Tileflipy Invert the texture or gradient vertically, and then tile the texture or gradient.

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.