Connecting Tech Pros Worldwide Forums | Help | Site Map

PNG tEXt Chunk

Member
 
Join Date: Mar 2008
Posts: 90
#1: Dec 29 '08
I'm trying to get the tEXt comment chunk from inside a png image. I can see the text if I open the .png file in a text editor however right clicking on it and going to properties doesn't show it there.

Am I just going to have to open the .png as a stream and go byte by byte or is there any references or methods that can obtain it for me?

RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,393
#2: Dec 29 '08

re: PNG tEXt Chunk


Are you trying this in C#? What have you tried already?
Member
 
Join Date: Mar 2008
Posts: 90
#3: Dec 29 '08

re: PNG tEXt Chunk


Yes I am trying it in C#. I had tried basically what is on PngBitmapDecoder Class (System.Windows.Media.Imaging)

with like decoder.MetaData.Comment and such.

I tried opening the .png file with FileStream and StreamReader however it isn't reading the file fully when I convert it back to string so I am unsure how I should search the data for 'tEXtcomment'. I wish C# had png chunk methods :-\
RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,393
#4: Dec 30 '08

re: PNG tEXt Chunk


I don't understand what you are trying to do. You are trying to decode a PNG file into a BMP file then output it as a string?
Member
 
Join Date: Mar 2008
Posts: 90
#5: Dec 30 '08

re: PNG tEXt Chunk


No what I am trying to do is take a PunkBuster screenshot which has information at the bottom of the screen which is also encoded in the tEXt chunk of the png file and grab that info. If I open the .png file with a text editor I can see in plain text the information I need in the tEXt Chunk. I see there is a plugin for Delphi which you just specify which chunk you want and it will grab the info without having to walk the file. I am looking for a fast and easy way to get the tEXt chunk of the png file.

Yesterday I tried walking the file and it did not turn out exactly the way I wanted it too.

Here is an example of the first couple lines of the png file in a text editor.
Attached Thumbnails
textpng.png  
RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,393
#6: Dec 30 '08

re: PNG tEXt Chunk


That image is too small. If the plugin from Delphi works then why not use that?
Reply