Thanks, Ballard for the help. I received an email from Uma pointing out the
byReference option in ImageComponent2D (available only in java3D 1.2). It
looks like that will speed up my programs image editing. As far as modifying
the image,

BufferedImage = ImageComponent2D.getImage()
Graphics = BufferedImage.getGraphics()
Graphics.fillRect() //etc
ImageComponent2D = new ImageComponent2D( BufferedImage, ... )

is working for me. I don't think I need the extra editing power your code
sample offers. But thank you, it has helped me understand Rasters and Tiles
better.

Raffi

-----Original Message-----
From: ballard andrews [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 09, 2000 4:56 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Graphic operations on texture images


Raffi,

To modify the image you have to get the raster.

    BufferedImage tmpImage = this.origImage.getAsBufferedImage();
    int numBands = tmpImage.getRaster().getNumBands();
    WritableRaster tile = tmpImage.getWritableTile(0, 0);
    for (int b = 0; b < numBands; b++)
     for (int y = 0; y < tile.getHeight(); y++)
      for (int x = 0; x < tile.getWidth(); x++)
        tile.setSample(x, y, b, somevalue);

    tmpImage.setData(tile);

Then pass the BufferedImage to the ImageComponent2D constructor:

ImageComponent2D image = new ImageComponent2D(image.FORMAT_WHATEVER,
                                tmpImage.getWidth(), tmpImage.getWidth());
image.set(tmpImage);

If you need more functionality use the Java Advanced Imaging API (JAI)
which has itterators (+ whole a lot more).

-ba

Uma Sabada wrote:
>
> Raffi:
>
> Java3D currently does not provide a mechanism to do a partial update of
texture
> images.  Using ImageComponent with the flag byReference and yUp is one way
of
> achieving what you want.  Using byReference enables you to change a part
of the
> image on the application side.  The advantage of using byReference and yUp
is
> that there is a possibility that internally Java3D will not make a copy of
the
> texture and is therefore faster.  Currently on PCs, Java3D will not make a
copy
> of texture image for the following combinations of BufferedImage format
and
> ImageComponent format(ofcourse, byReference and Yup should both be set to
true)
> :
>
> BufferedImage format                    ImageComponentFormat
> ----------------------                  ----------------------
> BufferedImage.TYPE_3BYTE_BGR            ImageComponent.FORMAT_RGB8 or
>                                         ImageComponent.FORMAT_RGB
>
> BufferedImage.TYPE_CUSTOM               ImageComponent.FORMAT_RGB8 or
> of form 3BYTE_RGB                       ImageComponent.FORMAT_RGB
>
> BufferedImage.TYPE_CUSTOM               ImageComponent.FORMAT_RGBA8 or
> of form 4BYTE_RGBA                      ImageComponent.FORMAT_RGBA
>
> BufferedImage.TYPE_BYTE_GRAY            ImageComponent.FORMAT_CHANNEL8
>
> On Solaris, the  combinations below will not make a Java3D copy:
>
> BufferedImage format                    ImageComponentFormat
> ----------------------                  ----------------------
> BufferedImage.TYPE_4BYTE_ABGR           ImageComponent.FORMAT_RGBA8 or
>                                         ImageComponent.FORMAT_RGBA
>
> BufferedImage.TYPE_CUSTOM               ImageComponent.FORMAT_RGB8 or
> of form 3BYTE_RGB                       ImageComponent.FORMAT_RGB
>
> BufferedImage.TYPE_CUSTOM               ImageComponent.FORMAT_RGBA8 or
> of form 4BYTE_RGBA                      ImageComponent.FORMAT_RGBA
>
> BufferedImage.TYPE_BYTE_GRAY            ImageComponent.FORMAT_CHANNEL8
>
> Note that an image associated with a live scene graph cannot be changed.
So,
> you need to first make the image unlive, change the image and set the
image
> back in the texture.
>
> For more info on byReference, please check the javadoc on ImageComponent.
>
> -Uma
> Java3D Team
>
> ------------- Begin Forwarded Message -------------
>
> MIME-Version: 1.0
> Date: Wed, 7 Jun 2000 12:19:34 -0400
> From: "Kasparian, Raffi J." <[EMAIL PROTECTED]>
> Subject: Re: [JAVA3D] Graphic operations on texture images
> To: [EMAIL PROTECTED]
>
> Judging by the lack of response, either my question was unclear or no one
> knows how to quickly edit the image used by a Texture2D.
>
> Dear Sun programmers,
>
> I need to paint dynamically on the surface of a sphere to create animation
> effects. This operation is fairly fundamental to my project. Conceptually,
I
> would like to twiddle with some of the pixels stored in the image without
> having to go through the time consuming process of creating an entirely
new
> ImageComponent2D and sticking it back into the Texture2D. My only other
> alternative has been to create Shape3D's that tightly hug the surface of
the
> sphere thereby simulating (to an extent) the painting I would like to do.
> This is ridiculously expensive in terms of the computer's memory and
runtime
> speed not to mention my own programming time. In short, it's not an
> acceptable alternative either.
>
> Does anyone have any solutions? If so, please help me out; if not, is this
a
> limitation of openGL? or Java3D? are there plans to implement something
like
> this?
>
> Thanks,
>
> -----Original Message-----
> From: Kasparian, Raffi J. [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 02, 2000 11:17 AM
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D] Graphic operations on texture images
>
> I would like to dynamically and quickly edit the image in a texture that
is
> applied to an object. The only way I figured out to do this is very slow.
(4
> seconds on my machine)
>
> Here's what I'm doing:
>
> draw what I want into a BufferedImage;//this is quick
> //the following instructions are slow
> ImageComponent2d.set( BufferedImage );
> Texture2D.setImage( ImageComponent2d );
> Appearance.setTexture( Texture2D );
>
> It seems that there should be a way more efficient way to edit the image
> since all I want is to change the color of some pixels. Does anyone know
of
> a better method?
>
> Thanks,
>
> Raffi
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
> ------------- End Forwarded Message -------------
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

--
Dr. A. Ballard Andrews
Senior Research Scientist
Schlumberger Doll Research
Old Quarry Road Ridgefield, CT 06877
tel: 203-431-5522 fax: 5521

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to