unit hiGP_BrushTexture;
interface
uses Windows,Kol,Share,ActiveX,Debug,hiGP_Canvas,GDIPOBJ,GDIPAPI;
type
THIGP_BrushTexture= class(TDebug)
private
bmp: PBitmap;
procedure SetPicture(Value:HBITMAP);
public
_prop_WrapMode:integer;
_prop_FileName:string;
_prop_FromFile:boolean;
_prop_UseMatrix:boolean;
_prop_Index: string;
_prop_Canvas:PICurrentCanvas;
_data_Picture:THI_Event;
_data_FileName:THI_Event;
_data_WrapMode:THI_Event;
_data_Index:THI_Event;
_event_onSet: THI_Event;
constructor Create;
destructor Destroy; override;
procedure _work_doSet(var _Data:TData; Index:word);
procedure _work_doFromFile(var _Data:TData; Index:word);
property _prop_Picture:HBITMAP write SetPicture;
end;
implementation
constructor THIGP_BrushTexture.Create;
begin
inherited Create;
bmp := NewBitmap(0,0);
end;
destructor THIGP_BrushTexture.Destroy;
begin
if Assigned(bmp) then bmp.Free;
inherited;
end;
procedure THIGP_BrushTexture._work_doSet;
var iBrush:string;
ist:IStream;
pst:PStream;
TextureBrush:TGPTextureBrush;
GPImage: TGPImage;
wrap: integer;
GPMatrix: TGPMatrix;
bmpLoad:PBitmap;
begin
if not Assigned(_prop_Canvas) then exit;
if _prop_FromFile then
begin
GPImage := TGPImage.Create(ReadString(_data,_data_FileName,_prop_FileName));
if GPImage.GetType <> ImageTypeBitmap then exit;
end
else
begin
bmpLoad := ReadBitmap(_Data,_data_Picture,nil);
if (bmpLoad <> nil) then
bmp.Assign(bmpLoad);
if bmp.Empty then
exit;
pst := NewMemoryStream;
bmp.SaveToStream(pst);
if CreateStreamOnHGlobal(0, true, ist) = S_OK
then ist.write(pSt.Memory,pst.Size,nil);
GPImage := TGPImage.Create(ist);
pst.Free;
ist := nil;
end;
wrap := ReadInteger(_data,_data_WrapMode,_prop_WrapMode);
iBrush := ReadString(_data,_data_Index,_prop_Index);
TextureBrush := TGPTextureBrush.Create(GPImage, TWrapMode(wrap));
GPImage.Free;
if _prop_UseMatrix then begin
TextureBrush.SetTransform(_prop_Canvas.Get_Matrix);
GPMatrix := _prop_Canvas.Get_Matrix;
GPMatrix.Reset;
end;
_prop_Canvas.Set_Brush(TextureBrush.Clone,iBrush);
TextureBrush.Free;
_hi_CreateEvent(_Data,@_event_onSet);
end;
procedure THIGP_BrushTexture._work_doFromFile;
begin
_prop_FromFile := ReadBool(_Data);
end;
procedure THIGP_BrushTexture.SetPicture;
begin
if Value = 0 then exit;
bmp.Handle := Value;
end;
end.
Ответов: 2236
Рейтинг: 676
|
|||
Внес изменения в pas файл:
|
|||
карма: 11 |
|
Редактировалось 1 раз(а), последний 2023-04-01 16:32:35