ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Transparent TIFF

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
dwilbourn Posted - Oct 01 2022 : 18:50:45
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!
4   L A T E S T    R E P L I E S    (Newest First)
dwilbourn Posted - Oct 04 2022 : 17:31:20
It worked! Thank you!!
xequte Posted - Oct 03 2022 : 21:04:51
Thanks for clarifying. To preserve the alpha channel in ImageEn, the compression must be set to ioTIFF_UNCOMPRESSED.

Here is an example:

// Save a PNG with alpha to TIFF
ImageEnView1.IO.LoadFromFile( 'D:\Alpha.png' );
ImageEnView1.IEBitmap.PixelFormat             := ie24RGB;
ImageEnView1.IO.Params.TIFF_PhotometInterpret := ioTIFF_RGB;
ImageEnView1.IO.Params.SamplesPerPixel        := 4;
ImageEnView1.IO.Params.BitsPerSample          := 8;
ImageEnView1.IO.Params.TIFF_Compression       := ioTIFF_UNCOMPRESSED;
ImageEnView1.IO.SaveToFile( 'D:\Alpha.TIFF' );

http://www.imageen.com/ieforum/attach/xequte/202210321249_Alpha.TIFF

Nigel
Xequte Software
www.imageen.com
dwilbourn Posted - Oct 03 2022 : 02:33:34
TIFF does support Transparency via Alpha channel masks though I concede it is very rare, basically an Adobe only feature. However the statement "Transparency Generally NOT supported" on the ImageEn File Formats help page implies that if ImageEn does not support transparency in general, there must be non-general cases where it does. The TIOTIFFPhotometInterpret value of ioTIFF_TRANSPMASK and the TIFF_NewSubfileType value of "Bit 2 is 1 if the image defines a transparency mask for another image in this TIFF file. The PhotometricInterpretation value must be 4, designating a transparency mask." further reinforce that special case interpretation.

My app does produce transparent PNGs. My problem is that the national standards (written by idiots) that govern many of my customers require that they archive images in TIFF with transparency. Which in practice means they have to (buy and) use PhotoShop to open and re-save all the transparent PNGs from my app.
xequte Posted - Oct 02 2022 : 22:02:51
Hi

Most TIFF formats do not support transparency. You are better to use a format like PNG instead:

http://www.imageen.com/help/File_Formats.html

Nigel
Xequte Software
www.imageen.com