Delphi and DirectX Delphix (): Tdib. Drawalphamask ();

Source: Internet
Author: User
Tags textout

This example effect chart:

Code files:

Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, DIB, Stdctrls, Extctrls;
Type
TForm1 = Class (Tform)
Dxpaintbox1:tdxpaintbox;
Button1:tbutton;
Button2:tbutton;
Colorbox1:tcolorbox;
Colorbox2:tcolorbox;
Procedure Formcreate (Sender:tobject);
Procedure Formdestroy (Sender:tobject);
Procedure Button1Click (Sender:tobject);
Procedure Button2click (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Const STR = ' Spring ';
Var
Dib,dib1,dib2:tdib;
Procedure Tform1.formcreate (Sender:tobject);
Const
ImgPath1 = ' C:\Temp\DX.jpg ';
Begin
Dib: = Tdib. Create;
DIB1: = Tdib. Create;
DIB2: = Tdib. Create;
Dib. LoadFromFile (IMGPATH1);
Dxpaintbox1.clientwidth: = Dib. Width;
Dxpaintbox1.clientheight: = Dib. Height;
DXPaintBox1.DIB.Assign (DIB);
Dib1. Assign (DIB);
Dib2. SetSize (DIB). Width, Dib. Height, 24);
Dib2. Canvas.Brush.Style: = Bsclear;
Dib2. Canvas.Font.Name: = ' black body ';
Dib2. Canvas.Font.Size: = 90;
Dib2. Canvas.Font.Style: = [Fsbold];
colorbox1.selected: = Clblack;
colorbox2.selected: = Clyellow;
End
Procedure Tform1.formdestroy (Sender:tobject);
Begin
Dib. Free;
Dib1. Free;
Dib2. Free;
End
Procedure Tform1.button1click (Sender:tobject);
Begin
Dib1. Assign (DIB);
Dib2. Fill (colorbox1.selected);
Dib2. Canvas.Font.Color: = colorbox2.selected;
Dib2. Canvas.textout (0, 0, str);
Dib1. Drawalphamask (dib2, DIB1, 0, 0, Dib. Width, Dib. Height, 0, 0);
DXPaintBox1.DIB.Assign (DIB1);
Dxpaintbox1.repaint;
End
Procedure Tform1.button2click (Sender:tobject);
Begin
Dib1. Assign (DIB);
Dib2. Fill (colorbox2.selected);
Dib2. Canvas.Font.Color: = colorbox1.selected;
Dib2. Canvas.textout (0, 0, str);
Dib1. Drawalphamask (dib2, DIB1, 0, 0, Dib. Width, Dib. Height, 0, 0);
DXPaintBox1.DIB.Assign (DIB1);
Dxpaintbox1.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.