/** * A static helper method to retrieve pixel byte signage. * * @param type * The pixels type for which you want to know the byte width. * @return The number of bytes per pixel value. */ public static boolean isTypeSigned(PixelsType type) { return FormatTools.isSigned(getPixelType(type)); }
public boolean isSigned() { return FormatTools.isSigned(reader.getPixelType()); }
/** * Converts the given BufferedImage into an image with unsigned pixel data. */ public static BufferedImage makeUnsigned(BufferedImage img) { if (img == null) return null; int pixelType = getPixelType(img); boolean signed = FormatTools.isSigned(pixelType); boolean fp = FormatTools.isFloatingPoint(pixelType); if (!signed || fp) return img; int bpp = FormatTools.getBytesPerPixel(pixelType); byte[][] pix = getPixelBytes(img, false); return makeImage(pix, img.getWidth(), img.getHeight(), bpp, fp, false, false); }
/** * Converts the given BufferedImage into an image with unsigned pixel data. */ public static BufferedImage makeUnsigned(BufferedImage img) { if (img == null) return null; int pixelType = getPixelType(img); boolean signed = FormatTools.isSigned(pixelType); boolean fp = FormatTools.isFloatingPoint(pixelType); if (!signed || fp) return img; int bpp = FormatTools.getBytesPerPixel(pixelType); byte[][] pix = getPixelBytes(img, false); return makeImage(pix, img.getWidth(), img.getHeight(), bpp, fp, false, false); }
/** Returns a subimage of the specified image. */ public static BufferedImage getSubimage(BufferedImage image, boolean littleEndian, int x, int y, int w, int h) { int pixelType = getPixelType(image); byte[][] pix = getPixelBytes(image, littleEndian, x, y, w, h); return makeImage(pix, w, h, FormatTools.getBytesPerPixel(pixelType), FormatTools.isFloatingPoint(pixelType), littleEndian, FormatTools.isSigned(pixelType)); }
/** Returns a subimage of the specified image. */ public static BufferedImage getSubimage(BufferedImage image, boolean littleEndian, int x, int y, int w, int h) { int pixelType = getPixelType(image); byte[][] pix = getPixelBytes(image, littleEndian, x, y, w, h); return makeImage(pix, w, h, FormatTools.getBytesPerPixel(pixelType), FormatTools.isFloatingPoint(pixelType), littleEndian, FormatTools.isSigned(pixelType)); }
/** Converts an indexed color BufferedImage to an RGB BufferedImage. */ public static BufferedImage indexedToRGB(BufferedImage img, boolean le) { byte[][] indices = getPixelBytes(img, le); if (indices.length > 1) return img; int pixelType = getPixelType(img); boolean signed = FormatTools.isSigned(pixelType); if (pixelType == FormatTools.UINT8) { IndexColorModel model = (IndexColorModel) img.getColorModel(); byte[][] b = new byte[3][indices[0].length]; for (int i=0; i<indices[0].length; i++) { b[0][i] = (byte) (model.getRed(indices[0][i] & 0xff) & 0xff); b[1][i] = (byte) (model.getGreen(indices[0][i] & 0xff) & 0xff); b[2][i] = (byte) (model.getBlue(indices[0][i] & 0xff) & 0xff); } return makeImage(b, img.getWidth(), img.getHeight(), signed); } else if (pixelType == FormatTools.UINT16) { Index16ColorModel model = (Index16ColorModel) img.getColorModel(); short[][] s = new short[3][indices[0].length / 2]; for (int i=0; i<s[0].length; i++) { int ndx = DataTools.bytesToInt(indices[0], i*2, 2, le) & 0xffff; s[0][i] = (short) (model.getRed(ndx) & 0xffff); s[1][i] = (short) (model.getRed(ndx) & 0xffff); s[2][i] = (short) (model.getRed(ndx) & 0xffff); } return makeImage(s, img.getWidth(), img.getHeight(), signed); } return null; }
/** Converts an indexed color BufferedImage to an RGB BufferedImage. */ public static BufferedImage indexedToRGB(BufferedImage img, boolean le) { byte[][] indices = getPixelBytes(img, le); if (indices.length > 1) return img; int pixelType = getPixelType(img); boolean signed = FormatTools.isSigned(pixelType); if (pixelType == FormatTools.UINT8) { IndexColorModel model = (IndexColorModel) img.getColorModel(); byte[][] b = new byte[3][indices[0].length]; for (int i=0; i<indices[0].length; i++) { b[0][i] = (byte) (model.getRed(indices[0][i] & 0xff) & 0xff); b[1][i] = (byte) (model.getGreen(indices[0][i] & 0xff) & 0xff); b[2][i] = (byte) (model.getBlue(indices[0][i] & 0xff) & 0xff); } return makeImage(b, img.getWidth(), img.getHeight(), signed); } else if (pixelType == FormatTools.UINT16) { Index16ColorModel model = (Index16ColorModel) img.getColorModel(); short[][] s = new short[3][indices[0].length / 2]; for (int i=0; i<s[0].length; i++) { int ndx = DataTools.bytesToInt(indices[0], i*2, 2, le) & 0xffff; s[0][i] = (short) (model.getRed(ndx) & 0xffff); s[1][i] = (short) (model.getRed(ndx) & 0xffff); s[2][i] = (short) (model.getRed(ndx) & 0xffff); } return makeImage(s, img.getWidth(), img.getHeight(), signed); } return null; }
if (FormatTools.isSigned(bfPixelsType)) { minmax[0] = -Math.pow(2, significantBits - 1); minmax[1] = Math.pow(2, significantBits - 1) - 1;
boolean signed = FormatTools.isSigned(pixelType); if (o instanceof byte[][]) { byte[][] pix = (byte[][]) o;
boolean signed = FormatTools.isSigned(pixelType); if (o instanceof byte[][]) { byte[][] pix = (byte[][]) o;
String type = r.getPixelsType(series).toString(); int pixelType = FormatTools.pixelTypeFromString(type); boolean signed = FormatTools.isSigned(pixelType);
int type = FormatTools.pixelTypeFromString(pixelsType); long[] values = FormatTools.defaultMinMax(type); isSigned = FormatTools.isSigned(type); isFloat = FormatTools.isFloatingPoint(type); minimum = values[0];
String type = r.getPixelsType(series).toString(); int pixelType = FormatTools.pixelTypeFromString(type); boolean signed = FormatTools.isSigned(pixelType);
options.channels = 1; options.interleaved = false; options.signed = FormatTools.isSigned(pixelType); boolean littleEndian = false; if (r.getPixelsBigEndian(series) != null) {
interleaved, FormatTools.getBytesPerPixel(type), FormatTools.isFloatingPoint(type), littleEndian, FormatTools.isSigned(type));
options.channels = 1; options.interleaved = false; options.signed = FormatTools.isSigned(pixelType); boolean littleEndian = false; if (r.getPixelsBigEndian(series) != null) {
interleaved, FormatTools.getBytesPerPixel(type), FormatTools.isFloatingPoint(type), littleEndian, FormatTools.isSigned(type));
if (FormatTools.isSigned(pixelType)) { source = makeUnsigned(source); sourceModel = null;
if (FormatTools.isSigned(pixelType)) { source = makeUnsigned(source); sourceModel = null;