PNGEncoder on zOS-system fails

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Manfred
Posts: 4
Joined: Tue Sep 16, 2003 3:01 pm

PNGEncoder on zOS-system fails

Post by Manfred » Tue Sep 16, 2003 3:26 pm

Hello

I am using JFreeChart with IBM WebSphere Application Server 4.0 on Windows and on zOS-platform. JDK 1.3

On Windows everything is allright, JPEG and PNG are correct encoded.

When I save the chart as PNG on zOS-system, the file is not valid and cannot be read, but there is no exception. When saving as JPEG, everything is okay.

I see, the PNGEncoder works with byte-arrays. Is it possible a convertion-problem from ASCII to EBCDIC ?

Have anyone experience of PNG encoding on zOS or OS390 ?

Thanks for any help

psoares
Posts: 12
Joined: Sun May 18, 2003 12:24 pm
Location: Lisbon, Portugal

Post by psoares » Wed Sep 17, 2003 6:52 pm

This is a similar problem I had in iText with OS390 and AS400.
Replace in PngEncoder.java all the .getBytes() with .getBytes("ISO-8859-1"). Some exception catching will be needed.

Best Regards,
Paulo Soares

Manfred
Posts: 4
Joined: Tue Sep 16, 2003 3:01 pm

PNGEncoder on zOS-system fails

Post by Manfred » Fri Sep 19, 2003 9:49 am

Hi Paulo!

Thanks for your help! Now the PNG-file is generated wonderful!

Manfred

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Sep 19, 2003 9:56 am

Hi Manfred,

Does the patched encoder work on all platforms? If it does, and the performance hasn't been affected too much, I'd be interested in updating it in the distribution...
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

mhilpert
Posts: 497
Joined: Wed Apr 02, 2003 1:57 pm
Location: Germany

Post by mhilpert » Fri Sep 19, 2003 10:02 am

but please don't set a fixed encoding like

.getBytes("ISO-8859-1")

but offer a configurable encoding:


DEFAULT_ENCODING = "ISO-8859-1";
...
setEndcoding(String encoding);
...
.getBytes(encoding)
Java 11, JFreeChart 1.0.15, JFreeSVG 4.0

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Sep 19, 2003 11:08 am

I'm not so sure it needs to be configurable. Looking at the PngEncoder source code, plus the PNG spec, it looks like the Strings ('IHDR', 'IDAT' and 'IEND') ought to be converted to bytes using the ISO-8859-1 encoding, not any other encoding:

http://www.w3.org/TR/PNG#Chunk-layout

Someone correct me if I'm wrong (I haven't studied the PNG spec before).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

psoares
Posts: 12
Joined: Sun May 18, 2003 12:24 pm
Location: Lisbon, Portugal

Post by psoares » Fri Sep 19, 2003 11:16 am

No encoding is needed as writeString() is only used to output the chunk tags, all that is need is some byte constants. I'll send you today a fixed PngEncoder.

Best Regards,
Paulo Soares

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Sep 19, 2003 1:56 pm

Hi Paulo,

Thanks for helping to sort this one out! I have committed your changes to CVS ready for the 0.9.13 release next week.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

arnaud
Posts: 86
Joined: Wed Mar 19, 2003 2:59 pm
Location: Paris, France
Contact:

Post by arnaud » Mon Sep 22, 2003 8:25 pm

Hello,

Btw, I had submitted some time ago an RFE to be able to save chart in high resolution and was in the need to modify the PNGEncoder to specify the dpi resolution of the image.

The changed file can be found at this RFE : [ 777515 ] High resolution images saving.

Btw, I forwarded the changes to the author of PNGEncoder, J. David Eisenberg, who answered me :
Thanks; glad you liked the package. I'm not doing much work with it,
since Sun is now shipping a library that does similar things.
So wel'll perhaps need to consider to change the package for the future...

Best regards,
Arnaud

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Sep 23, 2003 2:30 pm

Hi Arnaud,

Thanks. I think I finally understand what that RFE is about. Do other image file formats allow you to specify the DPI or is that specific to PNG?

I'm going to retain the PngEncoder class for a while, since I want JFreeChart to remain JDK 1.2.2 compatible for a while longer yet.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Manfred
Posts: 4
Joined: Tue Sep 16, 2003 3:01 pm

Post by Manfred » Thu Sep 25, 2003 12:26 pm

Hi David!

The PNG-Encoder with encoding "ISO-8859-1" are working correct on the windows and zOS platform. Performance is okay.

The next problem on zOS is the font. The SansSerif-font doesn't exist on zOS. So I must use the Lucida Sans Regular. Could you implement a method to set the default font for all Charts?

Example: In class ChartUtilities a static variable defaultFontName, a static setter and a getter-method. By default the default font is SansSerif and I can use ChartUtilities.setDefaultFontName("Lucida Sans Regular");

Look at these older postings:

http://www.jfree.org/phpBB2/viewtopic.p ... =sansserif

http://www.jfree.org/phpBB2/viewtopic.p ... =sansserif

Thanks, Manfred

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Sep 25, 2003 1:36 pm

Hi Manfred,

Paulo Soares has provided a patch for the PngEncoder that does away with the need for the encoding - it simply writes the correct byte values to the PNG file. This will be incorporated in the upcoming 0.9.13 release.

Regarding the default font, I will implement this when I get a chance...it's been added to the Feature Request Database (id=812410) so I don't forget about it.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked