[
https://issues.apache.org/jira/browse/BATIK-1106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15743396#comment-15743396
]
Jan Tošovský commented on BATIK-1106:
-------------------------------------
I've finally tracked down the cause: ColorSpace. Currently it is set to
CS_LINEAR_RGB. You can easily test the behavior using this snippet. It fails
with the same error message as originally reported. If the color space is
changed to ColorSpace.CS_sRGB, the conversion runs smoothly.
ColorModel linearRGBColorModel = new
DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), 32,
0xff0000, 0xff00, 0xff, 0xff000000, true, DataBuffer.TYPE_INT);
WritableRaster srcRaster =
linearRGBColorModel.createCompatibleWritableRaster(100, 100);
WritableRaster dstRaster =
linearRGBColorModel.createCompatibleWritableRaster(200, 200);
BufferedImage srcImage = new BufferedImage(linearRGBColorModel,
srcRaster, false, null);
BufferedImage dstImage = new BufferedImage(linearRGBColorModel,
dstRaster, false, null);
AffineTransform aff = new AffineTransform();
aff.scale(2.0, 2.0);
AffineTransformOp op = new AffineTransformOp(aff, null);
op.filter(srcImage, dstImage);
I've tried to override the ColorSpace in AffineRed.java by injecting the
following code:
ColorModel sRGBColorModel = new DirectColorModel(ColorSpace.getInstance
(ColorSpace.CS_sRGB), 32,
0xff0000, 0xff00, 0xff, 0xff000000, true,
DataBuffer.TYPE_INT);
WritableRaster srcRaster =
sRGBColorModel.createCompatibleWritableRaster(srcBI.getWidth(),
srcBI.getHeight());
WritableRaster myRaster =
sRGBColorModel.createCompatibleWritableRaster(myBI.getWidth(),
myBI.getHeight());
BufferedImage srcBIx = new BufferedImage(sRGBColorModel, srcRaster,
false, null);
BufferedImage myBIx = new BufferedImage(sRGBColorModel, myRaster,
false, null);
try {
ImageIO.write(srcBI, "PNG", new File("D:/srcBI.png"));
ImageIO.write(myBI, "PNG", new File("D:/myBI.png"));
ImageIO.write(srcBIx, "PNG", new File("D:/srcBIx.png"));
ImageIO.write(myBIx, "PNG", new File("D:/myBIx.png"));
} catch (IOException e) {
System.out.println(e.getMessage());
}
op.filter(srcBIx, myBIx);
It runs, but that blurred shadow disappear from the output :-(
> ImagingOpException when rasterizing simple SVG with filter into PDF
> -------------------------------------------------------------------
>
> Key: BATIK-1106
> URL: https://issues.apache.org/jira/browse/BATIK-1106
> Project: Batik
> Issue Type: Bug
> Components: SVG Rasterizer
> Affects Versions: trunk
> Environment: Win7, Oracle JDK 8
> Reporter: Jan Tošovský
> Attachments: line.png, line.svg
>
>
> While rasterizing simple SVG into PNG is fine, in case of PDF output I am
> getting the following error:
> java.awt.image.ImagingOpException: Unable to transform src image
> at java.awt.image.AffineTransformOp.filter(Unknown Source)
> at org.apache.batik.ext.awt.image.rendered.AffineRed.genRect(Unknown
> Source)
> at org.apache.batik.ext.awt.image.rendered.AffineRed.copyData(Unknown
> So
> urce)
> at org.apache.batik.ext.awt.image.rendered.PadRed.copyData(Unknown
> Sourc
> e)
> at
> org.apache.batik.ext.awt.image.rendered.CompositeRed.genRect(Unknown
> Source)
> at
> org.apache.batik.ext.awt.image.rendered.CompositeRed.copyData(Unknown
> Source)
> at
> org.apache.batik.ext.awt.image.rendered.Any2sRGBRed.copyData(Unknown
> Source)
> at
> org.apache.batik.ext.awt.image.rendered.AbstractRed.getData(Unknown S
> ource)
> at org.apache.batik.ext.awt.image.GraphicsUtil.drawImage(Unknown
> Source)
> at org.apache.batik.ext.awt.image.GraphicsUtil.drawImage(Unknown
> Source)
> at
> org.apache.batik.ext.awt.image.renderable.PadRable8Bit.paintRable(Unk
> nown Source)
> at org.apache.batik.ext.awt.image.GraphicsUtil.drawImage(Unknown
> Source)
> at
> org.apache.batik.ext.awt.image.renderable.PadRable8Bit.paintRable(Unk
> nown Source)
> at org.apache.batik.ext.awt.image.GraphicsUtil.drawImage(Unknown
> Source)
> at
> org.apache.batik.ext.awt.image.renderable.FilterChainRable8Bit.paintR
> able(Unknown Source)
> at org.apache.batik.ext.awt.image.GraphicsUtil.drawImage(Unknown
> Source)
> at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source)
> at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Unknown
> Sou
> rce)
> at org.apache.batik.gvt.CanvasGraphicsNode.primitivePaint(Unknown
> Source
> )
> at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source)
> at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Unknown
> Sou
> rce)
> at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source)
> at org.apache.fop.svg.PDFTranscoder.transcode(PDFTranscoder.java:183)
> at
> org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown S
> ource)
> at
> org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown S
> ource)
> at org.apache.batik.apps.rasterizer.SVGConverter.transcode(Unknown
> Sourc
> e)
> at org.apache.batik.apps.rasterizer.SVGConverter.execute(Unknown
> Source)
> at org.apache.batik.apps.rasterizer.Main.execute(Unknown Source)
> at org.apache.batik.apps.rasterizer.Main.main(Unknown Source)
> ... error (SVGConverter.error.while.rasterizing.file)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]