public CIContextOptions setOutputColorSpace(CGColorSpace outputColorSpace) { set(Keys.OutputColorSpace(), outputColorSpace.as(NSObject.class)); return this; } public CGColorSpace getWorkingColorSpace() {
public static CGColorSpace createCalibratedGray(float[] whitePoint, float[] blackPoint, double gamma) { if (whitePoint == null) { throw new NullPointerException("whitePoint"); } if (blackPoint == null) { throw new NullPointerException("blackPoint"); } if (whitePoint.length != 3) { throw new IllegalArgumentException("whitePoint.length != 3 (" + whitePoint.length + ")"); } if (blackPoint.length != 3) { throw new IllegalArgumentException("blackPoint.length != 3 (" + blackPoint.length + ")"); } return createCalibratedGray( VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(whitePoint)), VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(blackPoint)), gamma); }
throw new IllegalArgumentException("matrix.length != 9 (" + matrix.length + ")"); return createCalibratedRGB( VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(whitePoint)), VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(blackPoint)),
public byte[] getColorTable() { long len = getColorTableCount(); if (len == 0) { throw new IllegalStateException("Not an indexed color space"); } byte[] table = new byte[(int) len]; getColorTable(VM.getArrayValuesAddress(table)); return table; }
public static CGColorSpace createIndexed(CGColorSpace baseSpace, long lastIndex, byte[] colorTable) { if (baseSpace == null) { throw new NullPointerException("baseSpace"); } if (colorTable == null) { throw new NullPointerException("colorTable"); } long m = baseSpace.getNumberOfComponents(); if (colorTable.length != m * (lastIndex + 1)) { throw new IllegalArgumentException("colorTable.length != " + (m * (lastIndex + 1)) + " (" + colorTable.length + ")"); } return createIndexed(baseSpace, lastIndex, VM.getArrayValuesAddress(colorTable)); }
private static CGColor create(CGColorSpace space, Object components, int componentsLength) { if (space == null) { throw new NullPointerException("space == null"); } if (components == null) { throw new NullPointerException("components == null"); } if (componentsLength != space.getNumberOfComponents() + 1) { throw new IllegalArgumentException("components.length != space.numberOfComponents + 1"); } return create(space, VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(components))); }
public static CGColorSpace createICCBased(long nComponents, double[] range, CGDataProvider profile, CGColorSpace alternate) { if (range == null) { throw new NullPointerException("range"); } if (range.length != nComponents * 2) { throw new IllegalArgumentException("range.length != " + nComponents * 2 + " (" + range.length + ")"); } return createICCBased(nComponents, VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(range)), profile, alternate); }
public static CGColorSpace createLab(float[] whitePoint, float[] blackPoint, float[] range) { if (whitePoint == null) { throw new NullPointerException("whitePoint"); } if (blackPoint == null) { throw new NullPointerException("blackPoint"); } if (range == null) { throw new NullPointerException("range"); } if (whitePoint.length != 3) { throw new IllegalArgumentException("whitePoint.length != 3 (" + whitePoint.length + ")"); } if (blackPoint.length != 3) { throw new IllegalArgumentException("blackPoint.length != 3 (" + blackPoint.length + ")"); } if (range.length != 4) { throw new IllegalArgumentException("range.length != 4 (" + range.length + ")"); } return createLab( VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(whitePoint)), VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(blackPoint)), VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(range))); }
@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--; // } // } }
public byte[] getColorTable() { long len = getColorTableCount(); if (len == 0) { throw new IllegalStateException("Not an indexed color space"); } byte[] table = new byte[(int) len]; getColorTable(VM.getArrayValuesAddress(table)); return table; }
public static CGColorSpace createIndexed(CGColorSpace baseSpace, long lastIndex, byte[] colorTable) { if (baseSpace == null) { throw new NullPointerException("baseSpace"); } if (colorTable == null) { throw new NullPointerException("colorTable"); } long m = baseSpace.getNumberOfComponents(); if (colorTable.length != m * (lastIndex + 1)) { throw new IllegalArgumentException("colorTable.length != " + (m * (lastIndex + 1)) + " (" + colorTable.length + ")"); } return createIndexed(baseSpace, lastIndex, VM.getArrayValuesAddress(colorTable)); }
private static CGColor create(CGColorSpace space, CGPattern pattern, Object components, int componentsLength) { if (space == null) { throw new NullPointerException("space == null"); } if (components == null) { throw new NullPointerException("components == null"); } if (componentsLength != space.getNumberOfComponents() + 1) { throw new IllegalArgumentException("components.length != space.numberOfComponents + 1"); } return create(space, pattern, VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(components))); }
public static CGColorSpace createICCBased(long nComponents, float[] range, CGDataProvider profile, CGColorSpace alternate) { if (range == null) { throw new NullPointerException("range"); } if (range.length != nComponents * 2) { throw new IllegalArgumentException("range.length != " + nComponents * 2 + " (" + range.length + ")"); } return createICCBased(nComponents, VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(range)), profile, alternate); }
public static CGColorSpace createLab(double[] whitePoint, double[] blackPoint, double[] range) { if (whitePoint == null) { throw new NullPointerException("whitePoint"); } if (blackPoint == null) { throw new NullPointerException("blackPoint"); } if (range == null) { throw new NullPointerException("range"); } if (whitePoint.length != 3) { throw new IllegalArgumentException("whitePoint.length != 3 (" + whitePoint.length + ")"); } if (blackPoint.length != 3) { throw new IllegalArgumentException("blackPoint.length != 3 (" + blackPoint.length + ")"); } if (range.length != 4) { throw new IllegalArgumentException("range.length != 4 (" + range.length + ")"); } return createLab( VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(whitePoint)), VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(blackPoint)), VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(range))); }
@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--; // } // } }
public byte[] getColorTable() { long len = getColorTableCount(); if (len == 0) { throw new IllegalStateException("Not an indexed color space"); } byte[] table = new byte[(int) len]; getColorTable(VM.getArrayValuesAddress(table)); return table; }
public static CGColorSpace createIndexed(CGColorSpace baseSpace, long lastIndex, byte[] colorTable) { if (baseSpace == null) { throw new NullPointerException("baseSpace"); } if (colorTable == null) { throw new NullPointerException("colorTable"); } long m = baseSpace.getNumberOfComponents(); if (colorTable.length != m * (lastIndex + 1)) { throw new IllegalArgumentException("colorTable.length != " + (m * (lastIndex + 1)) + " (" + colorTable.length + ")"); } return createIndexed(baseSpace, lastIndex, VM.getArrayValuesAddress(colorTable)); }
public CIContextOptions setWorkingColorSpace(CGColorSpace workingColorSpace) { set(Keys.WorkingColorSpace(), workingColorSpace.as(NSObject.class)); return this; } /**
private static CGColor create(CGColorSpace space, CGPattern pattern, Object components, int componentsLength) { if (space == null) { throw new NullPointerException("space == null"); } if (components == null) { throw new NullPointerException("components == null"); } if (componentsLength != space.getNumberOfComponents() + 1) { throw new IllegalArgumentException("components.length != space.numberOfComponents + 1"); } return create(space, pattern, VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(components))); }
public static CGColorSpace createICCBased(long nComponents, float[] range, CGDataProvider profile, CGColorSpace alternate) { if (range == null) { throw new NullPointerException("range"); } if (range.length != nComponents * 2) { throw new IllegalArgumentException("range.length != " + nComponents * 2 + " (" + range.length + ")"); } return createICCBased(nComponents, VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(range)), profile, alternate); }