Solved

Add large data chunk in a .PNG image using C#

Posted on 2013-11-01
5
825 Views
Last Modified: 2013-11-17
Hi,

I need some opinion and tips. We are having a "drawing tool" that save to .png file but now we need to keep track of some vectorial data.

We get in the idea of adding a "data chunk" but we are note familiar with the format itself. We found that Adobe fireworks seem to do that kind of trick. Defining our own file format get things more complicated and lot less user firendly, the file cannot be emailed and need to "teach" file format differences.


- Do you find this an acceptable solution?
- Any tips or c# library that can help to add and reread our data insinde the png
- Any chunk size limitation?

Thanks
0
Comment
Question by:TelDig
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:hjgode
ID: 39619093
I would not go with a new format. You may either select one of the compound graphic file formats, like EPS, or, what I prefer, save the vector data in a separate file with the same name.
To save the vector data, you need to keep an array of drawing commands and then 'translate' these commands to svg, eps or similar drawing file.
If you can translate the drawing to eps (postscript) you may also use a pdf file for export/import, see the iTextSharp library.
0
 

Author Comment

by:TelDig
ID: 39622541
The issues here is that we must keep a flat image format (ex: png or jpeg)
0
 
LVL 16

Expert Comment

by:hjgode
ID: 39623394
You cannot use a bitmap file to store vector data. So either you go with two files (most comaptible) or hybrid file format (pdf) or possibly add your drawing data at the end of the png/jpg file. I do not know, what happens with apps, when they open a file with added file data at end of normal file.
0
 

Accepted Solution

by:
TelDig earned 0 total points
ID: 39642497
The PNG file format have been designed such way.

You can add additionnal data chunk that will be invisible to other applications. (they call that Ancillary chunks) Some are defined but you can create your custom/private chunk. whey will be ingnored from decoder

We have performed a small prototype using this library : https://code.google.com/p/pngcs/

- It worked well. even with an extra 20MB of "junk"
- Lots of tool that compress/shrik png file will strip all those chunk to keep only the image
- We assume that good chance a user that open the file in an editor will will remove our data but it's what we prefer anyway.
0
 

Author Closing Comment

by:TelDig
ID: 39654326
My question / My answer
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this Micro Tutorial viewers will learn the basic shortcuts and functions in InDesign.
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question