Solved

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

Posted on 2013-11-01
5
816 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
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.
The goal of the tutorial is to teach the user how to use the cropping tool and to straighten there photos so it does not look tilted. You will choose which photo you want to edit, crop it to you liking and make it straight.
The goal of the tutorial is to teach the user how to import photos into Adobe Lightroom efficiently and to keep everything organized.

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now