程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi 與 DirectX 之 DelphiX(25): TDIB.Blur();

Delphi 與 DirectX 之 DelphiX(25): TDIB.Blur();

編輯:Delphi

DelphiX 的組件面板上, 第二個就是 TDXDIB;

  TDXDIB.DIB 是 TDXDIB 的唯一屬性(其他是 TComponent 固有的);

  TDXDIB.DIB 屬性是一個 TDIB 對象;

  TDIB 和 TBitmap 一樣都直接繼承自 TGraphic, 是一個圖片容器, 它還有個別名: TDIBitmap;

  TDIB 和 TDXDraw.Surface 還有 TDXImageList 中的元素(TPictureCollectionItem)功能都差不多, 不過它更強大.

  使用 TDIB 需要 uses DIB 單元;

  但如果添加了 TDXDIB 組件, DIB 單元會自動添加, 並可以在設計時裝載圖片.

  本例測試了 TDIB 的模糊圖像的功能, 效果圖如下:

  代碼文件:

unit Unit1;
interface
uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, DIB, DXDraws, StdCtrls;
type
 TForm1 = class(TForm)
  DXDraw1: TDXDraw;
  DXDIB1: TDXDIB;
  Button1: TButton;
  Button2: TButton;
  Button3: TButton;
  Button4: TButton;
  procedure Button1Click(Sender: TObject);
  procedure Button2Click(Sender: TObject);
  procedure Button3Click(Sender: TObject);
  procedure Button4Click(Sender: TObject);
 end;
var
 Form1: TForm1;
implementation
{$R *.dfm}
const
 ImgPath1 = 'C:TempDelphiX.bmp';
procedure TForm1.Button1Click(Sender: TObject);
begin
 DXDraw1.Surface.LoadFromFile(ImgPath1);
 DXDraw1.Flip;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
 DXDIB1.DIB.LoadFromFile(ImgPath1);
 DXDIB1.DIB.Blur(32, 1);
 DXDraw1.Surface.LoadFromDIB(DXDIB1.DIB);
 DXDraw1.Flip;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
 DXDIB1.DIB.LoadFromFile(ImgPath1);
 DXDIB1.DIB.Blur(32, 6);
 DXDraw1.Surface.LoadFromDIB(DXDIB1.DIB);
 DXDraw1.Flip;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
 DXDIB1.DIB.LoadFromFile(ImgPath1);
 DXDIB1.DIB.Blur(4, 2);
 DXDraw1.Surface.LoadFromDIB(DXDIB1.DIB);
 DXDraw1.Flip;
end;
end.

  窗體文件:

object Form1: TForm1
 Left = 0
 Top = 0
 Caption = 'Form1'
 ClIEntHeight = 151
 ClIEntWidth = 280
 Color = clBtnFace
 Font.Charset = DEFAULT_CHARSET
 Font.Color = clWindowText
 Font.Height = -11
 Font.Name = 'Tahoma'
 Font.Style = []
 OldCreateOrder = False
 PixelsPerInch = 96
 TextHeight = 13
 object DXDraw1: TDXDraw
  Left = 8
  Top = 8
  Width = 265
  Height = 105
  AutoInitialize = True
  AutoSize = True
  Color = clBlack
  Display.FixedBitCount = False
  Display.FixedRatio = True
  Display.FixedSize = True
  Options = [doAllowReboot, doWaitVBlank, doCenter, do3D, doDirectX7Mode, doHardware, DOSelectDriver]
  SurfaceHeight = 105
  SurfaceWidth = 265
  TabOrder = 0
  Traces = <>
 end
 object Button1: TButton
  Left = 8
  Top = 119
  Width = 60
  Height = 25
  Caption = 'Button1'
  TabOrder = 1
  OnClick = Button1Click
 end
 object Button2: TButton
  Left = 76
  Top = 119
  Width = 60
  Height = 25
  Caption = 'Button2'
  TabOrder = 2
  OnClick = Button2Click
 end
 object Button3: TButton
  Left = 144
  Top = 119
  Width = 60
  Height = 25
  Caption = 'Button3'
  TabOrder = 3
  OnClick = Button3Click
 end
 object Button4: TButton
  Left = 213
  Top = 119
  Width = 60
  Height = 25
  Caption = 'Button4'
  TabOrder = 4
  OnClick = Button4Click
 end
 object DXDIB1: TDXDIB
  Left = 240
  Top = 16
 end
end


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved