public: void FillRegion( Brush* brush, Region* region );
BOOL FillRgn( HDC hdc, // handle to device context HRGN hrgn, // handle to region to be filled HBRUSH hbr // handle to brush used to fill the region );
我是把一幅图完全贴到HRGN中。我试过这样是不行的。 procedure TForm1.Button1Click(Sender: TObject); var Region: HRGN; begin Region := CreateRectRgn(100,100,200,200); FillRgn(Self.Canvas.Handle,Region,Image1.Picture.Bitmap.Canvas.Handle); DeleteObject(Region); end;
TPoints = array of TPoint; PPoints = ^TPoints;procedure TForm1.Button1Click(Sender: TObject); var Region: HRGN; Points: TPoints; begin SetLength(Points,4); Points[0] := Point(100,100); Points[1] := Point(200,100); Points[2] := Point(250,200); Points[3] := Point(120,220); Region := CreatePolygonRgn(PPoints(Points)^,4,ALTERNATE); Self.Canvas.Brush.Bitmap := Image2.Picture.Bitmap; FillRgn(Self.Canvas.Handle,Region,Self.Canvas.Brush.Handle); DeleteObject(Region); end;我试这段程序也不行,因为我要的只是一幅图象完全填充于HRGN中。就象photoshop一样,你可以随意改变一幅图象的形状,图象总会自适应在改变后的形状中。
Brush* brush,
Region* region
);
HDC hdc, // handle to device context
HRGN hrgn, // handle to region to be filled
HBRUSH hbr // handle to brush used to fill the region
);
procedure TForm1.Button1Click(Sender: TObject);
var
Region: HRGN;
begin
Region := CreateRectRgn(100,100,200,200);
FillRgn(Self.Canvas.Handle,Region,Image1.Picture.Bitmap.Canvas.Handle);
DeleteObject(Region);
end;
PPoints = ^TPoints;procedure TForm1.Button1Click(Sender: TObject);
var
Region: HRGN;
Points: TPoints;
begin
SetLength(Points,4);
Points[0] := Point(100,100);
Points[1] := Point(200,100);
Points[2] := Point(250,200);
Points[3] := Point(120,220);
Region := CreatePolygonRgn(PPoints(Points)^,4,ALTERNATE);
Self.Canvas.Brush.Bitmap := Image2.Picture.Bitmap;
FillRgn(Self.Canvas.Handle,Region,Self.Canvas.Brush.Handle);
DeleteObject(Region);
end;我试这段程序也不行,因为我要的只是一幅图象完全填充于HRGN中。就象photoshop一样,你可以随意改变一幅图象的形状,图象总会自适应在改变后的形状中。