I want to make a TIFF with a transparent background but I can't work out how. My feeble attempt at some code is:
var
srcx: PRGBTripleArray;
destx: pbyte;
y, x: integer;
begin
//source image assigned to ImageEnView1.IEBitmap....
ImageEnView1.io.Params.TIFF_Compression := ioTIFF_LZW;
ImageEnView1.io.Params.TIFF_PhotometInterpret := ioTIFF_TRANSPMASK ;
for y := 0 to ImageEnView1.IEBitmap.Height - 1 do
begin
srcx := ImageEnView1.IEBitmap.Scanline[y];
destx := ImageEnView1.IEBitmap.alphachannel.ScanLine[y];
for x := 0 to ImageEnView1.IEBitmap.Width - 1 do
begin
if (srcx[x].Red = GetRValue(TranspColor))
and (srcx[x].Blue = GetBValue(TranspColor))
and (srcx[x].Green = GetGValue(TranspColor)) then
destx[x] := 0
else
destx[x] := 255;
end;
end;
ImageEnView1.IEBitmap.SyncAlphaChannel();
ImageEnView1.Update;
ImageEnView1.io.SaveToFileTIFF(Filename);
end;
The Alphachannel looks correct, in that interrogating the pixels[x,y] shows some are 0, some are 255 however something else is obviously wrong as my TIFFs never have a transparent background!