In JDK1.4, you'll find that you will get the correct results.  We fixed
bug 4202347 -- Add bounds checking to all get/set methods for SampleModel/
Raster methods.

jeannette

> Delivered-To: [EMAIL PROTECTED]
> X-Priority: 3 (Normal)
> Mime-Version: 1.0
> Date: Wed, 28 Nov 2001 10:00:37 -0600
> From: Mike Robinson <[EMAIL PROTECTED]>
> Subject: Re: [JAVA2D] BufferedImage
> To: [EMAIL PROTECTED]
>
> Scott,
>
> When I run your code I get back the expected results. Here's the console
output.
>
> Bad
> Bad
> Good
> Bad
> Good
> Good
> Bad
> Good
> Good
>
> I am using jdk1.3 and, of course, substituted my own image.
>
> -Mike
>
> 11/28/01 7:40:31 AM, Scott Wong <[EMAIL PROTECTED]> wrote:
>
> >>> Now if C is >my central pixel (0,0), I should get back 3 Xs and C,
>>however if I run the code below, I get back the wrong
> answer.
> >>>
> >>> applyKernel(0,0);
> >>>
> >>> public void applyKernel(int x, int y) {
> >>>   for(int i=-1; i<2; i++) {
> >>>     for(int j=-1; j<2; j++) {
> >>>      try {
> >>>       aBufferedImage.getRGB(i + x, j + y);
> >>>       System.out.println("Good");
> >>>       }
> >>>      catch(ArrayIndexOutOfBoundsException e) {
> >>>        System.out.println("Bad");
> >>>        }
> >>>      }
> >>>    }
> >>>  }
> >
> >>Scott,
> >
> >>What answer do you get back?? Does the ArrayIndexOutOfBoundsException get
>thrown when you try to use getRGB with (-1,-
> 1)?
> >
> >>-Mike Robinson
> >
> >Nope, (-1, -1) works and I get back some pixel value when I should have
gotten back the printed statement "Bad"  :(
> >
> >===========================================================================
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> >of the message "signoff JAVA2D-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 JAVA2D-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 JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to