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.
    

  • 相关阅读:
    C++树状数组详解
    状态码
    java面试教程视频
    学生管理系统学生基本信息查询(1)
    学生管理系统导包
    学生信息管理系统数据库设计
    SSH简单项目
    MyBatis入门
    Struts配置详解
    Struts的使用
  • 原文地址:https://www.cnblogs.com/del/p/1374919.html
Copyright © 2011-2022 走看看