代码之家  ›  专栏  ›  技术社区  ›  Ian Boyd

GDI+等效GDI矩形

  •  0
  • Ian Boyd  · 技术社区  · 7 年前

    GDI+与GDI的等价物是什么 Rectangle

    enter image description here

    | Library | Outline       | Fill interior | Both        |
    |---------|---------------|---------------|-------------|
    | GDI     | FrameRect     | FillRect      | Rectangle   |
    | GDI+    | DrawRectangle | FillRectangle | ?           |
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Ian Boyd    7 年前

    GDI+版本 Rectangle

    :

    class procedure TGDIPlusHelper.Rectangle(g: TGPGraphics; OutlinePen: TGPPen; InteriorFillBrush: TGPBrush; x, y, width, height: Single);
    begin
        //GDI has Rectangle.
        //GDI+ we simulate it with FillRectangle followed by DrawRectangle
        g.FillRectangle(InteriorFillBrush, x, y, width, height);
        g.DrawRectangle(OutlinePen, x, y, width, height);
    end;
    

    C级# :

    void Rectangle(Graphics g, Pen outlinePen; Brush interiorFillBrush, Single x, Single y, Single width, Single height)
    {
        //GDI has Rectangle.
        //GDI+ we simulate it with FillRectangle followed by DrawRectangle
        g.FillRectangle(InteriorFillBrush, x, y, width, height);
        g.DrawRectangle(OutlinePen, x, y, width, height);
    }