Here is V2.2
This now has automatic colour scanning of a jigsaw picture. It's a brute-force algorithm: make an array of [0..0xFFFFFF) booleans. Set them all to false. Scan the pixels in the image and get their colour. Masking out any alpha bits, make the colour array entry for this colour true.
Starting with zero, scan the array and return a result when you hit a false value. Use that value for the transparent colour.
The default transparent colour when you are not using jigsaws by painting is full red.
Interestingly, scanning the picture of me glugging some nice Corfiot wine revealed that it did indeed have pixels that were black or near black. The first available colour was 3 - which equates to very dark red.
Reading the canvas.pixels[x,y] value is fairly fast. Writing is slow. But to scan the colours there's no need to write, so I'd class this simple algorithm as NWO (Not Worth Optimising).
function TForm_main.GetSafeTransparency: TColor;
var x,y : integer;
col : TColor;
colint: integer;
begin
result := clRed;
// scan the bitmap of the "real" image, which is bmp2
for y :=0 to bmp2.Height-1 do
for x := 0 to bmp2.width-1 do
begin
col := bmp2.Canvas.Pixels[x,y];
colint := ColorToRGB(col) and $00FFFFFF;
try
ColourMap[colint] := true;
except
showmessage(inttostr(colint));
exit
end;
end;
for x:= 0 to $FFFFFF do
if not colourmap[x] then
begin
result := TColor(x);
exit;
end;
end;
Enjoy! I've just poured a glass of vino, unfortunately not in Greece until late June.
Onwards and sometimes upwards