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 Petilon <pe...@yahoo.com> on 2002/10/06 00:34:50 UTC
How to rasterize SVG into a Java Image object?
I want to make a Java Image object out of an SVG file.
At first I thought org.apache.batik.transcoder.image.ImageTranscoder
would be able to do it. However, it turns out this is an abstract
class.
If I want to rasterize, I am forced to choose between JPEG, TIFF
and PNG. Why? Why can't Batik just give me an Image object and then
let me do whatever I want with it? That I will be able to leverage
my existing BMP output class (which takes a BufferedImage as input),
instead of writing my own subclass of ImageTranscoder.
Why doesn't Batik do this obvious thing? Or can it already render
into a BufferedImage?
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
RE: How to rasterize SVG into a Java Image object?
Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "P" == Petilon <pe...@yahoo.com> writes:
P> I want to make a Java Image object out of an SVG file. At first I
P> thought org.apache.batik.transcoder.image.ImageTranscoder would be
P> able to do it. However, it turns out this is an abstract class.
It is an abstract class that takes care of rasterizing an SVG to a
BufferedImage so you can stick in the few lines of code needed to
write it to the format you want (such as your BMP encoder).
P> If I want to rasterize, I am forced to choose between JPEG, TIFF
P> and PNG. Why? Why can't Batik just give me an Image object and then
P> let me do whatever I want with it? That I will be able to leverage
P> my existing BMP output class (which takes a BufferedImage as
P> input), instead of writing my own subclass of ImageTranscoder.
There are a number of reasons the simplest to explain is that SVG
is a scalable format (i.e. it has no strong notion of what size it
should be rendered at) a lot of what the ImageTranscoder baseclass
does is try and figure out a good mapping to pixels it also provides
hooks to adjust this output.
P> Why doesn't Batik do this obvious thing? Or can it already render
P> into a BufferedImage?
I don't understand why you are so offended that you need to write a
subclass to plug in your own output format, Java is an object oriented
language, this is entirely natural (it's not like the subclass is
particularly complex, take a look a the PNG encoder, it's about a page
of real code and it's one of the more complex outputs.
There are other routes to a BufferedImage as well, one is the
batik.gvt.StaticRenderer class, but then you need to figure out the
mapping from user space to device pixels.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org