/** * Converts a bi-level {@code MagickImage} to a {@code BufferedImage}, of * type {@code TYPE_BYTE_BINARY}. * * @param pImage the original {@code MagickImage} * @return a new {@code BufferedImage} * * @throws MagickException if an exception occurs during conversion * * @see BufferedImage */ private static BufferedImage bilevelToBuffered(MagickImage pImage) throws MagickException { // As there is no way to get the binary representation of the image, // convert to gray, and the create a binary image from it BufferedImage temp = grayToBuffered(pImage, false); BufferedImage image = new BufferedImage(temp.getWidth(), temp.getHeight(), BufferedImage.TYPE_BYTE_BINARY, CM_MONOCHROME); ImageUtil.drawOnto(image, temp); return image; }
/** * Creates a deep copy of the given image. The image will have the same * color model and raster type, but will not share image (pixel) data * with the input image. * * @param pImage the image to clone. * * @return a new {@code BufferedImage} * * @throws IllegalArgumentException if {@code pImage} is {@code null} */ public static BufferedImage createCopy(final BufferedImage pImage) { if (pImage == null) { throw new IllegalArgumentException("image == null"); } ColorModel cm = pImage.getColorModel(); BufferedImage img = new BufferedImage(cm, cm.createCompatibleWritableRaster(pImage.getWidth(), pImage.getHeight()), cm.isAlphaPremultiplied(), null); drawOnto(img, pImage); return img; }
public static BufferedImage filter(BufferedImageOp pOperation, BufferedImage pInput, BufferedImage pOutput) { if (!USE_MAGICK) { return null; } BufferedImage result = null; switch (getNativeOpIndex(pOperation.getClass())) { case RESAMPLE_OP: ResampleOp resample = (ResampleOp) pOperation; result = resampleMagick(pInput, resample.width, resample.height, resample.filterType); // NOTE: If output parameter is non-null, we have to return that // image, instead of result if (pOutput != null) { //pOutput.setData(result.getRaster()); // Fast, but less compatible // NOTE: For some reason, this is sometimes super-slow...? ImageUtil.drawOnto(pOutput, result); result = pOutput; } break; default: // Simply fall through, allowing acceleration to be added later break; } return result; }
drawOnto(image, pOriginal);
drawOnto(temp, pImage);
ImageUtil.drawOnto(output, result); result = output;
drawOnto(temp, scaled);
/** * Converts a bi-level {@code MagickImage} to a {@code BufferedImage}, of * type {@code TYPE_BYTE_BINARY}. * * @param pImage the original {@code MagickImage} * @return a new {@code BufferedImage} * * @throws MagickException if an exception occurs during conversion * * @see BufferedImage */ private static BufferedImage bilevelToBuffered(MagickImage pImage) throws MagickException { // As there is no way to get the binary representation of the image, // convert to gray, and the create a binary image from it BufferedImage temp = grayToBuffered(pImage, false); BufferedImage image = new BufferedImage(temp.getWidth(), temp.getHeight(), BufferedImage.TYPE_BYTE_BINARY, CM_MONOCHROME); ImageUtil.drawOnto(image, temp); return image; }
/** * Converts a bi-level {@code MagickImage} to a {@code BufferedImage}, of * type {@code TYPE_BYTE_BINARY}. * * @param pImage the original {@code MagickImage} * @return a new {@code BufferedImage} * * @throws MagickException if an exception occurs during conversion * * @see BufferedImage */ private static BufferedImage bilevelToBuffered(MagickImage pImage) throws MagickException { // As there is no way to get the binary representation of the image, // convert to gray, and the create a binary image from it BufferedImage temp = grayToBuffered(pImage, false); BufferedImage image = new BufferedImage(temp.getWidth(), temp.getHeight(), BufferedImage.TYPE_BYTE_BINARY, CM_MONOCHROME); ImageUtil.drawOnto(image, temp); return image; }
/** * Creates a copy of the given image. The image will have the same * colormodel and raster type, but will not share image (pixel) data. * * @param pImage the image to clone. * * @return a new {@code BufferedImage} * * @throws IllegalArgumentException if {@code pImage} is {@code null} */ public static BufferedImage createCopy(final BufferedImage pImage) { if (pImage == null) { throw new IllegalArgumentException("image == null"); } ColorModel cm = pImage.getColorModel(); BufferedImage img = new BufferedImage(cm, cm.createCompatibleWritableRaster(pImage.getWidth(), pImage.getHeight()), cm.isAlphaPremultiplied(), null); drawOnto(pImage, img); return img; }
/** * Creates a deep copy of the given image. The image will have the same * color model and raster type, but will not share image (pixel) data * with the input image. * * @param pImage the image to clone. * * @return a new {@code BufferedImage} * * @throws IllegalArgumentException if {@code pImage} is {@code null} */ public static BufferedImage createCopy(final BufferedImage pImage) { if (pImage == null) { throw new IllegalArgumentException("image == null"); } ColorModel cm = pImage.getColorModel(); BufferedImage img = new BufferedImage(cm, cm.createCompatibleWritableRaster(pImage.getWidth(), pImage.getHeight()), cm.isAlphaPremultiplied(), null); drawOnto(img, pImage); return img; }
public static BufferedImage filter(BufferedImageOp pOperation, BufferedImage pInput, BufferedImage pOutput) { if (!USE_MAGICK) { return null; } BufferedImage result = null; switch (getNativeOpIndex(pOperation.getClass())) { case RESAMPLE_OP: ResampleOp resample = (ResampleOp) pOperation; result = resampleMagick(pInput, resample.width, resample.height, resample.filterType); // NOTE: If output parameter is non-null, we have to return that // image, instead of result if (pOutput != null) { //pOutput.setData(result.getRaster()); // Fast, but less compatible // NOTE: For some reason, this is sometimes super-slow...? ImageUtil.drawOnto(pOutput, result); result = pOutput; } break; default: // Simply fall through, allowing acceleration to be added later break; } return result; }
public static BufferedImage filter(BufferedImageOp pOperation, BufferedImage pInput, BufferedImage pOutput) { if (!USE_MAGICK) { return null; } BufferedImage result = null; switch (getNativeOpIndex(pOperation.getClass())) { case RESAMPLE_OP: ResampleOp resample = (ResampleOp) pOperation; result = resampleMagick(pInput, resample.mWidth, resample.mHeight, resample.mFilterType); // NOTE: If output parameter is non-null, we have to return that // image, instead of result if (pOutput != null) { //pOutput.setData(result.getRaster()); // Fast, but less compatible // NOTE: For some reason, this is sometimes super-slow...? ImageUtil.drawOnto(pOutput, result); result = pOutput; } break; default: // Simply fall through, allowing acceleration to be added later break; } return result; }
drawOnto(image, pOriginal);
drawOnto(image, pOriginal);
drawOnto(temp, pImage);
drawOnto(temp, scaled);
ImageUtil.drawOnto(pOutput, result); result = pOutput;