创建一不规则的HRGN,如何让图象填充到这个HRGN中,就象photoshop的自由变换一样,可以改变图象的形状。

解决方案 »

  1.   

    public: void FillRegion(
       Brush* brush,
       Region* region
    );
      

  2.   

    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
    );
      

  3.   

    我是把一幅图完全贴到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;
      

  4.   

    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一样,你可以随意改变一幅图象的形状,图象总会自适应在改变后的形状中。
      

  5.   

    Mark计算机图像处理的书上应该有算法介绍.
      

  6.   

    參考這個:http://community.borland.com/article/0,1410,19534,00.html
      

  7.   

    http://www.delphibbs.com/delphibbs/dispq.asp?lid=222138
      

  8.   

    先定义好图象的形状,然后将图象自适应在形状中,我不相信这没办法解决。photoshop可以办得到的功能delphi我相信肯定能够实现。