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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to