Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-01

TFPCanvasDrawer and anti-alias.

12 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

TFPCanvasDrawer provides anti-alias support?

Thank you!

Silvio Clécio My public projects - github.com/silvioprog
Michael Van Canneyt
to silvioprog
silvioprog wrote
Hello, TFPCanvasDrawer provides  anti-alias support?

Not for lines. For texts, it should be able to add it.

Michael.

silvioprog
to Michael Van Canneyt

2013/1/28 Michael Van Canneyt

Show quoted text 7 lines
On Mon, 28 Jan 2013, silvioprog wrote: > Hello, > TFPCanvasDrawer provides anti-alias support? > Not for lines.

Sniff. :'(

I'm trying to generate charts in my CGI apps:

http://silvioprog.com.br/cgi-bin/cgi1

And PDF with PowerPDF (I'll send a patch soon to remove some LCL dependences):

http://silvioprog.com.br/cgi-bin/cgi2 (Clique "aqui" = Click "here")

For texts, it should be able to add it.

Yes:

procedure TFPCanvasDrawer.EnsureFont;
begin
  {$IFDEF USE_FTFONT}
  if FFont  nil then exit;
  FFont := TFreeTypeFont.Create;
  FFont.Resolution := 72;
  FFont.AntiAliased := False; <<<< I'll set it for True. It would be
interesting if there was a property to handle it.:)
  FCanvas.Font := FFont;
  {$ENDIF}
end;

Thanks for the fast reply man! :)

ps. I'm very, very happy with the Free Pascal. Now, I'm creating fine my PDFs and charts. I will make one layer to facilitate the use of some classes of PowerPDF and TAChart.

Silvio Clécio My public projects - github.com/silvioprog
Leonardo M. Ramé
to silvioprog
Show quoted text 14 lines
________________________________ From: silvioprog To: FPC-Pascal users discussions Sent: Monday, January 28, 2013 8:32 PM Subject: Re: [fpc-pascal] TFPCanvasDrawer and anti-alias. 2013/1/28 Michael Van Canneyt On Mon, 28 Jan 2013, silvioprog wrote: > >Hello, >>TFPCanvasDrawer provides  anti-alias support? >> >

Not for lines.

Show quoted text 40 lines
Sniff. :'( I'm trying to generate charts in my CGI apps: http://silvioprog.com.br/cgi-bin/cgi1 And PDF with PowerPDF (I'll send a patch soon to remove some LCL dependences): http://silvioprog.com.br/cgi-bin/cgi2 (Clique "aqui" = Click "here")   For texts, it should be able to add it. > Yes: procedure TFPCanvasDrawer.EnsureFont; begin   {$IFDEF USE_FTFONT}   if FFont nil then exit;   FFont := TFreeTypeFont.Create;   FFont.Resolution := 72;   FFont.AntiAliased := False; <<<< I'll set it for True. It would be interesting if there was a property to handle it.:)   FCanvas.Font := FFont;   {$ENDIF} end; Thanks for the fast reply man! :) ps. I'm very, very happy with the Free Pascal. Now, I'm creating fine my PDFs and charts. I will make one layer to facilitate the use of some classes of PowerPDF and TAChart.

Silvio, TAchart has a BGRABitmap backend mode, it creates great anti-aliased graphics (both lines and text). I didn't tested on CGI without linking against graphic libraries, I think it relies on TCanvas, so maybe it won't work, but it worth a try.

Leonardo M. Ramé
http://leonardorame.blogspot.com

silvioprog
to Leonardo M. Ramé: Not for lines. Silvio, TAchart has a BGRABitmap backend mode, it creates great…

2013/1/28 Leonardo M. Ramé

Show quoted text 10 lines
[...] Silvio, TAchart has a BGRABitmap backend mode, it creates great anti-aliased graphics (both lines and text). I didn't tested on CGI without linking against graphic libraries, I think it relies on TCanvas, so maybe it won't work, but it worth a try. Leonardo M. Ramé http://leonardorame.blogspot.com

I'll test it now, thank you Leo! :)

Is this the official link to download it?:

https://lazpaint.svn.sourceforge.net/svnroot/lazpaint

Silvio Clécio My public projects - github.com/silvioprog
Leonardo M. Ramé
to Graeme Geldenhuys: Use AggPas. That is exactly why I incorporated it into fpGUI. I needed anti-aliased line…

----- Original Message -----

Show quoted text 19 lines
From: Graeme Geldenhuys To: Cc: Sent: Monday, January 28, 2013 9:15 PM Subject: Re: [fpc-pascal] TFPCanvasDrawer and anti-alias. On 01/28/13 23:32, silvioprog wrote: >> Not for lines. > > > Sniff. :'( > > I'm trying to generate charts in my CGI apps: Use AggPas. That is exactly why I incorporated it into fpGUI. I needed anti-aliased line drawing for graphs etc.

Yes, that's a nice backend for TAchart.

Also you could generate your charts in the browser, using a JavaScript/Html5 library like this one: http://www.humblesoftware.com/flotr2/

 
Leonardo M. Ramé
http://leonardorame.blogspot.com

Leonardo M. Ramé
to silvioprog: 2013/1/28 Leonardo M. Ramé I'll test it now, thank you Leo! :) Is this the official link…
Show quoted text 20 lines
________________________________ From: silvioprog To: Leonardo M. Ramé ; FPC-Pascal users discussions Sent: Monday, January 28, 2013 9:20 PM Subject: Re: [fpc-pascal] TFPCanvasDrawer and anti-alias. 2013/1/28 Leonardo M. Ramé [...] >Silvio, TAchart has a BGRABitmap backend mode, it creates great anti-aliased graphics (both lines and text). I didn't tested on CGI without linking against graphic libraries, I think it relies on TCanvas, so maybe it won't work, but it worth a try. > > >Leonardo M. Ramé >http://leonardorame.blogspot.com _______________________________________________ fpc-pascal maillist  -  http://lists.freepascal.org/mailman/listinfo/fpc-pascal  

svn co svn://svn.code.sf.net/p/lazpaint/code/bgrabitmap

Leonardo M. Ramé
http://leonardorame.blogspot.com

silvioprog
to Graeme Geldenhuys: Use AggPas. That is exactly why I incorporated it into fpGUI. I needed anti-aliased line…

2013/1/28 Graeme Geldenhuys

Show quoted text 15 lines
On 01/28/13 23:32, silvioprog wrote: >> Not for lines. > > > Sniff. :'( > > I'm trying to generate charts in my CGI apps: Use AggPas. That is exactly why I incorporated it into fpGUI. I needed anti-aliased line drawing for graphs etc. Regards, - Graeme -

Installing it now (http://imagebin.org/244603). Thank you Graeme! :)

Silvio Clécio My public projects - github.com/silvioprog
silvioprog
to silvioprog

2013/1/28 silvioprog

Show quoted text 20 lines
2013/1/28 Graeme Geldenhuys > On 01/28/13 23:32, silvioprog wrote: > >> Not for lines. > > > > > > Sniff. :'( > > > > I'm trying to generate charts in my CGI apps: > > Use AggPas. That is exactly why I incorporated it into fpGUI. I needed > anti-aliased line drawing for graphs etc. > > > Regards, > - Graeme - > Installing it now (http://imagebin.org/244603). Thank you Graeme! :)

Fail. :(

program noguidemo;
{$mode objfpc}{$H+}

uses
Interfaces,
Classes,
FPCanvas,
FPImage,
TATools,
TAGraph,
TASeries,
TADrawerFPCanvas,
TADrawerCanvas,
TADrawUtils,

  agg_fpimage;
var
  chart: TChart;
  bs: TBarSeries;
  c: TAggFPCanvas;
  d: IChartDrawer;
begin
  chart := TChart.Create(nil);
  chart.LeftAxis.Marks.LabelFont.Name := 'Arial';
  chart.LeftAxis.Marks.LabelFont.Size := 10;
  chart.LeftAxis.Marks.LabelFont.Orientation := 450;
  chart.LeftAxis.Marks.Frame.Visible := True;
  chart.LeftAxis.Marks.Frame.Style := psSolid;
  chart.LeftAxis.Marks.Frame.FPColor := colBlack;
  chart.LeftAxis.Grid.FPColor := colDkGray;
  chart.BottomAxis.Marks.Visible := False;
  chart.BottomAxis.Grid.FPColor := colDkGray;
  chart.Color := $FFA0A0;
  chart.BackColor := $FFFFFF;
  bs := TBarSeries.Create(nil);
  chart.AddSeries(bs);
  bs.AddXY(1, 10);
  bs.AddXY(2, 7);
  bs.AddXY(3, 8);
  c := TAggFPCanvas.Create;
  c.Width := chart.Width;
  c.Height := chart.Height;
  d := TFPCanvasDrawer.Create(c);
  d.DoGetFontOrientation := @CanvasGetFontOrientationFunc;
  chart.Draw(d, Rect(0, 0, chart.Width, chart.Height));
  c.Image.SaveToFile('test.png');
  c.Free;
  bs.Free;
  chart.Free;
end.

The result is:

http://imagebin.org/244608

I may be using the wrong way, but I did not find documentation to help me with this. :/

Silvio Clécio My public projects - github.com/silvioprog
silvioprog
to Leonardo M. Ramé: Not for lines. Silvio, TAchart has a BGRABitmap backend mode, it creates great…

2013/1/28 Leonardo M. Ramé

Show quoted text 9 lines
[...] Silvio, TAchart has a BGRABitmap backend mode, it creates great anti-aliased graphics (both lines and text). I didn't tested on CGI without linking against graphic libraries, I think it relies on TCanvas, so maybe it won't work, but it worth a try. Leonardo M. Ramé http://leonardorame.blogspot.com

It works fine (see result here: http://imagebin.org/244612) in Win32 with this code:

program noguidemo;
{$mode objfpc}{$H+}

uses
Interfaces,
Classes,
FPCanvas,
FPImage,
FPImgCanv,
TATools,
TAGraph,
TASeries,
TADrawerCanvas,
TADrawUtils,
BGRABitmap,
TAChartUtils,

  TADrawerBGRA;
var
  chart: TChart;
  bs: TBarSeries;
  img: TBGRABitmap;
  d: IChartDrawer;
begin
  chart := TChart.Create(nil);
  chart.LeftAxis.Marks.LabelFont.Name := 'Arial';
  chart.LeftAxis.Marks.LabelFont.Size := 10;
  chart.LeftAxis.Marks.LabelFont.Orientation := 450;
  chart.LeftAxis.Marks.Frame.Visible := True;
  chart.LeftAxis.Marks.Frame.Style := psSolid;
  chart.LeftAxis.Marks.Frame.FPColor := colBlack;
  chart.LeftAxis.Grid.FPColor := colDkGray;
  chart.BottomAxis.Marks.Visible := False;
  chart.BottomAxis.Grid.FPColor := colDkGray;
  chart.Color := $FFA0A0;
  chart.BackColor := $FFFFFF;
  bs := TBarSeries.Create(nil);
  chart.AddSeries(bs);
  bs.AddXY(1, 10);
  bs.AddXY(2, 7);
  bs.AddXY(3, 8);
  img := TBGRABitmap.Create(chart.Width, chart.Height);
  d := TBGRABitmapDrawer.Create(img);
  img.CanvasBGRA.Font.Antialiasing := true;
  img.CanvasBGRA.Font.Name := 'Arial';
  d.DoGetFontOrientation := @CanvasGetFontOrientationFunc;
  chart.Draw(d, Rect(0, 0, chart.Width, chart.Height));
  img.SaveToFile('test.png');
  img.Free;
  bs.Free;
  chart.Free;
end.

But, with NoGUI, the error is:

C:\Users\silvioprog\Desktop\nogui>noguidemo.exe
TRasterImage.BitmapHandleNeeded: Unable to create handles, using default [FORMS.PP] ExceptionOccurred
Sender=EInvalidOperation
Exception=Canvas does not allow drawing
Stack trace:
$004951D4 TCANVAS__REQUIREDSTATE, line 1672 of ./include/canvas.inc $004953F0 TCANVAS__TEXTEXTENT, line 1731 of ./include/canvas.inc $0060A29F GETFONTHEIGHTSIGN, line 236 of bgratext.pas $005BCEFA TBGRADEFAULTBITMAP__INIT, line 1684 of bgradefaultbitmap.pas $005B9DF6 TBGRADEFAULTBITMAP__CREATE, line 732 of bgradefaultbitmap.pas $00401B91 main, line 43 of noguidemo.lpr
TApplication.HandleException Canvas does not allow drawing Stack trace:
$004951D4 TCANVAS__REQUIREDSTATE, line 1672 of ./include/canvas.inc $004953F0 TCANVAS__TEXTEXTENT, line 1731 of ./include/canvas.inc $0060A29F GETFONTHEIGHTSIGN, line 236 of bgratext.pas $005BCEFA TBGRADEFAULTBITMAP__INIT, line 1684 of bgradefaultbitmap.pas $005B9DF6 TBGRADEFAULTBITMAP__CREATE, line 732 of bgradefaultbitmap.pas $00401B91 main, line 43 of noguidemo.lpr
Exception at 004951D4: EInvalidOperation:
Canvas does not allow drawing.

C:\Users\silvioprog\Desktop\nogui>

:(

Silvio Clécio My public projects - github.com/silvioprog
Graeme Geldenhuys
to silvioprog: 2013/1/28 silvioprog Fail. :( program noguidemo; {$mode objfpc}{$H+} uses agg_fpimage; var
silvioprog wrote
Fail. :(

I don't use the AggPas from Lazarus though, so not sure what new dependencies it pulls in.

I believe I saw a LCL bug report about such "weird" bitmaps recently. I don't think the problem is AggPas, but rather one of LCL. Maybe it is worth asking in the Lazarus mailing list.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/