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

Backgroud Transparency #195

Closed LeonVeganMan closed 3 years ago

LeonVeganMan commented 3 years ago

Hi, first of all thank you for your wonderful work !!

In your demo, but also in my application, applying a FixedColor, the original background (transparent) going to semi transparent. Schermata del 2021-07-28 15-45-19 Schermata del 2021-07-28 15-44-32

Is this a bug?

Thanx.

Ciao. L.

AngusJohnson commented 3 years ago

I don't really believe this is an Image32 bug,but it can still be fixed by changing the TImage32.SetRGB method in Img32.pas to this ....

procedure TImage32.SetRGB(rgbColor: TColor32);
var
  rgb: TARGB absolute rgbColor;
  r,g,b: Byte;
  i: Integer;
  pc: PARGB;
begin
  //this method leaves the alpha channel untouched
  if IsEmpty then Exit;
  r := rgb.R; g := rgb.G; b := rgb.B;
  pc := PARGB(PixelBase);
  for i := 0 to Width * Height -1 do
    if pc.A = 0 then
    begin
      pc.Color := 0;
      inc(pc);
    end else
    begin
      pc.R := r;
      pc.G := g;
      pc.B := b;
      inc(pc);
    end;
  Changed;
end;