EtheaDev / SVGIconImageList

Three engines to render SVG (Delphi Image32, Skia4Delphi, Direct2D wrapper) and four components to simplify use of SVG images (resize, fixedcolor, grayscale...)
Apache License 2.0
327 stars 96 forks source link

How does TSVGIconImage pick up its background color? #150

Closed luebbe closed 3 years ago

luebbe commented 3 years ago

Hi Folks,

I have the following problem. I placed a TPanel on a Form and a TSVGIconImage on the TPanel. The TPanel has a color which is different from the window color. The application is using VCL Styles. Delphi 10.3.1

In the following screenshot the

In both cases the TSVGIconImage uses the window background color and not the color of the panel on which it sits. ParentBackground is true.

grafik

Obviously I want the TSVGIconImage to pick up its parent's color and not the window's color. How can I achieve this?

carloBarazzetta commented 3 years ago

I've made some tests and notice a similar but strange issue: Form -> Panel (Color = clRed) -> SVGIconImage If Form.DoubleBuffered is False the SVGIconImage draw a Red Background only without VCLStyle active (uses clRed of Panel) If Form.DoubleBuffered is True the SVGIconImage draw a Red Background also with VCLStyle active (uses clRed of Panel) In past, when the SVGIconImage inherits from TGraphicControl (but without DoubleBuffer support) this problem was not present... In your example, is the Form or the Panel DoubleBuffered ?

luebbe commented 3 years ago

Thanks for the hint. That may be a reason. I'll check, when I'm back at work tomorrow.

luebbe commented 3 years ago

Yes, I can confirm that SvgImage.Parent.DoubleBuffererd := false solves the problem. Form.DoubleBuffered was true.

grafik

For the panel on which the bottom "Wifi" icon sits, I set ParentDoubleBuffered := false and DoubleBuffered := false and got the expected result.

You can close the ticket if you see no reason to change something in the code of SVGIconImageList. For me it means that I have to place the TSvgIconImage on a panel that has (Parent)DoubleBuffered := false.

carloBarazzetta commented 3 years ago

Ok, but I don't know if this works correctly... I would like to investigate the problem further...

luebbe commented 3 years ago

Yes, it would be good, because the standard behaviour yields an unexpected result and requires a workaround.

pyscripter commented 3 years ago

Double-buffering is an issue only with the TSVG backend. Direct2D does double-buffering anyway (I am not sure about Cairo). It was introduced because it make a large difference in rendering speed. But for small SVGs this does not matter.

carloBarazzetta commented 3 years ago

new version of TSVGIconImage now derived from TGraphicControl to solve some painting issue. With Image32 lib the painting is fast. I'm closing this discussion: if you find some problems please reopen a new issue.