Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] ImageData / Image problem


noticed the following minor issue with Image.java in Carbon (others to?):

Image.getImageData() {
	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

	int width = OS.CGImageGetWidth(handle);
	int height = OS.CGImageGetHeight(handle);
	int bpr = OS.CGImageGetBytesPerRow(handle);
	int bpp = OS.CGImageGetBitsPerPixel(handle);	
	int dataSize = height * bpr;
	byte[] srcData = new byte[dataSize];
	OS.memmove(srcData, data, dataSize);
	
	PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
	ImageData data = new ImageData(width, height, bpp, palette);
	data.data = srcData;
....
}


new ImageData(width, height, bpp, palette) {
... ImageData(...)
.... setAllFields(
       .....
       data != null ? data : new byte[bytesPerLine * height],
       .....
      );
  }
}

Image buffer gets allocated twice for no reason.


--
Laurent Mihalkovic, co-author SWT/JFace in Action (www.manning.com/scarpino)



Back to the top