[Lazarus] Canvas cannot draw properly if has an alpha channel?

Anthony Walter sysrpl at gmail.com
Wed Apr 25 16:30:55 CEST 2018

I am trying to paint controls, so I need to eventually Canvas.Draw() to get
a graphic onto a control. I've been working on creating a fully featured
web browser for Lazarus and have been looking at the underlying widgetset
interface code.

Gtk3, which my project currently works great on, uses the now required
Cairo system for painting Gtk widgets. I've already had to patch the Gtk3
LCL interface section quite a bit to fix errors and I'll submit those
changes when I publish my project.

However, the LCL Gtk2 widgetset is stuck using the Gdk system for drawing,
even though that was deprecated early on in the Gtk2 lifetime and Cairo has
been recommend for a decade or more. I would like to submit a patch for
Gtk2 replacing Gdk with Cairo, but using a swtich setting that could be
changed at runtime.

GDI+ has been available for Windows since XP was released in 2001, and
Direct2D since Windows 7 in 2009. I think it's about time we upgrade the
Windows graphics from GDI to at least GDI+.

I am willing to contribute to these changes, but I would want assurances
that we would accept a common interface for the advanced features all these
improved graphics back-ends include. They all include alpha blending,
gradient brushes, matrix transforms, vector shaped clipping paths, and

My recommend approach to adding these features to the core LCL Canvas class
would be to:

A) Change the underlying widgetset to operate with these new graphic
backends and operate the same as before, but fixing a few problems like
allowing Canavs.Draw to work between 32 bits per pixel surfaces correctly.

B) Add an advanced canvas interface for new features like gradient brushes,
vector clipping paths and such. Widgetsets can implement the advanced
interface and use it in conjunction with the original TCanvas class.


Canvas.Matrix.Rotate(PI / 6);

  TPolygon = array of TPointF;

  IAdvancedCanvas = interface
    procedure AddPath(Polygon: TPolygon);
    procedure Clip;
    procedure Fill(Brush: IBrush);
    property Matrix: IMatrix read GetMatrix write SetMatrix;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180425/a82e6ae0/attachment.html>

More information about the Lazarus mailing list