Delphix (89) of Delphi and DirectX: tdib. drawalphamask ();

Source: Internet
Author: User
Tags textout
In this example:


Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, Dib, stdctrls, extctrls; Type tform1 = Class (tform) dxpaintbox1: bytes; button1: tbutton; button2: tbutton; colorbox1: tcolorbox; colorbox2: tcolorbox; Procedure Recipe (Sender: Taobao); Procedure Recipe (Sender: tobject ); procedure button2click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} const STR = 'chun'; 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: = 'simhei '; 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.
 
   
 

Form file:

Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 142 clientwidth = 226 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false oncreate = formcreate ondestroy = formdestroy pixelsperinch = 96 textheight = 13 object dxpaintbox1: tdxpaintbox left = 8 Top = 8 width = 81 Height = 73 autostretch = false center = false keepaspect = false stretch = false viewwidth = 0 viewheight = 0 end object button1: tbutton left = 143 Top = 78 width = 75 Height = 25 caption = 'button1' taborder = 0 onclick = button1click end object button2: tbutton left = 143 Top = 109 width = 75 Height = 25 caption = 'button2' taborder = 1 onclick = button2click end object colorbox1: tcolorbox left = 143 Top = 8 width = 81 Height = 22 itemheight = 16 taborder = 2 end object colorbox2: tcolorbox left = 143 Top = 36 width = 81 Height = 22 itemheight = 16 taborder = 3 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.