You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Rob Davis-5 <te...@robertjdavis.co.uk> on 2008/05/14 11:35:36 UTC
SOLVED-IT DOES WORK! Re: bilevel 1 bit per pixel PNG using
addTranscodingHint( PNGTranscoder.KEY_INDEXED, new Integer(1)) doesn't work
The problem was that I was using:
Color backgroundColor = new Color( 255, 255, 255, 0);
t.addTranscodingHint( ImageTranscoder.KEY_BACKGROUND_COLOR,
backgroundColor);
I fixed the problem by using:
t.addTranscodingHint(ImageTranscoder.KEY_BACKGROUND_COLOR, Color.white);
So the working code is as follows
(first, assume that a Rectangle2D instance aoi has been created to select
the area of interest)
PNGTranscoder t = new PNGTranscoder();
t.addTranscodingHint(ImageTranscoder.KEY_AOI, areaOfInterest);
float dpi = Float.valueOf(dpi);
double millimetresPerPixel = (25.4f / dpi);
t.addTranscodingHint(ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, new
Float(millimetresPerPixel));
t.addTranscodingHint(ImageTranscoder.KEY_BACKGROUND_COLOR, Color.white);
t.addTranscodingHint( PNGTranscoder.KEY_INDEXED, new Integer(1));
File aFile = new File(SVGFileInput);
String svgURI = aFile.toURI().toString();
TranscoderInput input = new TranscoderInput(svgURI);
OutputStream ostream = new FileOutputStream(BitmapOutput);
TranscoderOutput output = new TranscoderOutput(ostream);
t.transcode(input, output);
// Flush and close the stream.
ostream.flush();
ostream.close();
--
View this message in context: http://www.nabble.com/bilevel-1-bit-per-pixel-PNG-using-addTranscodingHint%28-PNGTranscoder.KEY_INDEXED%2C-new-Integer%281%29%29-doesn%27t-work-tp17211171p17227185.html
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: SOLVED-IT DOES WORK! Re: bilevel 1 bit per pixel PNG using
addTranscodingHint( PNGTranscoder.KEY_INDEXED, new Integer(1)) doesn't work
Posted by Rob Davis-5 <te...@robertjdavis.co.uk>.
Thanks for this. It's good to know that it is possible to render bitmaps
without anti-aliasing, with it turned off, disabled. I'm also aware of the
shape-rendering:crispEdges too used in the SVG itself.
But addTranscodingHint( PNGTranscoder.KEY_INDEXED, new Integer(1)) means
that the original SVG doesn't have to be adjusted
Just thought I'd add this reply with some more terms/synonyms that can help
others searching for the same solution.
--
View this message in context: http://www.nabble.com/bilevel-1-bit-per-pixel-PNG-using-addTranscodingHint%28-PNGTranscoder.KEY_INDEXED%2C-new-Integer%281%29%29-doesn%27t-work-tp17211171p17232088.html
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: SOLVED-IT DOES WORK! Re: bilevel 1 bit per pixel PNG using
addTranscodingHint( PNGTranscoder.KEY_INDEXED, new Integer(1)) doesn't
work
Posted by th...@kodak.com.
Hi Rob,
Rob Davis-5 <te...@robertjdavis.co.uk> wrote on 05/14/2008 05:35:36 AM:
> The problem was that I was using:
>
> Color backgroundColor = new Color( 255, 255, 255, 0);
If you didn't figure it out this is fully transparent white,
vs 'Color.white' which is opaque white.