用一个椭圆的REGION把图片裁减画到背景上就可以了么!老大!
CreateEllipticRgn Windows.pas
Syntax
CreateEllipticRgn(
p1: Integer; {the upper-left bounding box horizontal coordinate}
p2: Integer; {the upper-left bounding box vertical coordinate}
p3:Integer; {the lower-right bounding box horizontal coordinate}
p4: Integer {the lower-right bounding box vertical coordinate}
): HRGN; {returns a handle to a region}
Description
This function creates an elliptical region. The specified coordinates represent the smallest
rectangle that can be drawn around the resulting ellipse. When the region is no longer
needed, it should be deleted by calling the DeleteObject function.
Parameters
p1: Specifies the horizontal coordinate of the upper-left corner of the rectangle bounding
the ellipse in logical units.
p2: Specifies the vertical coordinate of the upper-left corner of the rectangle bounding the
ellipse in logical units.
p3: Specifies the horizontal coordinate of the lower-right corner of the rectangle bounding
the ellipse in logical units.
p4: Specifies the vertical coordinate of the lower-right corner of the rectangle bounding
the ellipse in logical units.
Return Value
If the function succeeds, it returns a handle to an elliptical region; otherwise, it returns
zero.
See Also
CreateEllipticRgnIndirect, DeleteObject
Example
See Listing 11-4 under CombineRgn.
CreateEllipticRgnIndirect Windows.pas
Syntax
CreateEllipticRgnIndirect(
const p1: TRect {a pointer to rectangular coordinates}
): HRGN; {returns a handle to a region}
Description
This function creates an elliptical region based on the rectangular coordinates pointed to
by the p1 parameter. The specified coordinates represent the smallest rectangle that can be
Region and Path Functions 469
Chapter
11
drawn around the resulting ellipse. When the region is no longer needed, it should be
deleted by calling the DeleteObject function.
Parameters
p1: A pointer to a TRect structure containing coordinates, in logical units, that define the
smallest rectangle that can be drawn around the resulting ellipse.
Return Value
If the function succeeds, it returns a handle to an elliptical region; otherwise, returns zero.
See Also
CreateEllipticRgn, DeleteObject
Example
Listing 11-5: Dynamically creating an elliptical region based on the form size
var
Form1: TForm1;
TheRegion: HRGN; // holds the elliptical region
implementation
{$R *.DFM}
procedure TForm1.FormPaint(Sender: TObject);
begin
{erase the current image on the form}
Canvas.Brush.Color := clBtnFace;
Canvas.FillRect(BoundsRect);
{outline the elliptical region in red}
Canvas.Brush.Color := clRed;
FrameRgn(Canvas.Handle, TheRegion, Canvas.Brush.Handle, 2, 2);
end;
procedure TForm1.FormResize(Sender: TObject);
begin
{delete the current region, if it exists}
if TheRegion<>0 then
DeleteObject(TheRegion);
{create a new elliptical region based on the boundaries of the client area}
TheRegion := CreateEllipticRgnIndirect(ClientRect);
{repaint the form}
Repaint;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
{delete the elliptical region}
DeleteObject(TheRegion);
end;