How to implement GDI+

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
aby
Posts: 81
Joined: 21 May 2007, 13:02
Location: Turkey

How to implement GDI+

Post by aby » 30 May 2007, 23:23

I want to fill an area with AlphaBlended colors. Is there any example on how to use GDI+ with CADVCL.

Thanks

Sabetay

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 31 May 2007, 13:40

Hello Sabetay,

The following example is base on a demo available at: http://www.cadsofttools.com/download/Template.zip

Code: Select all

<b>procedure</b> TForm1.Button1Click(Sender: TObject);
<b>const</b>
  cnstLayerName: string = <font color="blue">'new_Layer'</font id="blue">;
  cnstLTypeName: string = <font color="blue">'new_LType'</font id="blue">;
<b>var</b>
  vImg: TsgDXFImage;
  vHatch1,vHatch2: TsgCADCurvePolygon;
  vBoundary: Tsg2DBoundaryList;
  vEllipse: Tsg2DEllipse;
  vLType: TsgDXFLineType;
<b>begin</b>
  vImg := TsgDXFImage.Create;
  <b>try</b>
    vImg.Converter.InitializeSections;
    <font color="blue"><i>{ Adding the new linetype to image-converter }</i></font id="blue">
    vLType := TsgDXFLineType.Create;
    vLType.Name := cnstLTypeName;
    vLType.Lines.AddTick(<font color="blue">25</font id="blue">);       <font color="blue"><i>// length of the "solid" part of a line</i></font id="blue">
    vLType.Lines.AddTick(<font color="blue">-12.5</font id="blue">);    <font color="blue"><i>// length of the "empty" part of a line</i></font id="blue">
    vImg.Converter.Sections[csLTypes].AddEntity(vLType);

    vHatch1 := TsgCADCurvePolygon.Create;
    vImg.Layouts[<font color="blue">0</font id="blue">].AddEntity(vHatch1);
    vBoundary := Tsg2DBoundaryList.Create;
    vHatch1.BoundaryData.Add(vBoundary);
    vEllipse := Tsg2DEllipse.Create;
    vBoundary.Add(vEllipse);
    vEllipse.CenterPoint := MakeF2DPoint(<font color="blue">0</font id="blue">,<font color="blue">0</font id="blue">);
    vEllipse.MajorPoint := MakeF2DPoint(<font color="blue">0</font id="blue">,<font color="blue">100</font id="blue">);
    vEllipse.Radius := <font color="blue">2</font id="blue">;

    vHatch1.Color := clRed;
    vImg.Converter.Loads(vHatch1);

    vHatch2 := TsgCADCurvePolygon.Create;
    vImg.Layouts[0].AddEntity(vHatch2);
    vBoundary := Tsg2DBoundaryList.Create;
    vHatch2.BoundaryData.Add(vBoundary);
    vEllipse := Tsg2DEllipse.Create;
    vBoundary.Add(vEllipse);
    vEllipse.CenterPoint := MakeF2DPoint(<font color="blue">80</font id="blue">,<font color="blue">80</font id="blue">);
    vEllipse.MajorPoint := MakeF2DPoint(<font color="blue">0</font id="blue">,<font color="blue">80</font id="blue">);
    vEllipse.Radius := <font color="blue">2</font id="blue">;
    vHatch2.Color := <font color="blue">$9900FF00</font id="blue">;   <font color="blue"><i>// 99 specifies a transparency </i></font id="blue">
    vImg.Converter.Loads(vHatch2);

    vImg.GetExtents;
    sgPaintBox.Picture.Graphic := vImg;
    sgPaintBox.Width := Round(vImg.AbsWidth);
    sgPaintBox.Height := Round(vImg.AbsHeight);
    sgPaintBox.Invalidate;
  <b>finally</b>
    vImg.Free;
  <b>end</b>;
<b>end</b>;
Sergey:

Please post questions to the forum or write to support@cadsofttools.com

Post Reply