LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert PNG to 300pdi

Solved!
Go to solution

 

Hi,


I want
to export a graph's image to a 300pdi-png (printing). Here's what I do:

 

First I export the graph to a png with the standard LV-VI. I re-open the file, locate the IHDR-Header, shift the index by 17 (which is the end of the IHDR) and place the pHYs-Header (from a 300pdi-PNG created by Photoshop)in between the IHDR and the IDAT,  as required. (See Snipet; hope you don't mind the german captions ^^)

 

So far
so good, but the file gets corrupt after my modifications....guess I've done some mistakes here.


Greets,

Stoney

 

Message Edited by Stone-D on 03-24-2010 06:20 AM
0 Kudos
Message 1 of 8
(4,168 Views)

At the first, try to set "prepend array or string size? (T)" of the Write to Binary File primitive to false (its true by default), because this added 4 additional bytes at the beginning of the file and png header gets corrupted.

 

Andrey.

 

0 Kudos
Message 2 of 8
(4,141 Views)
Should it not be dpi instead of pdi
0 Kudos
Message 3 of 8
(4,139 Views)

muks wrote:
Should it not be dpi instead of pdi

 

Hmmm... "Per Dot Inch" also not so bad. But "ipd" - this will be definitoively totally wrong!

 

 

0 Kudos
Message 4 of 8
(4,137 Views)
Just wanted to confirm that it means the same irrespective what the name is.:smileywink:
0 Kudos
Message 5 of 8
(4,133 Views)

Andrey Dmitriev wrote:

muks wrote:
Should it not be dpi instead of pdi

 

Hmmm... "Per Dot Inch" also not so bad. But "ipd" - this will be definitoively totally wrong!

 

 


 

ups, my bad....

 

 


Andrey Dmitriev wrote:
At the first, try to set "prepend array or string size? (T)" of the Write to Binary File primitive to false (its true by default), because this added 4 additional bytes at the beginning of the file and png header gets corrupted.



Andrey. 

 

Thanks, but the file is still corrupt... 

 

0 Kudos
Message 6 of 8
(4,102 Views)

Stone-D wrote:

Thanks, but the file is still corrupt... 

 


Not sure if other parts of the header should be changed or not (may be some offsets values should be corrected).

 

You have three possibilities in general:

1. Check byte to byte that your new file still compliant with  RFC2083.

2. Use ImageMagick (something like "convert -units PixelsPerInch -density 300 inFile.png outFile.png")

3. Use  libpng (as dll - this can be hard if you haven't experience with using external code in LabVIEW)

 

Andrey.

 

Message 7 of 8
(4,086 Views)
Solution
Accepted by topic author Stone-D
omg, just found my error.............The string constant which contains the dpi-header wasn't set to hex... 
0 Kudos
Message 8 of 8
(4,079 Views)