// Paint Ellipse With GDI API
with ImageEnView1 do
begin
Proc.UndoRect(XScr2Bmp(startX), YScr2Bmp(startY), XScr2Bmp(lastX), YScr2Bmp(lastY));
IEBitmap.Canvas.Pen.Color := PaintColor.Color;
if not Filled1.Checked then
begin
IEBitmap.Canvas.Brush.Style := bsClear;
IEBitmap.Canvas.Ellipse(XScr2Bmp(startX), YScr2Bmp(startY), XScr2Bmp(X), YScr2Bmp(Y));
end
else
begin
if DrawBorderOpague1.Checked then
Transparency := 255
else
Transparency := ((StrToInt(Opacity1.Text) * 255) div 100);
IEBitmap.Canvas.Ellipse(XScr2Bmp(startX), YScr2Bmp(startY), XScr2Bmp(X), YScr2Bmp(Y));
IEBitmap.Canvas.Pen.Color := PaintColor.Color;
IEBitmap.Canvas.Brush.Color := FillColor.Color;
IEBitmap.AlphaChannel.Canvas.Brush.Color := FillColor.Color;
IEBitmap.Canvas.Brush.Style := bsSolid;
IEBitmap.AlphaChannel.Canvas.Pen.Color := $02000000 or (Transparency) or (Transparency shl 8) or (Transparency shl 16);
Transparency := ((StrToInt(Opacity1.Text) * 255) div 100);
IEBitmap.AlphaChannel.Canvas.Brush.Color := $02000000 or (Transparency) or (Transparency shl 8) or (Transparency shl 16);
if DrawBorderOpague1.Checked then
Transparency := 255
else
Transparency := ((StrToInt(Opacity1.Text) * 255) div 100);
IEBitmap.AlphaChannel.Canvas.Ellipse(XScr2Bmp(startX), YScr2Bmp(startY), XScr2Bmp(X), YScr2Bmp(Y));
end;
Update;
end;
You will get much nicer drawings if you use a TIECanvas that uses GDIPlus:
procedure TForm1.DrawFilledEllipse;
{Draw a filled ellipse}
var
iPenSize: integer;
iPenColor: TColor;
iPenAlpha: integer;
iBrushColor: TColor;
iBrushAlpha: integer;
begin
MyUndo(ImageEnView1);
// Draw on the Non-Alpha Canvas
NewCanvas := TIECanvas.Create(ImageEnView1.IEBitmap.Canvas, AntiAlias1.Checked, UseGDIPlus1.Checked);
iPenSize := StrToInt(BrushSize1.Text);
iPenColor := PenColor1.Selected;
iPenAlpha := StrToInt(PenAlpha1.Text);
iBrushColor := BrushColor1.Selected;
iBrushAlpha := StrToInt(BrushAlpha1.Text);
NewCanvas.Pen.Color := iPenColor;
NewCanvas.Pen.Style := psSolid;
NewCanvas.Pen.Width := iPenSize;
NewCanvas.Brush.Color := iBrushColor;
NewCanvas.Brush.BackColor := iBrushColor;
NewCanvas.Brush.Style := bsSolid;
NewCanvas.Brush.Transparency := iBrushAlpha;
NewCanvas.Brush.BackTransparency := iBrushAlpha;
NewCanvas.Ellipse(startX, startY, PX + iPenSize, PY + iPenSize);
NewCanvas.Free();
ImageEnView1.IEBitmap.AlphaChannel.CanvasCurrentAlpha := iPenAlpha;
// Draw on the Alpha Canvas
// Note: do not assign color here... it will overwrite the alphachannel
// Note: unless you assign the AlphaChannel.CanvasCurrentAlpha the pen has an alpha of 0 even though
// NewCanvas.Pen.Transparency is set before drawing
NewCanvas := TIECanvas.Create(ImageEnView1.IEBitmap.AlphaChannel.Canvas, AntiAlias1.Checked, UseGDIPlus1.Checked);
NewCanvas.Pen.Width := iPenSize;
NewCanvas.Pen.Style := psSolid;
NewCanvas.Brush.Style := bsSolid;
NewCanvas.Brush.Transparency := iBrushAlpha;
NewCanvas.Brush.BackTransparency := iBrushAlpha;
NewCanvas.Ellipse(startX, startY, PX + iPenSize, PY + iPenSize);
NewCanvas.Free();
ImageEnView1.IEBitmap.AlphaChannel.CanvasCurrentAlpha := iBrushAlpha;
ImageEnView1.Bitmap.Modified := True;
end;
My EBook has a GDIPlus- TIECanvas demonstration project in a zip file that is included with the EBook as well as some paragraphs about using TIECanvas.

645.11 KB
William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html