Skip to main content

[JAVA2D] Raster.createChild usage problem

1 reply [Last post]
Anonymous

Hello all. I am using the Raster.createChild(int parentX, int parentY, int
width, int height, int childMinX, int childMinY, int bandList[]) method to
return a one-pixel child raster that is just the lower-right corner of its
parent. I am encountering errors with this because parentX (coord of
rightmost pixel) plus width (one) is outside the bounds of the parent
raster. A RasterFormatException is thrown in this case. I feel that
creating this one-pixel child raster should be legal. Am I using this
method wrong?

Thanks,
Meghan

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

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

A Raster has (x,y) coordinates which satisfy

x in [raster.getMinX(), raster.getMinX() + raster.getWidth())
y in [raster.getMinY(), raster.getMinY() + raster.getHeight())

where "[" is inclusive and ")" is exclusive.

To obtain a child consisting of the bottom right pixel you should do the
equivalent of this:

raster.createChild(raster.getMinX() + raster.getWidth() - 1,
raster.getMinY() + raster.getHeight() - 1,
1, 1,
childMinX, childMinY, bandList);

The resulting child will have its minX and minY at (childMinX, childMinY) and
will have the specified band content.

I hope this is what you were asking.

Brian

> Hello all. I am using the Raster.createChild(int parentX, int parentY, int
> width, int height, int childMinX, int childMinY, int bandList[]) method to
> return a one-pixel child raster that is just the lower-right corner of its
> parent. I am encountering errors with this because parentX (coord of
> rightmost pixel) plus width (one) is outside the bounds of the parent
> raster. A RasterFormatException is thrown in this case. I feel that
> creating this one-pixel child raster should be legal. Am I using this
> method wrong?

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

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".