zoukankan      html  css  js  c++  java
  • Delphi 与 DirectX 之 DelphiX(9): 透明色与是否透明


    TDXImageList.Items 中的每个 TPictureCollectionItem 的默认透明色是黑色, 并默认透明.

    本例使用的测试图片: https://files.cnblogs.com/del/Transparent.rar

    本例效果图:



    代码文件:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, DXDraws, StdCtrls, DXClass;
    
    type
      TForm1 = class(TForm)
        DXDraw1: TDXDraw;
        DXImageList1: TDXImageList;
        CheckBox1: TCheckBox;
        procedure FormCreate(Sender: TObject);
        procedure CheckBox1Click(Sender: TObject);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    var
      PicItem: TPictureCollectionItem;
    
    procedure TForm1.FormCreate(Sender: TObject);
    const
      ImgPath1 = 'C:\Temp\Transparent.bmp';
    begin
      DXImageList1.DXDraw := DXDraw1;
      PicItem := TPictureCollectionItem(DXImageList1.Items.Add);
      PicItem.Picture.LoadFromFile(ImgPath1);
    
      PicItem.TransparentColor := $FFFFFF; {指定透明色; 我测试用的图片是白色背景的}
    end;
    
    procedure TForm1.CheckBox1Click(Sender: TObject);
    const
      arr: array[Boolean] of string = ('不透明', '透明');
    begin
      DXDraw1.Surface.Fill($FF0000);
      PicItem.Restore;
      PicItem.Transparent := CheckBox1.Checked;
      PicItem.Draw(DXDraw1.Surface, 10, 10, 0);
      DXDraw1.Flip;
      CheckBox1.Caption := arr[CheckBox1.Checked];
    end;
    
    end.
    

  • 相关阅读:
    CentOS7修改计算机名!
    kafka原理和实践
    sip协议详解
    MP4视频测试URL地址,亲测有效
    pkill精确匹配进程名称
    gdb break 断点设置
    ZR#996
    CF1217C
    CF1217B
    CF1217A
  • 原文地址:https://www.cnblogs.com/del/p/1374919.html
Copyright © 2011-2022 走看看