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
321 stars 93 forks source link

Image not drawn completly #254

Closed jfudickar closed 1 year ago

jfudickar commented 1 year ago

Have a look at this SVG file (generated from plantuml). In the legend at the end there are empty coloured rectangles which are not drawn in delphi : grafik but drawn when showing the file in the edge browser: spacex_launch_latest compact

Regards Jens

carloBarazzetta commented 1 year ago

Please attach the SVG file...

jfudickar commented 1 year ago

It must be attached somehow, because I dragged it in. Try the right mouse click on the big image and save as.

jfudickar commented 1 year ago

Should be here : https://user-images.githubusercontent.com/3485451/224549327-5f297927-e1ce-492b-94d3-dbeb6382c9a3.svg

carloBarazzetta commented 1 year ago

I've notice that the problems are in those 4 lines: adding an 'X' instead of three spaces shows the X with correct background color... `X

X X X

` Maybe an incorrect use of background text color for spaces, in Image32 SVG Library of Angus: https://github.com/AngusJohnson/Image32

jfudickar commented 1 year ago

Will you raise a ticket there? I can't work with the X :-)

AngusJohnson commented 1 year ago

Hi Jens. I can confirm there is a bug in Image32's SVG reader, but I can't see an easy fix. While I've only had a quick look so far, the issue seems to be related to getting the correct bounds of the floodfill filter element.

jfudickar commented 1 year ago

Hi Angus, I have not a real problem with it. The delphi implementation is only a "nice to have" of my json2puml project. Most of the people will work with the svg file directly. But I wanted to mention it :-)

AngusJohnson commented 1 year ago

Here's a 'quick and dirty' solution ...

In TShapeElement.Draw() in Img32.SVG.Reader @ line ~2100

    //get special effects bounds
    if Assigned(clipPathEl) then
    begin
      ....
    end
    else if Assigned(maskEl) then
    begin
      ....
    end else
    begin
      clipRec := drawDat.bounds;
      // add this //////////////////
      if clipRec.IsEmpty and
        (drawDat.fontInfo.textLength > 0) and
        (self is TSubtextElement) then
      begin
        clipRec.Left := fParent.elRectWH.left.rawVal;
        clipRec.Bottom := fParent.elRectWH.top.rawVal;
        clipRec.Right := clipRec.Left + drawDat.fontInfo.textLength;
        clipRec.Top := clipRec.Bottom - drawDat.fontInfo.size;
      end;
      //////////////////////////////
jfudickar commented 1 year ago

Yes seems to fix it. Nice. And thanks!!!

jfudickar commented 1 year ago

After upgrading to v4 the problem is back :-(

jfudickar commented 1 year ago

Adding the line fixes it again !

carloBarazzetta commented 1 year ago

Oh, sorry, but I've aligned Image32 source code of @AngusJohnson retrieved from His Gitub repo, probably it was not updated...

AngusJohnson commented 1 year ago

I've just updated the Image32 repository and the fix above has been included.