Results 1 to 1 of 1
- 02-13-2009, 07:29 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 5
- Rep Power
- 0
java.lang.ArrayIndexOutOfBoundsException
hi
I am trying to convert byte array into int[] pixels to get ImagePixels to set in
BufferedImage.setRGB(0, 0, fWidth, fHeight, pixels, 0, fWidth);
using :
public int[] getPixelsFromImage(String imageBuffer) {
byte[] b = null;
System.out.println("Length of ImageBufStr "+imageBuffer.length());
b = imageBuffer.getBytes();
System.out.println("length of Byte Array ::"+b.length);
if (b.length > Integer.MAX_VALUE) {
System.out.println(" Value is too large");
}
int[] pixels = new int[b.length/4];
int i, j;
System.out.println(b[0] + "/" + b[1] + "/" + b[2] + "/" + b[3]);
for(i=0, j =0; i < b.length; i=i+4, j++) {
pixels[j] = (b[i] << 24) + ((b[i+1] & 0xFF) << 16)
+ ((b[i+2] & 0xFF) << 8) + (b[i+3] & 0xFF);
}
return pixels;
}
This happens in a loop.
And I get java.lang.ArrayIndexOutOfBoundsException
Please suggest some solution.
Thanks
Similar Threads
-
java.lang.ArrayIndexOutOfBoundsException
By mensa in forum Java 2DReplies: 7Last Post: 05-05-2008, 09:09 AM -
java.lang.ArrayIndexOutOfBoundsException
By riccian in forum New To JavaReplies: 0Last Post: 03-18-2008, 09:38 AM -
java.lang.ArrayIndexOutOfBoundsException
By mew in forum New To JavaReplies: 2Last Post: 12-02-2007, 09:40 PM -
Error: java.lang.ArrayIndexOutOfBoundsException
By fernando in forum Java 2DReplies: 1Last Post: 07-31-2007, 11:47 PM -
java.lang.ArrayIndexOutOfBoundsException
By Marcus in forum New To JavaReplies: 1Last Post: 07-05-2007, 05:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks