Skip to main content

[JAI] Writing DisplayJAI's to file.

3 replies [Last post]
Anonymous

Hello,

I have a PlanarImage object which is converted to a DisplayJAI type
object (Actually a DisplayJAIWithAnnotations object -
https://jaistuff.dev.java.net/) in order for additional information to
be drawn on top of the image. This is fine when I want to display the
image using a JFrame on my local machine. The problem I have is that the
final image needs to be displayed using JSP's. I can save the original
PlanarImage on the server side as a jpeg and stream the jpeg to the jsp
but this means I lose the additional information.

Is there a way of saving DisplayJAI objects as jpegs (I'm guessing
probably not as the DisplayJAI class is an extension of JPanel), or is
there another route I can go down to draw on-top of a PlanarImage which
can then be saved as a jpeg?

Thanks,

Christina

--
Christina Cunningham
Belfast eScience Centre (BeSC)
Queen's University, Belfast
e: mailto:christina.cunningham@qub.ac.uk
w: www.qub.ac.uk/escience
t: +44 (0)28 9097 4809

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Rafael Santos

Christina,

DisplayJAIWithAnnotations inherits from DisplayJAI which inherits from
JComponent and Component. Please check the example
data.CreateImageFromComponent (it is on https://jaistuff.dev.java.net/
too) for a crude example on how to save a component to an image.

hope it helps
Rafael

> I have a PlanarImage object which is converted to a DisplayJAI type
> object (Actually a DisplayJAIWithAnnotations object -
> https://jaistuff.dev.java.net/) in order for additional information to
> be drawn on top of the image. This is fine when I want to display the
> image using a JFrame on my local machine. The problem I have is that
> the final image needs to be displayed using JSP's. I can save the
> original PlanarImage on the server side as a jpeg and stream the jpeg
> to the jsp but this means I lose the additional information.
>
> Is there a way of saving DisplayJAI objects as jpegs (I'm guessing
> probably not as the DisplayJAI class is an extension of JPanel), or is
> there another route I can go down to draw on-top of a PlanarImage
> which can then be saved as a jpeg?

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Christina Cunningham

Hi,

Thanks for the suggestions. I managed to draw onto the PlanarImage by
creating a TiledImage and then using the createGraphics() method
highlighted by Mike.

Christina

Rafael Santos wrote:

> Christina,
>
> DisplayJAIWithAnnotations inherits from DisplayJAI which inherits from
> JComponent and Component. Please check the example
> data.CreateImageFromComponent (it is on https://jaistuff.dev.java.net/
> too) for a crude example on how to save a component to an image.
>
> hope it helps
> Rafael
>
>
>> I have a PlanarImage object which is converted to a DisplayJAI type
>> object (Actually a DisplayJAIWithAnnotations object -
>> https://jaistuff.dev.java.net/) in order for additional information
>> to be drawn on top of the image. This is fine when I want to display
>> the image using a JFrame on my local machine. The problem I have is
>> that the final image needs to be displayed using JSP's. I can save
>> the original PlanarImage on the server side as a jpeg and stream the
>> jpeg to the jsp but this means I lose the additional information.
>>
>> Is there a way of saving DisplayJAI objects as jpegs (I'm guessing
>> probably not as the DisplayJAI class is an extension of JPanel), or
>> is there another route I can go down to draw on-top of a PlanarImage
>> which can then be saved as a jpeg?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>

--
Christina Cunningham
Belfast eScience Centre (BeSC)
Queen's University, Belfast
e: mailto:christina.cunningham@qub.ac.uk
w: www.qub.ac.uk/escience
t: +44 (0)28 9097 4809

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Nidel, Mike

Christina,

Don't think of your PlanarImage being "converted" to a DisplayJAI.
Instead, the DisplayJAI is a view on top of the image.

If you want to draw your annotations onto the underlying image,
you'll probably want to get a hold of the Graphics2D object for
the image. Actually what you need to do in this case is either

1. Construct a TiledImage from your PlanarImage and call
TiledImage.createGraphics(). Then you can draw your annotations
on the TiledImage.

2. call PlanarImage.getAsBufferedImage() to get a BufferedImage.
Then you can draw on this BufferedImage using BufferedImage.createGraphics()
and proceeding as above. This will read the entire image into memory
at once so only do this if your image is not unmanageably large.

After you have drawn your graphics onto either the BufferedImage
or the TiledImage, you can pass either one into a normal means of
writing a RenderedImage to disk as a JPEG, using the JAI codec or
(probably preferable) the ImageIO JPEG plugin.

If this doesn't solve your problem please ask again.

Mike

> -----Original Message-----
> From: Christina Cunningham [mailto:christina.cunningham@qub.ac.uk]
> Sent: Wednesday, May 11, 2005 11:24 AM
> To: interest@jai.dev.java.net
> Subject: [JAI] Writing DisplayJAI's to file.
>
>
> Hello,
>
> I have a PlanarImage object which is converted to a DisplayJAI type
> object (Actually a DisplayJAIWithAnnotations object -
> https://jaistuff.dev.java.net/) in order for additional
> information to
> be drawn on top of the image. This is fine when I want to display the
> image using a JFrame on my local machine. The problem I have
> is that the
> final image needs to be displayed using JSP's. I can save the
> original
> PlanarImage on the server side as a jpeg and stream the jpeg
> to the jsp
> but this means I lose the additional information.
>
> Is there a way of saving DisplayJAI objects as jpegs (I'm guessing
> probably not as the DisplayJAI class is an extension of
> JPanel), or is
> there another route I can go down to draw on-top of a
> PlanarImage which
> can then be saved as a jpeg?
>
> Thanks,
>
> Christina
>
> --
> Christina Cunningham
> Belfast eScience Centre (BeSC)
> Queen's University, Belfast
> e: mailto:christina.cunningham@qub.ac.uk
> w: www.qub.ac.uk/escience
> t: +44 (0)28 9097 4809
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net