use of org.robovm.apple.coregraphics.CGBitmapInfo in project playn by threerings.
the class RoboAbstractImage method getRgb.
@Override
public void getRgb(int startX, int startY, int width, int height, int[] rgbArray, int offset, int scanSize) {
if (width <= 0 || height <= 0)
return;
int bytesPerRow = 4 * width;
CGBitmapContext context = CGBitmapContext.create(width, height, 8, bytesPerRow, CGColorSpace.createDeviceRGB(), // PremultipliedFirst for ARGB, same as BufferedImage in Java.
new CGBitmapInfo(CGImageAlphaInfo.PremultipliedFirst.value()));
// since we're fishing for authentic RGB data, never allow interpolation.
context.setInterpolationQuality(CGInterpolationQuality.None);
draw(context, 0, 0, width, height, startX, startY, width, height);
// TODO: extract data from context.getData()
// int x = 0;
// int y = height - 1; // inverted Y
// for (int px = 0; px < regionBytes.length; px += 4) {
// int a = (int)regionBytes[px ] & 0xFF;
// int r = (int)regionBytes[px + 1] & 0xFF;
// int g = (int)regionBytes[px + 2] & 0xFF;
// int b = (int)regionBytes[px + 3] & 0xFF;
// rgbArray[offset + y * scanSize + x] = a << 24 | r << 16 | g << 8 | b;
// x++;
// if (x == width) {
// x = 0;
// y--;
// }
// }
}
Aggregations