• GDI+ 学习记录(29): 区域 Region


    //创建并填充区域
    var
      g: TGPGraphics;
      sb: TGPSolidBrush;
      region: TGPRegion; {定义区域}
    begin
      g := TGPGraphics.Create(Canvas.Handle);
      sb := TGPSolidBrush.Create(aclGold);
    
      region := TGPRegion.Create(MakeRect(50, 50, 150, 150)); {建立区域}
      g.FillRegion(sb, region);                               {填充区域}
    
      sb.Free;
      region.Free;
      g.Free;
    end;
    
    //根据路径建立区域 var g: TGPGraphics; path: TGPGraphicsPath; region: TGPRegion; sb: TGPSolidBrush; const pts: array[0..3] of TGPPoint = ((x:10 ; y:10 ), (x:150; y:10 ), (x:100; y:75 ), (x:100; y:150)); begin g := TGPGraphics.Create(Canvas.Handle); sb := TGPSolidBrush.Create(aclRed); path := TGPGraphicsPath.Create; path.AddPolygon(PGPPoint(@pts), Length(pts)); region := TGPRegion.Create(path); {根据路径建立区域} g.FillRegion(sb, region); g.Free; path.Free; region.Free; sb.Free; end;
    //区域联合 var g : TGPGraphics; sb: TGPSolidBrush; region: TGPRegion; begin g := TGPGraphics.Create(Canvas.Handle); sb := TGPSolidBrush.Create(aclYellowGreen); region := TGPRegion.Create(MakeRect(50, 0, 50, 150)); {建立区域} region.Union(MakeRect(0, 50, 150, 50)); {区域联合} g.FillRegion(sb, region); {填充} sb.Free; region.Free; g.Free; end;
    //用区域剪切画板 var g : TGPGraphics; sb: TGPSolidBrush; p: TGPPen; region: TGPRegion; font: TGPFont; begin g := TGPGraphics.Create(Canvas.Handle); sb := TGPSolidBrush.Create(aclYellowGreen); p := TGPPen.Create(aclRed); font := TGPFont.Create('宋体',12); region := TGPRegion.Create(MakeRect(50, 0, 50, 150)); {建立区域} region.Union(MakeRect(0, 50, 150, 50)); {区域联合} g.FillRegion(sb, region); g.SetClip(region); {用区域剪切画板} g.DrawLine(p, 0, 0, 100, 100); {测试画板剪切后的直线} sb.SetColor(aclBlack); g.DrawString('万一万一万一', -1, font, MakePoint(20.0,20.0), sb); {测试文本} sb.Free; p.Free; region.Free; font.Free; g.Free; end;
  • 相关阅读:
    ColorPix——到目前为止最好用的屏幕取色器
    ES+VBA 实现批量添加网络图片
    SQL语句-delete语句
    Visual C++ 2013 and Visual C++ Redistributable Package 更新版官网下载地址
    centos长ping输出日志的脚本
    Centos 常用命令
    c#连接数据库
    C#窗体间的跳转传值
    c#邮件发送
    C#WIFI搜索与连接
  • 原文地址:https://www.cnblogs.com/del/p/1017613.html
Copyright © 2020-2023  润新知