文档章节

Delphi 与 DirectX 之 DelphiX(88): TDIB.DrawQuickAlpha();

涂孟超
 涂孟超
发布于 2014/09/26 15:35
字数 572
阅读 15
收藏 0

本例效果图:



代码文件:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DIB, StdCtrls;

type
  TForm1 = class(TForm)
    DXPaintBox1: TDXPaintBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var
  dib: TDIB;

procedure TForm1.FormCreate(Sender: TObject);
begin
  dib := TDIB.Create;
  dib.SetSize(DXPaintBox1.Width, DXPaintBox1.Height, 24);
  dib.Fill(0);
  dib.Canvas.Brush.Style := bsClear;
  dib.Canvas.Font.Color := clRed;
  dib.Canvas.Font.Name := 'Tahoma';
  dib.Canvas.Font.Size := 32;
  dib.Canvas.Font.Style := [fsBold];
  dib.Canvas.TextOut(10, 10, 'DelphiX');
  Self.Color := clWhite;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  dib.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  DXPaintBox1.DIB.Assign(dib);
  DXPaintBox1.Repaint;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  DXPaintBox1.DIB.Fill(Self.Color);
  DXPaintBox1.DIB.DrawQuickAlpha(dib, 0, 0, dib.Width, dib.Height, 0, 0, clBlack, fmNormal);
  DXPaintBox1.Repaint;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  DXPaintBox1.DIB.Fill(Self.Color);
  DXPaintBox1.DIB.DrawQuickAlpha(dib, 0, 0, dib.Width, dib.Height, 0, 0, clBlack, fmMix75);
  DXPaintBox1.Repaint;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  DXPaintBox1.DIB.Fill(Self.Color);
  DXPaintBox1.DIB.DrawQuickAlpha(dib, 0, 0, dib.Width, dib.Height, 0, 0, clBlack, fmMix50);
  DXPaintBox1.Repaint;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  DXPaintBox1.DIB.Fill(Self.Color);
  DXPaintBox1.DIB.DrawQuickAlpha(dib, 0, 0, dib.Width, dib.Height, 0, 0, clBlack, fmMix25);
  DXPaintBox1.Repaint;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
  DXPaintBox1.DIB.Fill(Self.Color);
  DXPaintBox1.DIB.DrawQuickAlpha(dib, 0, 0, dib.Width, dib.Height, 0, 0, clRed, fmNormal);
  DXPaintBox1.Repaint;
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
  DXPaintBox1.DIB.Fill(Self.Color);
  DXPaintBox1.DIB.DrawQuickAlpha(dib, 0, 0, dib.Width, dib.Height, 0, 0, clRed, fmMix75);
  DXPaintBox1.Repaint;
end;

procedure TForm1.Button8Click(Sender: TObject);
begin
  DXPaintBox1.DIB.Fill(Self.Color);
  DXPaintBox1.DIB.DrawQuickAlpha(dib, 0, 0, dib.Width, dib.Height, 0, 0, clRed, fmMix50);
  DXPaintBox1.Repaint;
end;

procedure TForm1.Button9Click(Sender: TObject);
begin
  DXPaintBox1.DIB.Fill(Self.Color);
  DXPaintBox1.DIB.DrawQuickAlpha(dib, 0, 0, dib.Width, dib.Height, 0, 0, clRed, fmMix25);
  DXPaintBox1.Repaint;
end;

end.

 
 
 
 
 

 

 

  

窗体文件:
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 224
  ClientWidth = 208
  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 = 193
    Height = 73
    AutoStretch = False
    Center = False
    KeepAspect = False
    Stretch = False
    ViewWidth = 0
    ViewHeight = 0
  end
  object Button1: TButton
    Left = 8
    Top = 92
    Width = 67
    Height = 125
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 81
    Top = 92
    Width = 58
    Height = 25
    Caption = 'Button2'
    TabOrder = 1
    OnClick = Button2Click
  end
  object Button3: TButton
    Left = 145
    Top = 92
    Width = 57
    Height = 25
    Caption = 'Button3'
    TabOrder = 2
    OnClick = Button3Click
  end
  object Button4: TButton
    Left = 81
    Top = 123
    Width = 58
    Height = 25
    Caption = 'Button4'
    TabOrder = 3
    OnClick = Button4Click
  end
  object Button5: TButton
    Left = 145
    Top = 123
    Width = 57
    Height = 25
    Caption = 'Button5'
    TabOrder = 4
    OnClick = Button5Click
  end
  object Button6: TButton
    Left = 81
    Top = 161
    Width = 58
    Height = 25
    Caption = 'Button6'
    TabOrder = 5
    OnClick = Button6Click
  end
  object Button7: TButton
    Left = 145
    Top = 161
    Width = 57
    Height = 25
    Caption = 'Button7'
    TabOrder = 6
    OnClick = Button7Click
  end
  object Button8: TButton
    Left = 81
    Top = 192
    Width = 58
    Height = 25
    Caption = 'Button8'
    TabOrder = 7
    OnClick = Button8Click
  end
  object Button9: TButton
    Left = 145
    Top = 192
    Width = 57
    Height = 25
    Caption = 'Button9'
    TabOrder = 8
    OnClick = Button9Click
  end
end

 
 
 
 
 

 

 

  

本文转载自:http://www.cnblogs.com/del/archive/2009/01/23/1380545.html

共有 人打赏支持
涂孟超
粉丝 12
博文 2011
码字总数 14107
作品 0
深圳
程序员
私信 提问
开源游戏框架(转至wiki)

免费和开源引擎,转载自维基 Agar - 一个高级图形应用程序框架,用于2D和3D游戏。 Allegro - 基于 C/C++ 的游戏引擎,支持图形,声音,输入,游戏时钟,浮点,压缩文件以及GUI。 Axiom 引擎 ...

Matrix4X4
2012/04/17
1K
0
delphi7 打开project/options 出错

出错提示: Access violation at address 0012F88F. Write of address 0012F88F. 然后又提示一条: Access violation at address 0012F9DB. Write of address 0012F9DB. 操作系统windows2003......

MartinKing
2015/12/18
16
0
2012年5月编程语言排行榜 - Java 持续下挫

Java 自从上个月丢掉第一个的宝座以后,这个月的的走势依然下挫。在过去8年中,前10名的编程语言几乎没有变化,只是 Objective-C 把 Delphi 给挤了出去。人们对新语言的接受程度进展缓慢,这...

oschina
2012/05/09
8K
56
DirectX 将会被命名为 DirectX 12

本周早些时候我们曾报道过,微软将会在GDC大会上宣布全新版本的DirectX。现在微软已经在DirectX的博客页面确认了下一代DirectX API的正式名称,延续之前的产品代号,DirectX将会被命名为Dir...

oschina
2014/03/06
5.1K
48
【Visual C++】游戏开发笔记三十二 浅墨DirectX提高班之一 DirectX大局观认知篇

本系列文章由zhmxy555(毛星云)编写,转载请注明出处。 文章链接: http://blog.csdn.net/zhmxy555/article/details/8172615 作者:毛星云(浅墨) 邮箱: happylifemxy@163.com 这篇文章作...

长平狐
2012/11/12
928
0

没有更多内容

加载失败,请刷新页面

加载更多

虚拟化 - KVM 和 Xen 比较

Linux虚拟化技术的用户目前有两种免费的开源管理程序可以选择:Xen和KVM。 作为较早出现的虚拟化技术,Xen是“第一类”运行在裸机上的虚拟化管理程序(Hypervisor),也是当前相当一部分商业...

临江仙卜算子
19分钟前
1
0
给windows server中的“未识别的网络”或“无法识别的网络”设置网络位置类型

在windows server中,如果网络没有被正确的识别,那么就需要手工设置一下网络位置类型。 将“公用网络”指定设置为“专用网络“ 【控制面板】--【系统和安全】--【管理工具】--【本地安全策略...

gugudu
今天
2
0
阿里强制要求的21条Java开发规范,可以避免很多坑

1. 【强制】避免通过一个类的对象引用访问此类的静态变量或静态方法,无谓增加编译器解析成本,直接用类名来访问即可。 2. 【强制】所有的覆写方法,必须加@Override注解。 说明:getObject...

天王盖地虎626
今天
10
0
oracle dg 备库未设置convert参数导致ORA-01111,ORA-01110

查看trace 文件: MRP0: Background Managed Standby Recovery process started (amls) started logmerger process Sun Jan 20 07:55:53 2019 Managed Standby Recovery starting Real Time ......

hnairdb
今天
2
0
乱入Linux界的我是如何学习的

欢迎来到建哥学Linux,咳!咳!咳!开个玩笑哈,我是一个IT男,IT界的入门选手,正在学习Linux。 在之前,一直想进军IT界,学习IT技术,但是苦于没有人指导,也不知道学什么,最开始我自己在...

linux-tao
今天
4
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部