Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Crash in ImageData.blit() when trying to resize Display window(ArrayOutOfBounds Exception)
Crash in ImageData.blit() when trying to resize Display window [message #1478607] Tue, 18 November 2014 20:43
Kristy Welsh is currently offline Kristy WelshFriend
Messages: 1
Registered: November 2014
Junior Member
I've reversed engineered the jar file from AndroidProjector (@code.google.com). I am trying to modify AndroidProjector to accomodate different screen sizes and I am running into problems with org.eclipse.swt.graphics.ImageData.blit() - ArrayOutOfBoundsException.

The project also uses this file RawImage.java as part of the solution.

My Android Projector call:

Quote:
private void getFramebufferHeader(SocketChannel paramSocketChannel)
throws IOException
{
ByteBuffer localByteBuffer = ByteBuffer.wrap(new byte[4]);
readAdbChannel(paramSocketChannel, localByteBuffer);
localByteBuffer.rewind();
localByteBuffer.order(ByteOrder.LITTLE_ENDIAN);
int i = localByteBuffer.getInt();
int j = RawImage.getHeaderSize(i);
localByteBuffer = ByteBuffer.wrap(new byte[j * 4]);
readAdbChannel(paramSocketChannel, localByteBuffer);
localByteBuffer.rewind();
localByteBuffer.order(ByteOrder.LITTLE_ENDIAN);
this.mRawImage = new RawImage();
this.mRawImage.readHeader(i, localByteBuffer,percentSize);
}

ArrayOutOfBounds Exception Here:

Quote:
private void updateDeviceImage(Shell paramShell, RawImage paramRawImage)
{
PaletteData localPaletteData = new PaletteData(paramRawImage.getRedMask(), paramRawImage.getGreenMask(), paramRawImage.getBlueMask());
//paramRawImage.getRedMask() = -16777216
//paramRawImage.getRedMask() = 16711680
//paramRawImage.getBlueMask() = 65289
ImageData localImageData = null;
//ArrayOutOfBounds Exception Here////////////////
//paramRawImage.width = 800
//paramRawImage.height = 1280
//paramRawImage.bpp = 32
//
localImageData = new ImageData(paramRawImage.width, paramRawImage.height, paramRawImage.bpp, localPaletteData, 1, paramRawImage.data);
Image localImage = new Image(paramShell.getDisplay(), localImageData);
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/////////////////////////////////////////
this.mImageLabel.setImage(localImage);
this.mImageLabel.pack();
paramShell.pack();
}



My modified RawData method call (the outofbounds exception occurs when percentSize is less than 100):

Quote:
public boolean readHeader(int version, ByteBuffer buf, int percentSize) {
this.version = version;

if (version == 16) {
// compatibility mode with original protocol
this.bpp = 16;

// read actual values.
this.size = buf.getInt() * percentSize/100;
this.width = buf.getInt() * percentSize/100;
this.height = buf.getInt() * percentSize/100;


// create default values for the rest. Format is 565
this.red_offset = 11 * percentSize/100;
this.red_length = 5 * percentSize/100;
this.green_offset = 5 * percentSize/100;
this.green_length = 6 * percentSize/100;
this.blue_offset = 0 ;
this.blue_length = 5 * percentSize/100;
this.alpha_offset = 0;
this.alpha_length = 0;
} else if (version == 1) {
this.bpp = buf.getInt();
this.size = buf.getInt() * percentSize/100;
this.width = buf.getInt() * percentSize/100;
this.height = buf.getInt() * percentSize/100;
if (percentSize < 100) {
this.red_offset = 11;
this.red_length = 5;
this.green_offset = 5;
this.green_length = 6;
this.blue_offset = buf.getInt() ;
this.blue_length = 5;
this.alpha_offset = buf.getInt();
this.alpha_length = buf.getInt();
} else {
this.red_offset = buf.getInt() ;
this.red_length = buf.getInt();
this.blue_offset = buf.getInt();
this.blue_length = buf.getInt();
this.green_offset = buf.getInt();
this.green_length = buf.getInt();
this.alpha_offset = buf.getInt();
this.alpha_length = buf.getInt();
}
/*

*/
} else {
// unsupported protocol!
return false;
}

return true;
}



Here is my exception:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 16390
at org.eclipse.swt.graphics.ImageData.blit(Unknown Source)
at org.eclipse.swt.graphics.Image.init(Unknown Source)
at org.eclipse.swt.graphics.Image.init(Unknown Source)
at org.eclipse.swt.graphics.Image.<init>(Unknown Source)
at com.google.android.AndroidProjector.updateDeviceImage(AndroidProjector.java:262)
at com.google.android.AndroidProjector.open(AndroidProjector.java:56)
at com.google.android.AndroidProjector.main(AndroidProjector.java:273)
Previous Topic:drag image from windows explorer to canvas / table field
Next Topic:Composite.print works on GC display but doesn't work on GC printer
Goto Forum:
  


Current Time: Fri Apr 26 12:28:24 GMT 2024

Powered by FUDForum. Page generated in 0.03083 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top