简体   繁体   English

如何将椭圆或多边形从一个位图复制到另一个位图

[英]How to copy ellipse or polygon from one bitmap to another bitmap

How Can I copy an ellipse or polygon shape from one bitmap to another Bitmap. 如何将椭圆或多边形形状从一个位图复制到另一个位图。 BitBlt is only useful for copying Rectangles. BitBlt仅对复制矩形有用。

I currently use GDI but If it is easier to use GDI+, I can use it. 我目前使用GDI,但如果使用GDI +更容易,则可以使用它。 I only need a general guidance to show me the right direction. 我只需要一般指导即可为我指明正确的方向。

You could select an elliptic/polygon clip region into the target device context and then use BitBlt as usual. 您可以在目标设备上下文中选择一个椭圆/多边形剪辑区域,然后照常使用BitBlt。

var
  Rgn: HRGN;
  Points: array[0..2] of TPoint;
begin
  //Rgn := CreateEllipticRgn(0, 0, 100, 100);

  Points[0] := Point(0, 0);
  Points[1] := Point(50, 50);
  Points[2] := Point(50, 0);
  Rgn := CreatePolygonRgn(Points, 3, WINDING);

  SaveDC(Canvas.Handle);
  SelectClipRgn(Canvas.Handle, Rgn);
  DeleteObject(Rgn); // SelectClipRgn copies the region

  BitBlt(Canvas.Handle, 0, 0, 100, 100, BmpDC, 0, 0, SRCCOPY);

  RestoreDC(Canvas.Handle, -1);
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM