Skip to main content

Re: Re: [JAI] problems drawing on to a buffered image

8 replies [Last post]
Anonymous

Hi

Thanks for the advice - I'll give it a go. Your suggestion about using getAsBufferedImage with a Rectangle and ColorModel might help me wiyth my next issue. I am trying to get a red line drawn on the initial PlanarImage which was a 1 bit image, black and white. SO everything I draw on it with the Graphics2D object, it comes out in black.

I have been going around in circles trying to increase the depth of the initial image with SampleModel and ColorModel but not getting anywhere. How can I do this ?

I am wondering whether there are any documents at the "conceptual level" about the components of JAI. I find that when I need to start using classes in an area that I haven't explored before, it is difficult to know where to start. If there is such a thing, that would really help me.

Thanks

Chris

>
> From: Brian Burkhalter
> Date: 2005/05/05 Thu PM 03:57:52 GMT
> To: Java Advanced Imaging discussion list ,
> christopher.faulkner@ntlworld.com
> Subject: Re: [JAI] problems drawing on to a buffered image
>
> Chris,
>
> Per the documentation here
>
> http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/PlanarImage.html#getAsBufferedImage(java.awt.Rectangle,%20java.awt.image.ColorModel)
>
> the BufferedImage is a *copy* of the PlanarImage. I think there are two good
> options for what you want to do:
>
> 1) Save the BufferedImage "bi" instead.
> 2) Create a TiledImage using this constructor
>
> http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/TiledImage.html#TiledImage(java.awt.image.RenderedImage,
> boolean)
>
> as
>
> TiledImage ti = new TiledImage(img, true);
>
> and replace the 'bi' in your code with 'ti'. The second parameter of the
> constructor causes 'img' to be overwritten so you may save either 'img' or
> 'ti'.
>
> Brian
>
> On Thu, 5 May 2005 christopher.faulkner@ntlworld.com wrote:
>
> > Hello all
> >
> > I have been using JAI for a while now and am successfully using it to crop / scale and tile maps together, mainly from TIFFs.
> >
> > I would now like to draw some lines and text on top of it. I followed a tutorial I found on the JAI website.
> >
> > Basically, the code goes like this.
> >
> > img is a PlanarImage
> >
> >
> > BufferedImage bi = img.getAsBufferedImage();
> > Graphics2D big = bi.createGraphics();
> >
> > big.setColor(Color.BLACK);
> > float dash1[] = {10.0f};
> > BasicStroke bs = new BasicStroke(5.0f, BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
> > big.setStroke(bs);
> > Line2D line = new Line2D.Float(20.0f, 10.0f, 1000.0f, 1000.0f);
> > big.draw(line);
> >
> > big.drawString("BufferedImage", 4, 12);
> > big.drawLine(202,202,202,2000);
> >
> > So I am taking the img, creating a BufferedImage and then a Graphics2D object into which I draw some lines and text.
> >
> > When I encode the img as a JPEG, nothing appears, other than the input imagery which went into the initial PlanarImage.
> >
> > What am I missing ? Do I have to save the BufferedImage / Graphic2D contents back into the PlanarImage (img) and if so how ?
> >
> > Thanks
> >
> > Chris
> >
> > -----------------------------------------
> > Email sent from www.ntlworld.com
> > virus-checked using mcAfee(R) Software
> > visit www.ntlworld.com/security for more information
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > For additional commands, e-mail: interest-help@jai.dev.java.net
> >
> >
>
> ----------------
> Brian Burkhalter
> Advanced Development, Graphics and Media
> Software Chief Technology Office
> Sun Microsystems, Inc.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> This email message is for the sole use of the intended recipient(s)
> and may contain confidential and privileged information. Any
> unauthorized review, use, disclosure or distribution is prohibited.
> If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

-----------------------------------------
Email sent from www.ntlworld.com
virus-checked using McAfee(R) Software
visit www.ntlworld.com/security for more information

---------------------------------------------------------------------
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.
Aastha Bhardwaj

Hi Chris,

For RenderingHints, take a look at the Javadoc for the JAI class. It
contains many RenderingHints.Key definitions, including the one you are
looking for

JAI.KEY_IMAGE_LAYOUT

In order to find out which parameters are required for each operator,
the best place to look at is the Javadoc for the operation's descriptor
in the javax.media.jai.operator package. So in this case you would look
at the javax.media.jai.operator.FormatDescriptor class. Note that you
can also generate a Quick Operation Reference Guide for yourself using
the JAI code posted here:

http://archives.java.sun.com/cgi-bin/wa?A2=ind0305&L=jai-interest&D=0&I=...
http://archives.java.sun.com/cgi-bin/wa?A2=ind0305&L=jai-interest&D=0&I=...

For other JAI resources, please take a look at the JAI FAQ, which
contains links to some code samples, under the "Additional Code Samples"
heading.

http://java.sun.com/products/java-media/jai/forDevelopers/jaifaq.html

Searching the jai-interest archives and the java.net archives is also
very useful. There is also a somewhat outdated Programmer's Reference
available here:

http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-...

The source code to JAI demos is available from the "jai-demos" Java.net
project, and should be very useful in helping a beginner get started
with JAI.

Aastha

---------------------
Aastha Bhardwaj
Java Advanced Imaging
Sun Microsystems

> HI
>
> Thanks for the extra advice. I thought I would try to convert my
> original image that I am drawing onto (a PlanarImage called img).
> Following the instructions in your first paragraph, I am loading a
> simple 8 bit image to a PlanarImage called deepImage. Then I do this
>
> ImageLayout il = new ImageLayout(this.deepImage);
> RenderingHints rhints = new RenderingHints ( ?? ,
> il.getColorModel(this.deepImage));
>
> ParameterBlock pb = new ParameterBlock();
> pb.addSource(img);
> pb.add(rhints);
> this.img = JAI.create("format", pb );
>
> This doesn't work largely because I am guessing at the meaning of what
> you are trying to tell me ! My two main problems :
> 1. How do I create a named RenderingHint ? As far as I can tell from the
> specs, the first parameter has to be a RenderingHints.Key and not a
> String.
> 2. What are the parameters for the format operator ? How can you find
> out what parameters are required for each operator ?
>
> As another total guess, I spotted the ColorConvert operator.
>
> ColorSpace cs =
> this.deepImage.getColorModel().getColorSpace();
> ParameterBlock pb = new ParameterBlock();
> pb.addSource(img).add(cs);
> this.img = JAI.create("ColorConvert", pb );
>
>
> This didn't work either. This is quite frustrating. I don't know which
> documentation to turn to that can help point me in the right
> dicumentation. The APIs are OK if you know your way around the classes
> in the first place. I obviously don't !
>
> Chris
>
>
> -----Original Message-----
> From: Marc Boscher [mailto:marcb@digicharm.com]
> Sent: 06 May 2005 18:40
> To: interest@jai.dev.java.net
> Subject: RE: Re: [JAI] problems drawing on to a buffered image
>
>
> Hi Chris,
>
> To change the color model you can use the Format operator, giving it a
> different color model (by passing an ImageLayout object as a
> RenderingHint named "ImageLayout"). This will allow you to increase the
> color depth of your black and white image and then to draw your red
> line.
>
> For drawing, I have also sometimes used a separate drawing canvas and
> drawn both my original image and my graphics. So I create a new
> TiledImage, get the graphics2D object on it, then drawRenderedImage/draw
> line/text etc.
>
>
> Cheers,
> Marc
>
>
> -----Original Message-----
> From: christopher.faulkner@ntlworld.com
> [mailto:christopher.faulkner@ntlworld.com]
> Sent: May 5, 2005 4:23 PM
> To: interest@jai.dev.java.net
> Subject: Re: Re: [JAI] problems drawing on to a buffered image
>
> Hi
>
> Thanks for the advice - I'll give it a go. Your suggestion about using
> getAsBufferedImage with a Rectangle and ColorModel might help me wiyth
> my next issue. I am trying to get a red line drawn on the initial
> PlanarImage which was a 1 bit image, black and white. SO everything I
> draw on it with the Graphics2D object, it comes out in black.
>
> I have been going around in circles trying to increase the depth of the
> initial image with SampleModel and ColorModel but not getting anywhere.
> How can I do this ?
>
> I am wondering whether there are any documents at the "conceptual level"
> about the components of JAI. I find that when I need to start using
> classes in an area that I haven't explored before, it is difficult to
> know where to start. If there is such a thing, that would really help
> me.
>
> Thanks
>
> Chris
>
>
>
>>From: Brian Burkhalter
>>Date: 2005/05/05 Thu PM 03:57:52 GMT
>>To: Java Advanced Imaging discussion list ,
>
>
>> christopher.faulkner@ntlworld.com
>>Subject: Re: [JAI] problems drawing on to a buffered image
>>
>>Chris,
>>
>>Per the documentation here
>>
>>
>
> http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja
> vax/
> media/jai/PlanarImage.html#getAsBufferedImage(java.awt.Rectangle,%20java
> .awt
> .image.ColorModel)
>
>>the BufferedImage is a *copy* of the PlanarImage. I think there are
>>two
>
> good
>
>>options for what you want to do:
>>
>>1) Save the BufferedImage "bi" instead.
>>2) Create a TiledImage using this constructor
>>
>>
>
> http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja
> vax/
> media/jai/TiledImage.html#TiledImage(java.awt.image.RenderedImage,
>
>>boolean)
>>
>>as
>>
>>TiledImage ti = new TiledImage(img, true);
>>
>>and replace the 'bi' in your code with 'ti'. The second parameter of
>>the constructor causes 'img' to be overwritten so you may save either
>>'img' or 'ti'.
>>
>>Brian
>>
>>On Thu, 5 May 2005 christopher.faulkner@ntlworld.com wrote:
>>
>>
>>>Hello all
>>>
>>>I have been using JAI for a while now and am successfully using it
>>>to
>
> crop / scale and tile maps together, mainly from TIFFs.
>
>>>I would now like to draw some lines and text on top of it. I
>>>followed a
>
> tutorial I found on the JAI website.
>
>>>Basically, the code goes like this.
>>>
>>>img is a PlanarImage
>>>
>>>
>>>BufferedImage bi = img.getAsBufferedImage();
>>>Graphics2D big = bi.createGraphics();
>>>
>>>big.setColor(Color.BLACK);
>>>float dash1[] = {10.0f};
>>>BasicStroke bs = new BasicStroke(5.0f,
>
> BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
>
>>>big.setStroke(bs);
>>>Line2D line = new Line2D.Float(20.0f, 10.0f, 1000.0f, 1000.0f);
>>>big.draw(line);
>>>
>>>big.drawString("BufferedImage", 4, 12);
>>>big.drawLine(202,202,202,2000);
>>>
>>>So I am taking the img, creating a BufferedImage and then a
>>>Graphics2D
>
> object into which I draw some lines and text.
>
>>>When I encode the img as a JPEG, nothing appears, other than the
>>>input
>
> imagery which went into the initial PlanarImage.
>
>>>What am I missing ? Do I have to save the BufferedImage / Graphic2D
>
> contents back into the PlanarImage (img) and if so how ?
>
>>>Thanks
>>>
>>>Chris
>>>
>>>-----------------------------------------
>>>Email sent from www.ntlworld.com
>>>virus-checked using mcAfee(R) Software
>>>visit www.ntlworld.com/security for more information
>>>
>>>
>>>
>>>--------------------------------------------------------------------
>>>-
>>>To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
>>>For additional commands, e-mail: interest-help@jai.dev.java.net
>>>
>>>
>>
>>----------------
>>Brian Burkhalter
>>Advanced Development, Graphics and Media
>>Software Chief Technology Office
>>Sun Microsystems, Inc.
>>
>>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>This email message is for the sole use of the intended recipient(s)
>>and may contain confidential and privileged information. Any
>>unauthorized review, use, disclosure or distribution is prohibited. If
>
>
>>you are not the intended recipient, please contact the sender by reply
>
>
>>email and destroy all copies of the original message.
>>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>
>
> -----------------------------------------
> Email sent from www.ntlworld.com
> virus-checked using McAfee(R) Software
> visit www.ntlworld.com/security for more information
>
>
>
> ---------------------------------------------------------------------
> 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
>
>
>
>
> ---------------------------------------------------------------------
> 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

christopher.faulkner

Thanks to everyone who helped on this one - thanks for the sample code
and for your patience.

I went through this code and also the Programming in Java Advanced
Imaging
manual which I found below "Community - Books and Authors" (rather than
"Documentation" which is where I had mainly been looking).

Great news, I got to a situation where I could draw coloured text and
lines on
top of a source image with 1 bit per sample, adapting the sample code.
This
basically creates a TiledImage and then, traversing the tiles within,
draws the
image and data back in. I think I have a good handle on how this works.

Now the bad news. This all works except when I first apply the "crop"
operator
to the input image. My input image is 2500 by 2500 pixels and I only
want a part of that. So I open the source image, crop it and then use
the same
methods to create the TiledImage (based on the new smaller extents),
BufferedImage and so on. The TiledImage, drawing and tile- traversing
bits still
work because the output image has the annotation. Unfortunately, it does
not
have the input image in the correct place.

There is some sample code at http://oramap.homelinux.com/Test.zip if you
are interested.

# compile
javac Test.java

# run it WITHOUT the crop operator. Creates an image called
uncropped.tif.
java -cp . Test map.tif 512 512 N

# run it WITHOUT the crop operator. Creates an image called cropped.tif.
java -cp . Test map.tif 512 512 Y

map.tif is the input image
512 is the tile width
512 is the tile height
Y|N says whether to do the cropping.

If you apply the crop, then it crops the image at point 500,500 for 800
pixels
square. Now what seems to happen is this

- the image is cropped. If you report the width and height by using
getWidth
getHeight, you get the new sizes.
- when the image is drawn, it simply draws the image at it's original
size, with
the cropped areas blacked out. In the example I did with cropping, the
correct
area appears but the origin is at 500, 500 instead of 0 0. The crop
appears to
clip out the image correctly, it reports the new dimensions but does not
shift
the origin at the point at which I am drawing.

The commented workaround which fixes the problem is this (500 was my
crop
origin)

// TRANSFORM the image by the same point that you
// cropped and it works
AffineTransform atx = new AffineTransform();
//AffineTransform atx
//= AffineTransform.getTranslateInstance(-500,-500);

System.out.println("drawing image");
bsg.drawRenderedImage(img, atx);

I shouldn't have to shift the image though should I ? Because the
BufferedImage,
TiledImage were ultimately derived from the cropped image and not the
input one.
Seems like crop is not being done completely before I start drawing.

Is this a bug or a failing in my understanding ?

Cheers

Chris

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

Aastha Bhardwaj

Hi Chris,

Please note that after the "crop" operation, the (minX, minY) of the
image, that is it's upper left hand corner will lie at the upper left
hand corner of the crop rectangle that you specified. So if you started
the crop at (500, 500), the cropped image's upper left hand corner will
now be (500, 500). If you want the image's origin to be (0,0) then you
would need to translate it by (-500, -500). In short, crop just does the
cropping, it does not translate an image back to (0, 0)

Aastha

---------------------
Aastha Bhardwaj
Java Advanced Imaging
Sun Microsystems

> Thanks to everyone who helped on this one - thanks for the sample code
> and for your patience.
>
> I went through this code and also the Programming in Java Advanced
> Imaging
> manual which I found below "Community - Books and Authors" (rather than
> "Documentation" which is where I had mainly been looking).
>
> Great news, I got to a situation where I could draw coloured text and
> lines on
> top of a source image with 1 bit per sample, adapting the sample code.
> This
> basically creates a TiledImage and then, traversing the tiles within,
> draws the
> image and data back in. I think I have a good handle on how this works.
>
> Now the bad news. This all works except when I first apply the "crop"
> operator
> to the input image. My input image is 2500 by 2500 pixels and I only
> want a part of that. So I open the source image, crop it and then use
> the same
> methods to create the TiledImage (based on the new smaller extents),
> BufferedImage and so on. The TiledImage, drawing and tile- traversing
> bits still
> work because the output image has the annotation. Unfortunately, it does
> not
> have the input image in the correct place.
>
> There is some sample code at http://oramap.homelinux.com/Test.zip if you
> are interested.
>
> # compile
> javac Test.java
>
> # run it WITHOUT the crop operator. Creates an image called
> uncropped.tif.
> java -cp . Test map.tif 512 512 N
>
> # run it WITHOUT the crop operator. Creates an image called cropped.tif.
> java -cp . Test map.tif 512 512 Y
>
> map.tif is the input image
> 512 is the tile width
> 512 is the tile height
> Y|N says whether to do the cropping.
>
> If you apply the crop, then it crops the image at point 500,500 for 800
> pixels
> square. Now what seems to happen is this
>
> - the image is cropped. If you report the width and height by using
> getWidth
> getHeight, you get the new sizes.
> - when the image is drawn, it simply draws the image at it's original
> size, with
> the cropped areas blacked out. In the example I did with cropping, the
> correct
> area appears but the origin is at 500, 500 instead of 0 0. The crop
> appears to
> clip out the image correctly, it reports the new dimensions but does not
> shift
> the origin at the point at which I am drawing.
>
> The commented workaround which fixes the problem is this (500 was my
> crop
> origin)
>
> // TRANSFORM the image by the same point that you
> // cropped and it works
> AffineTransform atx = new AffineTransform();
> //AffineTransform atx
> //= AffineTransform.getTranslateInstance(-500,-500);
>
> System.out.println("drawing image");
> bsg.drawRenderedImage(img, atx);
>
> I shouldn't have to shift the image though should I ? Because the
> BufferedImage,
> TiledImage were ultimately derived from the cropped image and not the
> input one.
> Seems like crop is not being done completely before I start drawing.
>
> Is this a bug or a failing in my understanding ?
>
> Cheers
>
> Chris
>
>
>
> ---------------------------------------------------------------------
> 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

christopher.faulkner@ntlworld.com

Hi

Thanks for the advice but I am not sure about that. I have been uing crop for a while and I have never used translate to alter the origin. crop should crop the image. If you are saying that crop should simply black out pixels around the area of interest without resizing the image, then I think you are describing a mask operation and not a crop.

Chris

>
> From: Aastha Bhardwaj
> Date: 2005/06/02 Thu AM 01:14:55 GMT
> To: interest@jai.dev.java.net
> Subject: Re: [JAI] Drawing on Buffered Image - problem with crop
>
> Hi Chris,
>
> Please note that after the "crop" operation, the (minX, minY) of the
> image, that is it's upper left hand corner will lie at the upper left
> hand corner of the crop rectangle that you specified. So if you started
> the crop at (500, 500), the cropped image's upper left hand corner will
> now be (500, 500). If you want the image's origin to be (0,0) then you
> would need to translate it by (-500, -500). In short, crop just does the
> cropping, it does not translate an image back to (0, 0)
>
> Aastha
>
> ---------------------
> Aastha Bhardwaj
> Java Advanced Imaging
> Sun Microsystems
>
>
> > Thanks to everyone who helped on this one - thanks for the sample code
> > and for your patience.
> >
> > I went through this code and also the Programming in Java Advanced
> > Imaging
> > manual which I found below "Community - Books and Authors" (rather than
> > "Documentation" which is where I had mainly been looking).
> >
> > Great news, I got to a situation where I could draw coloured text and
> > lines on
> > top of a source image with 1 bit per sample, adapting the sample code.
> > This
> > basically creates a TiledImage and then, traversing the tiles within,
> > draws the
> > image and data back in. I think I have a good handle on how this works.
> >
> > Now the bad news. This all works except when I first apply the "crop"
> > operator
> > to the input image. My input image is 2500 by 2500 pixels and I only
> > want a part of that. So I open the source image, crop it and then use
> > the same
> > methods to create the TiledImage (based on the new smaller extents),
> > BufferedImage and so on. The TiledImage, drawing and tile- traversing
> > bits still
> > work because the output image has the annotation. Unfortunately, it does
> > not
> > have the input image in the correct place.
> >
> > There is some sample code at http://oramap.homelinux.com/Test.zip if you
> > are interested.
> >
> > # compile
> > javac Test.java
> >
> > # run it WITHOUT the crop operator. Creates an image called
> > uncropped.tif.
> > java -cp . Test map.tif 512 512 N
> >
> > # run it WITHOUT the crop operator. Creates an image called cropped.tif.
> > java -cp . Test map.tif 512 512 Y
> >
> > map.tif is the input image
> > 512 is the tile width
> > 512 is the tile height
> > Y|N says whether to do the cropping.
> >
> > If you apply the crop, then it crops the image at point 500,500 for 800
> > pixels
> > square. Now what seems to happen is this
> >
> > - the image is cropped. If you report the width and height by using
> > getWidth
> > getHeight, you get the new sizes.
> > - when the image is drawn, it simply draws the image at it's original
> > size, with
> > the cropped areas blacked out. In the example I did with cropping, the
> > correct
> > area appears but the origin is at 500, 500 instead of 0 0. The crop
> > appears to
> > clip out the image correctly, it reports the new dimensions but does not
> > shift
> > the origin at the point at which I am drawing.
> >
> > The commented workaround which fixes the problem is this (500 was my
> > crop
> > origin)
> >
> > // TRANSFORM the image by the same point that you
> > // cropped and it works
> > AffineTransform atx = new AffineTransform();
> > //AffineTransform atx
> > //= AffineTransform.getTranslateInstance(-500,-500);
> >
> > System.out.println("drawing image");
> > bsg.drawRenderedImage(img, atx);
> >
> > I shouldn't have to shift the image though should I ? Because the
> > BufferedImage,
> > TiledImage were ultimately derived from the cropped image and not the
> > input one.
> > Seems like crop is not being done completely before I start drawing.
> >
> > Is this a bug or a failing in my understanding ?
> >
> > Cheers
> >
> > Chris
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>

-----------------------------------------
Email provided by http://www.ntlhome.com/

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

Stéphane Wasserhardt

Hi !

The crop operation is really a crop operation, not a mask. But in JAI,
images have minX, minY, width and height properties, so that every images
are located on a common coordinate system. If you crop an image, its
coordinates (minX, minY, width, height) will be changed. That is to say minX
won't be the original image's minX but minX + x (where x is the "x"
parameter of the crop operation). Processing this way, JAI really crops the
image, but doesn't translate it to the origin of the original image.
Maybe you didn't notice this before because you cropped at (0,0) coordinates
or because you used a rendering process that begins drawing at (minX, minY)
instead of (0, 0) ...
Take a look at the image's properties after a crop operation, and you'll see
that Aastha was right.
You really need to translate the image with parameters "-x" and "-y" to get
what you want.

Stephane

-----Message d'origine-----
De : christopher.faulkner@ntlworld.com
[mailto:christopher.faulkner@ntlworld.com]
Envoyé : jeudi 2 juin 2005 12:46
À : interest@jai.dev.java.net
Objet : Re: Re: [JAI] Drawing on Buffered Image - problem with crop

Hi

Thanks for the advice but I am not sure about that. I have been uing crop
for a while and I have never used translate to alter the origin. crop should
crop the image. If you are saying that crop should simply black out pixels
around the area of interest without resizing the image, then I think you are
describing a mask operation and not a crop.

Chris

>
> From: Aastha Bhardwaj
> Date: 2005/06/02 Thu AM 01:14:55 GMT
> To: interest@jai.dev.java.net
> Subject: Re: [JAI] Drawing on Buffered Image - problem with crop
>
> Hi Chris,
>
> Please note that after the "crop" operation, the (minX, minY) of the
> image, that is it's upper left hand corner will lie at the upper left
> hand corner of the crop rectangle that you specified. So if you started
> the crop at (500, 500), the cropped image's upper left hand corner will
> now be (500, 500). If you want the image's origin to be (0,0) then you
> would need to translate it by (-500, -500). In short, crop just does the
> cropping, it does not translate an image back to (0, 0)
>
> Aastha
>
> ---------------------
> Aastha Bhardwaj
> Java Advanced Imaging
> Sun Microsystems
>
>
> > Thanks to everyone who helped on this one - thanks for the sample code
> > and for your patience.
> >
> > I went through this code and also the Programming in Java Advanced
> > Imaging
> > manual which I found below "Community - Books and Authors" (rather than
> > "Documentation" which is where I had mainly been looking).
> >
> > Great news, I got to a situation where I could draw coloured text and
> > lines on
> > top of a source image with 1 bit per sample, adapting the sample code.
> > This
> > basically creates a TiledImage and then, traversing the tiles within,
> > draws the
> > image and data back in. I think I have a good handle on how this works.
> >
> > Now the bad news. This all works except when I first apply the "crop"
> > operator
> > to the input image. My input image is 2500 by 2500 pixels and I only
> > want a part of that. So I open the source image, crop it and then use
> > the same
> > methods to create the TiledImage (based on the new smaller extents),
> > BufferedImage and so on. The TiledImage, drawing and tile- traversing
> > bits still
> > work because the output image has the annotation. Unfortunately, it does
> > not
> > have the input image in the correct place.
> >
> > There is some sample code at http://oramap.homelinux.com/Test.zip if you
> > are interested.
> >
> > # compile
> > javac Test.java
> >
> > # run it WITHOUT the crop operator. Creates an image called
> > uncropped.tif.
> > java -cp . Test map.tif 512 512 N
> >
> > # run it WITHOUT the crop operator. Creates an image called cropped.tif.
> > java -cp . Test map.tif 512 512 Y
> >
> > map.tif is the input image
> > 512 is the tile width
> > 512 is the tile height
> > Y|N says whether to do the cropping.
> >
> > If you apply the crop, then it crops the image at point 500,500 for 800
> > pixels
> > square. Now what seems to happen is this
> >
> > - the image is cropped. If you report the width and height by using
> > getWidth
> > getHeight, you get the new sizes.
> > - when the image is drawn, it simply draws the image at it's original
> > size, with
> > the cropped areas blacked out. In the example I did with cropping, the
> > correct
> > area appears but the origin is at 500, 500 instead of 0 0. The crop
> > appears to
> > clip out the image correctly, it reports the new dimensions but does not
> > shift
> > the origin at the point at which I am drawing.
> >
> > The commented workaround which fixes the problem is this (500 was my
> > crop
> > origin)
> >
> > // TRANSFORM the image by the same point that you
> > // cropped and it works
> > AffineTransform atx = new AffineTransform();
> > //AffineTransform atx
> > //= AffineTransform.getTranslateInstance(-500,-500);
> >
> > System.out.println("drawing image");
> > bsg.drawRenderedImage(img, atx);
> >
> > I shouldn't have to shift the image though should I ? Because the
> > BufferedImage,
> > TiledImage were ultimately derived from the cropped image and not the
> > input one.
> > Seems like crop is not being done completely before I start drawing.
> >
> > Is this a bug or a failing in my understanding ?
> >
> > Cheers
> >
> > Chris
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>

-----------------------------------------
Email provided by http://www.ntlhome.com/

---------------------------------------------------------------------
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

Marc Boscher

Hi Chris,

To change the color model you can use the Format operator, giving it a
different color model (by passing an ImageLayout object as a RenderingHint
named "ImageLayout"). This will allow you to increase the color depth of
your black and white image and then to draw your red line.

For drawing, I have also sometimes used a separate drawing canvas and drawn
both my original image and my graphics. So I create a new TiledImage, get
the graphics2D object on it, then drawRenderedImage/draw line/text etc.

Cheers,
Marc

-----Original Message-----
From: christopher.faulkner@ntlworld.com
[mailto:christopher.faulkner@ntlworld.com]
Sent: May 5, 2005 4:23 PM
To: interest@jai.dev.java.net
Subject: Re: Re: [JAI] problems drawing on to a buffered image

Hi

Thanks for the advice - I'll give it a go. Your suggestion about using
getAsBufferedImage with a Rectangle and ColorModel might help me wiyth my
next issue. I am trying to get a red line drawn on the initial PlanarImage
which was a 1 bit image, black and white. SO everything I draw on it with
the Graphics2D object, it comes out in black.

I have been going around in circles trying to increase the depth of the
initial image with SampleModel and ColorModel but not getting anywhere. How
can I do this ?

I am wondering whether there are any documents at the "conceptual level"
about the components of JAI. I find that when I need to start using classes
in an area that I haven't explored before, it is difficult to know where to
start. If there is such a thing, that would really help me.

Thanks

Chris

>
> From: Brian Burkhalter
> Date: 2005/05/05 Thu PM 03:57:52 GMT
> To: Java Advanced Imaging discussion list ,
> christopher.faulkner@ntlworld.com
> Subject: Re: [JAI] problems drawing on to a buffered image
>
> Chris,
>
> Per the documentation here
>
>
http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...
media/jai/PlanarImage.html#getAsBufferedImage(java.awt.Rectangle,%20java.awt
.image.ColorModel)
>
> the BufferedImage is a *copy* of the PlanarImage. I think there are two
good
> options for what you want to do:
>
> 1) Save the BufferedImage "bi" instead.
> 2) Create a TiledImage using this constructor
>
>
http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...
media/jai/TiledImage.html#TiledImage(java.awt.image.RenderedImage,
> boolean)
>
> as
>
> TiledImage ti = new TiledImage(img, true);
>
> and replace the 'bi' in your code with 'ti'. The second parameter of the
> constructor causes 'img' to be overwritten so you may save either 'img' or
> 'ti'.
>
> Brian
>
> On Thu, 5 May 2005 christopher.faulkner@ntlworld.com wrote:
>
> > Hello all
> >
> > I have been using JAI for a while now and am successfully using it to
crop / scale and tile maps together, mainly from TIFFs.
> >
> > I would now like to draw some lines and text on top of it. I followed a
tutorial I found on the JAI website.
> >
> > Basically, the code goes like this.
> >
> > img is a PlanarImage
> >
> >
> > BufferedImage bi = img.getAsBufferedImage();
> > Graphics2D big = bi.createGraphics();
> >
> > big.setColor(Color.BLACK);
> > float dash1[] = {10.0f};
> > BasicStroke bs = new BasicStroke(5.0f,
BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
> > big.setStroke(bs);
> > Line2D line = new Line2D.Float(20.0f, 10.0f, 1000.0f, 1000.0f);
> > big.draw(line);
> >
> > big.drawString("BufferedImage", 4, 12);
> > big.drawLine(202,202,202,2000);
> >
> > So I am taking the img, creating a BufferedImage and then a Graphics2D
object into which I draw some lines and text.
> >
> > When I encode the img as a JPEG, nothing appears, other than the input
imagery which went into the initial PlanarImage.
> >
> > What am I missing ? Do I have to save the BufferedImage / Graphic2D
contents back into the PlanarImage (img) and if so how ?
> >
> > Thanks
> >
> > Chris
> >
> > -----------------------------------------
> > Email sent from www.ntlworld.com
> > virus-checked using mcAfee(R) Software
> > visit www.ntlworld.com/security for more information
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > For additional commands, e-mail: interest-help@jai.dev.java.net
> >
> >
>
> ----------------
> Brian Burkhalter
> Advanced Development, Graphics and Media
> Software Chief Technology Office
> Sun Microsystems, Inc.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> This email message is for the sole use of the intended recipient(s)
> and may contain confidential and privileged information. Any
> unauthorized review, use, disclosure or distribution is prohibited.
> If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

-----------------------------------------
Email sent from www.ntlworld.com
virus-checked using McAfee(R) Software
visit www.ntlworld.com/security for more information

---------------------------------------------------------------------
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

christopher.faulkner

HI

Thanks for the extra advice. I thought I would try to convert my
original image that I am drawing onto (a PlanarImage called img).
Following the instructions in your first paragraph, I am loading a
simple 8 bit image to a PlanarImage called deepImage. Then I do this

ImageLayout il = new ImageLayout(this.deepImage);
RenderingHints rhints = new RenderingHints ( ?? ,
il.getColorModel(this.deepImage));

ParameterBlock pb = new ParameterBlock();
pb.addSource(img);
pb.add(rhints);
this.img = JAI.create("format", pb );

This doesn't work largely because I am guessing at the meaning of what
you are trying to tell me ! My two main problems :
1. How do I create a named RenderingHint ? As far as I can tell from the
specs, the first parameter has to be a RenderingHints.Key and not a
String.
2. What are the parameters for the format operator ? How can you find
out what parameters are required for each operator ?

As another total guess, I spotted the ColorConvert operator.

ColorSpace cs =
this.deepImage.getColorModel().getColorSpace();
ParameterBlock pb = new ParameterBlock();
pb.addSource(img).add(cs);
this.img = JAI.create("ColorConvert", pb );

This didn't work either. This is quite frustrating. I don't know which
documentation to turn to that can help point me in the right
dicumentation. The APIs are OK if you know your way around the classes
in the first place. I obviously don't !

Chris

-----Original Message-----
From: Marc Boscher [mailto:marcb@digicharm.com]
Sent: 06 May 2005 18:40
To: interest@jai.dev.java.net
Subject: RE: Re: [JAI] problems drawing on to a buffered image

Hi Chris,

To change the color model you can use the Format operator, giving it a
different color model (by passing an ImageLayout object as a
RenderingHint named "ImageLayout"). This will allow you to increase the
color depth of your black and white image and then to draw your red
line.

For drawing, I have also sometimes used a separate drawing canvas and
drawn both my original image and my graphics. So I create a new
TiledImage, get the graphics2D object on it, then drawRenderedImage/draw
line/text etc.

Cheers,
Marc

-----Original Message-----
From: christopher.faulkner@ntlworld.com
[mailto:christopher.faulkner@ntlworld.com]
Sent: May 5, 2005 4:23 PM
To: interest@jai.dev.java.net
Subject: Re: Re: [JAI] problems drawing on to a buffered image

Hi

Thanks for the advice - I'll give it a go. Your suggestion about using
getAsBufferedImage with a Rectangle and ColorModel might help me wiyth
my next issue. I am trying to get a red line drawn on the initial
PlanarImage which was a 1 bit image, black and white. SO everything I
draw on it with the Graphics2D object, it comes out in black.

I have been going around in circles trying to increase the depth of the
initial image with SampleModel and ColorModel but not getting anywhere.
How can I do this ?

I am wondering whether there are any documents at the "conceptual level"
about the components of JAI. I find that when I need to start using
classes in an area that I haven't explored before, it is difficult to
know where to start. If there is such a thing, that would really help
me.

Thanks

Chris

>
> From: Brian Burkhalter
> Date: 2005/05/05 Thu PM 03:57:52 GMT
> To: Java Advanced Imaging discussion list ,

> christopher.faulkner@ntlworld.com
> Subject: Re: [JAI] problems drawing on to a buffered image
>
> Chris,
>
> Per the documentation here
>
>
http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja
vax/
media/jai/PlanarImage.html#getAsBufferedImage(java.awt.Rectangle,%20java
.awt
.image.ColorModel)
>
> the BufferedImage is a *copy* of the PlanarImage. I think there are
> two
good
> options for what you want to do:
>
> 1) Save the BufferedImage "bi" instead.
> 2) Create a TiledImage using this constructor
>
>
http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja
vax/
media/jai/TiledImage.html#TiledImage(java.awt.image.RenderedImage,
> boolean)
>
> as
>
> TiledImage ti = new TiledImage(img, true);
>
> and replace the 'bi' in your code with 'ti'. The second parameter of
> the constructor causes 'img' to be overwritten so you may save either
> 'img' or 'ti'.
>
> Brian
>
> On Thu, 5 May 2005 christopher.faulkner@ntlworld.com wrote:
>
> > Hello all
> >
> > I have been using JAI for a while now and am successfully using it
> > to
crop / scale and tile maps together, mainly from TIFFs.
> >
> > I would now like to draw some lines and text on top of it. I
> > followed a
tutorial I found on the JAI website.
> >
> > Basically, the code goes like this.
> >
> > img is a PlanarImage
> >
> >
> > BufferedImage bi = img.getAsBufferedImage();
> > Graphics2D big = bi.createGraphics();
> >
> > big.setColor(Color.BLACK);
> > float dash1[] = {10.0f};
> > BasicStroke bs = new BasicStroke(5.0f,
BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
> > big.setStroke(bs);
> > Line2D line = new Line2D.Float(20.0f, 10.0f, 1000.0f, 1000.0f);
> > big.draw(line);
> >
> > big.drawString("BufferedImage", 4, 12);
> > big.drawLine(202,202,202,2000);
> >
> > So I am taking the img, creating a BufferedImage and then a
> > Graphics2D
object into which I draw some lines and text.
> >
> > When I encode the img as a JPEG, nothing appears, other than the
> > input
imagery which went into the initial PlanarImage.
> >
> > What am I missing ? Do I have to save the BufferedImage / Graphic2D
contents back into the PlanarImage (img) and if so how ?
> >
> > Thanks
> >
> > Chris
> >
> > -----------------------------------------
> > Email sent from www.ntlworld.com
> > virus-checked using mcAfee(R) Software
> > visit www.ntlworld.com/security for more information
> >
> >
> >
> > --------------------------------------------------------------------
> > -
> > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > For additional commands, e-mail: interest-help@jai.dev.java.net
> >
> >
>
> ----------------
> Brian Burkhalter
> Advanced Development, Graphics and Media
> Software Chief Technology Office
> Sun Microsystems, Inc.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> This email message is for the sole use of the intended recipient(s)
> and may contain confidential and privileged information. Any
> unauthorized review, use, disclosure or distribution is prohibited. If

> you are not the intended recipient, please contact the sender by reply

> email and destroy all copies of the original message.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

-----------------------------------------
Email sent from www.ntlworld.com
virus-checked using McAfee(R) Software
visit www.ntlworld.com/security for more information

---------------------------------------------------------------------
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

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

Marc Boscher

Chris,

Here is some sample code for the format op. I haven't run it in a long time,
but I think it should work.

// lut is a 3-dimension array of 16 elements. Ie a color palette
ColorModel cm = new IndexColorModel(4, 16, lut[0], lut[1], lut[2]);
ImageLayout il = new ImageLayout();
il.setColorModel(cm);
RenderingHints rh = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);
ParameterBlock pb = new ParameterBlock();
pb.addSource(raImg);
pb.add(reImg.getSampleModel().getDataType());
RenderedImage ri = JAI.create("Format", pb, rh);

I feel you pain as I struggled quite a lot to figure this out in the first
place. I was also confused with various other operators (such as
ColorConvert) that seemed to do what I wanted.

I think that JAI is very powerful but it lacks some good basic documentation
on what is the best way to do various basic things.

Marc Boscher
System Architect
Communications Digicharm Inc.
(514) 448-4475

-----Original Message-----
From: christopher.faulkner [mailto:christopher.faulkner@ntlworld.com]
Sent: May 8, 2005 10:38 AM
To: interest@jai.dev.java.net
Subject: RE: Re: [JAI] problems drawing on to a buffered image

HI

Thanks for the extra advice. I thought I would try to convert my
original image that I am drawing onto (a PlanarImage called img).
Following the instructions in your first paragraph, I am loading a
simple 8 bit image to a PlanarImage called deepImage. Then I do this

ImageLayout il = new ImageLayout(this.deepImage);
RenderingHints rhints = new RenderingHints ( ?? ,
il.getColorModel(this.deepImage));

ParameterBlock pb = new ParameterBlock();
pb.addSource(img);
pb.add(rhints);
this.img = JAI.create("format", pb );

This doesn't work largely because I am guessing at the meaning of what
you are trying to tell me ! My two main problems :
1. How do I create a named RenderingHint ? As far as I can tell from the
specs, the first parameter has to be a RenderingHints.Key and not a
String.
2. What are the parameters for the format operator ? How can you find
out what parameters are required for each operator ?

As another total guess, I spotted the ColorConvert operator.

ColorSpace cs =
this.deepImage.getColorModel().getColorSpace();
ParameterBlock pb = new ParameterBlock();
pb.addSource(img).add(cs);
this.img = JAI.create("ColorConvert", pb );

This didn't work either. This is quite frustrating. I don't know which
documentation to turn to that can help point me in the right
dicumentation. The APIs are OK if you know your way around the classes
in the first place. I obviously don't !

Chris

-----Original Message-----
From: Marc Boscher [mailto:marcb@digicharm.com]
Sent: 06 May 2005 18:40
To: interest@jai.dev.java.net
Subject: RE: Re: [JAI] problems drawing on to a buffered image

Hi Chris,

To change the color model you can use the Format operator, giving it a
different color model (by passing an ImageLayout object as a
RenderingHint named "ImageLayout"). This will allow you to increase the
color depth of your black and white image and then to draw your red
line.

For drawing, I have also sometimes used a separate drawing canvas and
drawn both my original image and my graphics. So I create a new
TiledImage, get the graphics2D object on it, then drawRenderedImage/draw
line/text etc.

Cheers,
Marc

-----Original Message-----
From: christopher.faulkner@ntlworld.com
[mailto:christopher.faulkner@ntlworld.com]
Sent: May 5, 2005 4:23 PM
To: interest@jai.dev.java.net
Subject: Re: Re: [JAI] problems drawing on to a buffered image

Hi

Thanks for the advice - I'll give it a go. Your suggestion about using
getAsBufferedImage with a Rectangle and ColorModel might help me wiyth
my next issue. I am trying to get a red line drawn on the initial
PlanarImage which was a 1 bit image, black and white. SO everything I
draw on it with the Graphics2D object, it comes out in black.

I have been going around in circles trying to increase the depth of the
initial image with SampleModel and ColorModel but not getting anywhere.
How can I do this ?

I am wondering whether there are any documents at the "conceptual level"
about the components of JAI. I find that when I need to start using
classes in an area that I haven't explored before, it is difficult to
know where to start. If there is such a thing, that would really help
me.

Thanks

Chris

>
> From: Brian Burkhalter
> Date: 2005/05/05 Thu PM 03:57:52 GMT
> To: Java Advanced Imaging discussion list ,

> christopher.faulkner@ntlworld.com
> Subject: Re: [JAI] problems drawing on to a buffered image
>
> Chris,
>
> Per the documentation here
>
>
http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja
vax/
media/jai/PlanarImage.html#getAsBufferedImage(java.awt.Rectangle,%20java
.awt
.image.ColorModel)
>
> the BufferedImage is a *copy* of the PlanarImage. I think there are
> two
good
> options for what you want to do:
>
> 1) Save the BufferedImage "bi" instead.
> 2) Create a TiledImage using this constructor
>
>
http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja
vax/
media/jai/TiledImage.html#TiledImage(java.awt.image.RenderedImage,
> boolean)
>
> as
>
> TiledImage ti = new TiledImage(img, true);
>
> and replace the 'bi' in your code with 'ti'. The second parameter of
> the constructor causes 'img' to be overwritten so you may save either
> 'img' or 'ti'.
>
> Brian
>
> On Thu, 5 May 2005 christopher.faulkner@ntlworld.com wrote:
>
> > Hello all
> >
> > I have been using JAI for a while now and am successfully using it
> > to
crop / scale and tile maps together, mainly from TIFFs.
> >
> > I would now like to draw some lines and text on top of it. I
> > followed a
tutorial I found on the JAI website.
> >
> > Basically, the code goes like this.
> >
> > img is a PlanarImage
> >
> >
> > BufferedImage bi = img.getAsBufferedImage();
> > Graphics2D big = bi.createGraphics();
> >
> > big.setColor(Color.BLACK);
> > float dash1[] = {10.0f};
> > BasicStroke bs = new BasicStroke(5.0f,
BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
> > big.setStroke(bs);
> > Line2D line = new Line2D.Float(20.0f, 10.0f, 1000.0f, 1000.0f);
> > big.draw(line);
> >
> > big.drawString("BufferedImage", 4, 12);
> > big.drawLine(202,202,202,2000);
> >
> > So I am taking the img, creating a BufferedImage and then a
> > Graphics2D
object into which I draw some lines and text.
> >
> > When I encode the img as a JPEG, nothing appears, other than the
> > input
imagery which went into the initial PlanarImage.
> >
> > What am I missing ? Do I have to save the BufferedImage / Graphic2D
contents back into the PlanarImage (img) and if so how ?
> >
> > Thanks
> >
> > Chris
> >
> > -----------------------------------------
> > Email sent from www.ntlworld.com
> > virus-checked using mcAfee(R) Software
> > visit www.ntlworld.com/security for more information
> >
> >
> >
> > --------------------------------------------------------------------
> > -
> > To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> > For additional commands, e-mail: interest-help@jai.dev.java.net
> >
> >
>
> ----------------
> Brian Burkhalter
> Advanced Development, Graphics and Media
> Software Chief Technology Office
> Sun Microsystems, Inc.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> This email message is for the sole use of the intended recipient(s)
> and may contain confidential and privileged information. Any
> unauthorized review, use, disclosure or distribution is prohibited. If

> you are not the intended recipient, please contact the sender by reply

> email and destroy all copies of the original message.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

-----------------------------------------
Email sent from www.ntlworld.com
virus-checked using McAfee(R) Software
visit www.ntlworld.com/security for more information

---------------------------------------------------------------------
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

---------------------------------------------------------------------
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