/** * Retrieves the number of bytes per pixel in the current plane. * @param pixelType the pixel type, as a String. * @return the number of bytes per pixel. * @see #pixelTypeFromString(String) * @see #getBytesPerPixel(int) */ public static int getBytesPerPixel(String pixelType) { return getBytesPerPixel(pixelTypeFromString(pixelType)); }
ASCII(int pixelType, int pixelsPerPlane) { this.pixelType = pixelType; this.pixelsPerPlane = pixelsPerPlane; bytesPerPixel = FormatTools.getBytesPerPixel(pixelType); offsets = new long[getSizeZ() + 1]; offsets[0] = offsetOfFirstStream; }
ASCII(int pixelType, int pixelsPerPlane) { this.pixelType = pixelType; this.pixelsPerPlane = pixelsPerPlane; bytesPerPixel = FormatTools.getBytesPerPixel(pixelType); offsets = new long[getSizeZ() + 1]; offsets[0] = offsetOfFirstStream; }
private int getTileSize() { int channels = getRGBChannelCount(); int bpp = FormatTools.getBytesPerPixel(getPixelType()); int index = getCoreIndex(); return bpp * channels * tileX.get(index) * tileY.get(index); }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { byte[] buf = DataTools.allocate(w, h, FormatTools.getBytesPerPixel(getPixelType())); return openBytes(no, buf, x, y, w, h); }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { byte[] buf = new byte[w * h * getRGBChannelCount() * FormatTools.getBytesPerPixel(getPixelType())]; return openBytes(no, buf, x, y, w, h); }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { byte[] buf = new byte[w * h * getRGBChannelCount() * FormatTools.getBytesPerPixel(getPixelType())]; return openBytes(no, buf, x, y, w, h); }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { byte[] buf = DataTools.allocate(w, h, FormatTools.getBytesPerPixel(getPixelType())); return openBytes(no, buf, x, y, w, h); }
@Override public int getOptimalTileHeight() { FormatTools.assertId(currentId, true, 1); int bpp = FormatTools.getBytesPerPixel(getPixelType()); int maxHeight = (1024 * 1024) / (getSizeX() * getRGBChannelCount() * bpp); return (int) Math.min(maxHeight, getSizeY()); }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { int bpp = FormatTools.getBytesPerPixel(getPixelType()); int ch = getRGBChannelCount(); byte[] buf = DataTools.allocate(w, h, ch, bpp); return openBytes(no, buf, x, y, w, h); }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { byte[] buf = DataTools.allocate(w, h, getRGBChannelCount(), FormatTools.getBytesPerPixel(getPixelType())); return openBytes(no, buf, x, y, w, h); }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { int bpp = FormatTools.getBytesPerPixel(getPixelType()); int ch = getRGBChannelCount(); byte[] buf = DataTools.allocate(w, h, ch, bpp); return openBytes(no, buf, x, y, w, h); }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { int bpp = FormatTools.getBytesPerPixel(getPixelType()); int ch = getRGBChannelCount(); byte[] newBuffer = DataTools.allocate(w, h, ch, bpp); return openBytes(no, newBuffer, x, y, w, h); }
@Override public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException { byte[] buf = DataTools.allocate(w, h, getRGBChannelCount(), FormatTools.getBytesPerPixel(getPixelType())); return openBytes(no, buf, x, y, w, h); }
/** 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)); }
@Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.assertId(getCurrentFile(), true, 2); super.openBytes(no, buf, x, y, w, h); updateMinMax(no, buf, FormatTools.getBytesPerPixel(getPixelType()) * w * h); return buf; }
@Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.assertId(getCurrentFile(), true, 2); super.openBytes(no, buf, x, y, w, h); updateMinMax(no, buf, FormatTools.getBytesPerPixel(getPixelType()) * w * h); return buf; }
/** 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)); }
private int planeCount() { MetadataRetrieve r = getMetadataRetrieve(); int z = r.getPixelsSizeZ(series).getValue().intValue(); int t = r.getPixelsSizeT(series).getValue().intValue(); int c = r.getChannelCount(series); String pixelType = r.getPixelsType(series).getValue(); int bytes = FormatTools.getBytesPerPixel(pixelType); if (bytes > 1 && c == 1) { c = r.getChannelSamplesPerPixel(series, 0).getValue(); } return z * c * t; }
@Override public int getPlaneCount() { MetadataRetrieve retrieve = getMetadataRetrieve(); int c = getSamplesPerPixel(); int type = FormatTools.pixelTypeFromString( retrieve.getPixelsType(series).toString()); int bytesPerPixel = FormatTools.getBytesPerPixel(type); if (bytesPerPixel > 1 && c != 1 && c != 3) { return super.getPlaneCount() * c; } return super.getPlaneCount(); }