How to implement GDI+
Moderators: SDS, support, admin
How to implement GDI+
I want to fill an area with AlphaBlended colors. Is there any example on how to use GDI+ with CADVCL.
Thanks
Sabetay
Thanks
Sabetay
Hello Sabetay,
The following example is base on a demo available at: http://www.cadsofttools.com/download/Template.zip
Sergey:
Please post questions to the forum or write to support@cadsofttools.com
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>;
Please post questions to the forum or write to support@cadsofttools.com