protected /*<name>*/CGBitmapInfo/*</name>*/ wrap(long value, long mask) { return new /*<name>*/CGBitmapInfo/*</name>*/(value, mask); } protected /*<name>*/CGBitmapInfo/*</name>*/[] _values() {
/** * @since Available in iOS 4.0 and later. */ public CVPixelFormatDescription setCGBitmapInfo(CGBitmapInfo cGBitmapInfo) { set(Keys.CGBitmapInfo(), CFNumber.valueOf(cGBitmapInfo.value())); return this; } /**
/** * @since Available in iOS 2.0 and later. */ public static CGBitmapContext create(long width, long height, long bitsPerComponent, long bytesPerRow, CGColorSpace space, CGImageAlphaInfo alphaInfo) { return create((IntPtr)null, width, height, bitsPerComponent, bytesPerRow, space, new CGBitmapInfo(alphaInfo.value())); } /**
/** * @since Available in iOS 4.0 and later. */ public CVPixelFormatDescription setCGBitmapInfo(CGBitmapInfo cGBitmapInfo) { set(Keys.CGBitmapInfo(), CFNumber.valueOf(cGBitmapInfo.value())); return this; } /**
/** * @since Available in iOS 2.0 and later. */ public static CGBitmapContext create(byte[] data, long width, long height, long bitsPerComponent, long bytesPerRow, CGColorSpace space, CGImageAlphaInfo alphaInfo) { BytePtr ptr = new BytePtr(); ptr.set(data); return create(ptr.as(IntPtr.class), width, height, bitsPerComponent, bytesPerRow, space, new CGBitmapInfo(alphaInfo.value())); } /**
/** * @since Available in iOS 4.0 and later. */ public CVPixelFormatDescription setCGBitmapInfo(CGBitmapInfo cGBitmapInfo) { set(Keys.CGBitmapInfo(), CFNumber.valueOf(cGBitmapInfo.value())); return this; } /**
/** * @since Available in iOS 4.0 and later. */ public CGBitmapInfo getCGBitmapInfo() { if (has(Keys.CGBitmapInfo())) { CFNumber val = get(Keys.CGBitmapInfo(), CFNumber.class); return new CGBitmapInfo(val.longValue()); } return null; } /**
protected /*<name>*/CGBitmapInfo/*</name>*/ wrap(long value, long mask) { return new /*<name>*/CGBitmapInfo/*</name>*/(value, mask); } protected /*<name>*/CGBitmapInfo/*</name>*/[] _values() {
protected /*<name>*/CGBitmapInfo/*</name>*/ wrap(long value, long mask) { return new /*<name>*/CGBitmapInfo/*</name>*/(value, mask); } protected /*<name>*/CGBitmapInfo/*</name>*/[] _values() {
static CGBitmapContext createCGBitmap(int width, int height) { return CGBitmapContext.create(width, height, 8, 4 * width, colorSpace, new CGBitmapInfo( CGImageAlphaInfo.PremultipliedLast.value())); }
/** * @since Available in iOS 2.0 and later. */ public static CGBitmapContext create(long width, long height, long bitsPerComponent, long bytesPerRow, CGColorSpace space, CGImageAlphaInfo alphaInfo) { return create((IntPtr)null, width, height, bitsPerComponent, bytesPerRow, space, new CGBitmapInfo(alphaInfo.value())); } /**
/** * @since Available in iOS 2.0 and later. */ public static CGBitmapContext create(long width, long height, long bitsPerComponent, long bytesPerRow, CGColorSpace space, CGImageAlphaInfo alphaInfo) { return create((IntPtr)null, width, height, bitsPerComponent, bytesPerRow, space, new CGBitmapInfo(alphaInfo.value())); } /**
static CGBitmapContext createCGBitmap(int width, int height) { return CGBitmapContext.create(width, height, 8, 4 * width, colorSpace, new CGBitmapInfo( CGImageAlphaInfo.PremultipliedLast.value())); }
/** * @since Available in iOS 4.0 and later. */ public CGBitmapInfo getCGBitmapInfo() { if (has(Keys.CGBitmapInfo())) { CFNumber val = get(Keys.CGBitmapInfo(), CFNumber.class); return new CGBitmapInfo(val.longValue()); } return null; } /**
/** * @since Available in iOS 2.0 and later. */ public static CGBitmapContext create(byte[] data, long width, long height, long bitsPerComponent, long bytesPerRow, CGColorSpace space, CGImageAlphaInfo alphaInfo) { BytePtr ptr = new BytePtr(); ptr.set(data); return create(ptr.as(IntPtr.class), width, height, bitsPerComponent, bytesPerRow, space, new CGBitmapInfo(alphaInfo.value())); } /**
/** * @since Available in iOS 4.0 and later. */ public CGBitmapInfo getCGBitmapInfo() { if (has(Keys.CGBitmapInfo())) { CFNumber val = get(Keys.CGBitmapInfo(), CFNumber.class); return new CGBitmapInfo(val.longValue()); } return null; } /**
/** * @since Available in iOS 2.0 and later. */ public static CGBitmapContext create(byte[] data, long width, long height, long bitsPerComponent, long bytesPerRow, CGColorSpace space, CGImageAlphaInfo alphaInfo) { BytePtr ptr = new BytePtr(); ptr.set(data); return create(ptr.as(IntPtr.class), width, height, bitsPerComponent, bytesPerRow, space, new CGBitmapInfo(alphaInfo.value())); } /**
@Override public void getRgb(int startX, int startY, int width, int height, int[] rgbArray, int offset, int scanSize) { 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--; // } // } }
@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--; // } // } }