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

Drawing problem on FMX with new Image32 3.4.1 #205

Closed carloBarazzetta closed 3 years ago

carloBarazzetta commented 3 years ago

I've found some problems on FMX drawing after update to Image32 3.4.1 A strange "white" surround of images and some icons with white background instead of transparency.

image image

AngusJohnson commented 3 years ago

Hi Carlo. This can be fixed by adding a line to TColorRenderer.RenderProc in Img32.Draw as demonstrated below:

procedure TColorRenderer.RenderProc(x1, x2, y: integer; alpha: PByte);
var
  i: integer;
  dst: PColor32;
begin
  dst := GetDstPixel(x1,y);
  for i := x1 to x2 do
  begin
    //BlendToAlpha is marginally slower than BlendToOpaque but it's used
    //here because it's universally applicable.
    //Ord() is used here because very old compilers define PByte as a PChar
    if Ord(alpha^) > 1 then // ADD THIS LINE
      dst^ := BlendToAlpha(dst^, ((Ord(alpha^) * fAlpha) shr 8) shl 24 or fColor);
    inc(dst); inc(alpha);
  end;
end;

ps: the use of Ord() above may seem strange but it's necessary for Delphi 7 compatability.

carloBarazzetta commented 3 years ago

Fixed in 3.1.1 version