How to draw an image with opacity? lazarus / 21-General ---------------------------------------------------------------------- Jonny · 2025-02-01 15:51 Is it possible to draw an image to appear as a watermark over another? So that it is see-through / semi-transparent. I think that I am close with the test below but I cannot change the "logo: TFPCustomImage" opacity level. Is there a missing command? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program blend;uses  FPImage, FPImgCanv, FPCanvas, FPReadPNG, FPWritePNG;var  img: TFPMemoryImage;  canvas: TFPImageCanvas;  reader: TFPCustomImageReader;  writer : TFPCustomImageWriter;  logo: TFPCustomImage;begin  img := TFPMemoryImage.Create(800, 800);  canvas := TFPImageCanvas.Create(img);  try    canvas.DrawingMode := dmAlphaBlend;    canvas.Pen.Style := psClear;    canvas.Brush.FPColor := colWhite;    canvas.FillRect(0, 0, img.Width, img.Height);    canvas.Brush.FPColor := FPColor($FFFF, $FFFF, 0);    canvas.Rectangle(10, 10, 790, 700);    canvas.Brush.FPColor := FPColor($FFFF, 0, 0, $4000);    canvas.Ellipse(60, 60, 640, 640);    canvas.Brush.FPColor := FPColor(0, 0, $FFFF, $8000);    canvas.Ellipse(0, 100, 600, 600);    logo:=TFPMemoryImage.Create(0,0);    reader := TFPReaderPNG.Create;  writer := TFPWriterPNG.Create;    logo.LoadFromFile('logo.png',reader);    canvas.Draw(0,0,logo); // << draw logo with 50% transparency?  finally    img.SaveToFile('blend.png',writer);    canvas.Free;    img.Free;  end;end. ---------------------------------------------------------------------- wp · 2025-02-01 17:59 Simply, after loading, multiply the alpha value of the logo pixels by a transparency factor. This makes the opaque parts (Alpha = $FFFF) semitransparent, and the fully tranparent parts (Alpha = $0000) stay fully transparent. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure MakeSemiTransparent(AImage: TFPCustomImage; Transparency: Single);var  x, y: Integer;  c: TFPColor;begin  for y := 0 to AImage.Height - 1 do    for x := 0 to AImage.Width - 1 do    begin      c := AImage.Colors[x, y];      c.Alpha := round(c.Alpha * (1.0 - Transparency));      AImage.Colors[x, y] := c;    end;end; [...]    logo:=TFPMemoryImage.Create(0,0);    reader := TFPReaderPNG.Create;  writer := TFPWriterPNG.Create;    logo.LoadFromFile('logo.png',reader);    MakeSemitransparent(logo, 0.75);   // Make logo 75% transparent    canvas.Draw((img.width - logo.Width) div 2, (img.Height - logo.Height) div 2, logo);[...] ---------------------------------------------------------------------- Jonny · 2025-02-02 11:38 Quote from: wpSimply, after loading, multiply the alpha value of the logo pixels by a transparency factor. Simply? Indeed. Once you know it. Thank you very much again. I had spent a day trying to "or" the alpha value. Your example was spot-on as always. Very much appreciated.