On Thursday 20 December 2001 16:16, Thierry Kormann wrote:
>
> The following code is not really optimal as you encode the image in png and
> then decode it. Another way to implement that would be to subclass the
> ImageTranscoder such as (live code so might not work :):
>
> import org.apache.batik.transcoder.*;
> import org.apache.batik.transcoder.image.ImageTranscoder;
>
> public class Foo {
>
> public static Image transcodeSVGDocument( URL url, int x, int y ){
>
> // Create a custom transcoder.
MyImageTranscoder t = new MyImageTranscoder();
>
> // Set the transcoding hints.
> t.addTranscodingHint( PNGTranscoder.KEY_WIDTH, new Float(x) );
> t.addTranscodingHint( PNGTranscoder.KEY_HEIGHT, new Float(y) );
>
> // Create the transcoder input.
> TranscoderInput input = new TranscoderInput( url.toString() );
> t.transcode(input, null);
>
> return t.getBufferedImage();
> }
>
> static class MyImageTranscoder extends ImageTranscoder {
>
> protected BufferedImage img;
>
> public void writeImage(BufferedImage img, TranscoderOutput output)
> throws TranscoderException {
> this.img = img; // just store the image
> }
>
> public BufferedImage getBufferedImage() {
> return img;
> }
> }
> }
>
PS: Still live code :)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]