Can I get it B&W(1-bit color) PNG ?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Djonatah S.
Posts: 3
Joined: Wed Nov 26, 2008 9:06 pm

Can I get it B&W(1-bit color) PNG ?

Post by Djonatah S. » Wed Nov 26, 2008 9:12 pm

Hi,

I would like to create PNG B&W (1-bit color) is it possible?

Thanks
From Brazil :D

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Thu Nov 27, 2008 6:51 pm

Sure, assuming that you carefully tweak the chart's various paints to be TexturePaints with black-and-white images as textures.

If you use the default color configuration of a chart to render a black-and-white image you won't like the result.

Djonatah S.
Posts: 3
Joined: Wed Nov 26, 2008 9:06 pm

Post by Djonatah S. » Thu Nov 27, 2008 7:12 pm

Taqua, Thanks for the answer.

Actually I have already tried to convert images in another process (after creating images). About the textures I'll take care of them..

But, is there an option when saving images to save in 1-bit color? (Because I could not find on the API docs, neither on the web..)

Could you give me some help on that?

Thanks.
From Brazil :D

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Fri Nov 28, 2008 7:23 pm

You have to render the chart into a buffered-image. For that, create the image, grab the Graphics2D for the image and then call "JFreeChart#draw(..)" with the graphics2d and a rectangle that fits your image's size.

JFreeChart itself does not offer a helper method for that, and as this is standard Java2D-programming, there is no need for such a method either.

Djonatah S.
Posts: 3
Joined: Wed Nov 26, 2008 9:06 pm

Post by Djonatah S. » Tue Dec 02, 2008 1:46 pm

Hi Taqua,

I tried that, and it worked fine. Thanks for your help!
From Brazil :D

Locked