public class ImageSaver extends Object
Modifier and Type | Field and Description |
---|---|
static Field |
Bbuf |
static DirectColorModel |
RGB_COLOR_MODEL |
static DirectColorModel |
RGBA_COLOR_MODEL |
static DirectColorModel |
RGBA_PRE_COLOR_MODEL |
Modifier and Type | Method and Description |
---|---|
static BufferedImage |
asBufferedImage(Image awt) |
static BufferedImage |
asGrey(BufferedImage bi)
If the given BufferedImage is of type TYPE_BYTE_GRAY, it will simply return it.
|
static boolean |
checkPath(String path)
Will create parent directories if they don't exist.
|
static BufferedImage |
createARGBImage(int[] pixels,
int width,
int height) |
static BufferedImage |
createARGBImagePre(int[] pixels,
int width,
int height)
Assumes the pixels have been premultiplied.
|
static BufferedImage |
createGrayImage(byte[] pixels,
int width,
int height) |
static BufferedImage |
createImage(int[] pixels,
int width,
int height,
DirectColorModel cm) |
static BufferedImage |
createRGBImage(int[] pixels,
int width,
int height) |
static void |
debugAlpha() |
static int |
estimateJPEGFileSize(int w,
int h)
Based on EM images of neuropils with outside alpha masks.
|
static String |
getDescriptionString(ij.ImagePlus imp,
ij.io.FileInfo fi)
Returns a string containing information about the specified image.
|
static BufferedImage |
open(String path,
boolean as_grey) |
static BufferedImage |
openFromStream(InputStream stream,
boolean as_grey)
The stream IS NOT closed by this method.
|
static BufferedImage |
openGreyImage(String path) |
static BufferedImage |
openGreyTIFF(String path) |
static BufferedImage |
openImage(String path,
boolean ensure_premultiplied_alpha)
Open an image file including the alpha channel if it has one; will open JPEG, PNG and BMP.
|
static BufferedImage |
openJpegAlpha(String path)
Open a jpeg file including the alpha channel if it has one.
|
static BufferedImage |
openPNGAlpha(String path) |
static BufferedImage |
openTIFF(String path,
boolean ensure_premultiplied_alpha)
Opens RGB or RGB + alpha images stored in TIFF format.
|
static boolean |
saveAsARGBJpeg(int[] pixels,
int width,
int height,
String path,
float quality)
Save as ARGB jpeg.
|
static boolean |
saveAsGreyJpeg(byte[] pixels,
int width,
int height,
String path,
float quality) |
static boolean |
saveAsJpeg(BufferedImage bi,
String path,
float quality,
boolean as_grey)
Will not flush the given BufferedImage.
|
static boolean |
saveAsJpeg(ij.process.ImageProcessor ip,
String path,
float quality,
boolean as_grey)
Returns true on success.
|
static boolean |
saveAsJpegAlpha(BufferedImage awt,
String path,
float quality)
Save an RGB jpeg including the alpha channel if it has one; can be read only by ImageSaver.openJpegAlpha method; in other software the alpha channel is confused by some other color channel.
|
static boolean |
saveAsJpegAlpha(Image awt,
String path,
float quality)
Save an RGB jpeg including the alpha channel if it has one; can be read only by ImageSaver.openJpegAlpha method; in other software the alpha channel is confused by some other color channel.
|
static boolean |
saveAsPNG(BufferedImage awt,
String path)
Save a PNG with or without alpha channel with default compression at maximum level (9, expressed as 0 in the ImageWriter compression quality because 0 indicates "maximum compression is important").
|
static boolean |
saveAsPNG(ij.process.ImageProcessor ip,
String path) |
static boolean |
saveAsPNG(Image awt,
String path) |
static boolean |
saveAsTIFF(BufferedImage bi,
String path,
boolean as_grey) |
static boolean |
saveAsTIFF(ij.process.ImageProcessor ip,
String path,
boolean as_grey)
WARNING fails when there is an alpha channel: generates an empty file.
|
static boolean |
saveAsTIFF(Image awt,
String path,
boolean as_grey)
Will not flush @param awt.
|
static boolean |
saveAsZip(ij.ImagePlus imp,
String path)
Returns true on success.
|
public static final DirectColorModel RGBA_COLOR_MODEL
public static final DirectColorModel RGBA_PRE_COLOR_MODEL
public static final DirectColorModel RGB_COLOR_MODEL
public static final Field Bbuf
public static final boolean checkPath(String path)
Returns false if the path is unusable.
public static final boolean saveAsJpeg(ij.process.ImageProcessor ip, String path, float quality, boolean as_grey)
Core functionality adapted from ij.plugin.JpegWriter
class by Wayne Rasband.
public static final BufferedImage createGrayImage(byte[] pixels, int width, int height)
public static final boolean saveAsGreyJpeg(byte[] pixels, int width, int height, String path, float quality)
public static final BufferedImage createImage(int[] pixels, int width, int height, DirectColorModel cm)
public static final BufferedImage createRGBImage(int[] pixels, int width, int height)
public static final BufferedImage createARGBImage(int[] pixels, int width, int height)
public static final BufferedImage createARGBImagePre(int[] pixels, int width, int height)
public static final boolean saveAsARGBJpeg(int[] pixels, int width, int height, String path, float quality)
public static final boolean saveAsJpeg(BufferedImage bi, String path, float quality, boolean as_grey)
public static final BufferedImage open(String path, boolean as_grey)
public static final BufferedImage openFromStream(InputStream stream, boolean as_grey)
public static final boolean saveAsZip(ij.ImagePlus imp, String path)
Core functionality adapted from ij.io.FileSaver
class by Wayne Rasband.
public static final String getDescriptionString(ij.ImagePlus imp, ij.io.FileInfo fi)
public static final int estimateJPEGFileSize(int w, int h)
public static final boolean saveAsJpegAlpha(BufferedImage awt, String path, float quality)
public static final boolean saveAsJpegAlpha(Image awt, String path, float quality)
public static final BufferedImage asBufferedImage(Image awt)
public static BufferedImage openJpegAlpha(String path)
public static BufferedImage openPNGAlpha(String path)
public static BufferedImage openImage(String path, boolean ensure_premultiplied_alpha)
ensure_premultiplied_alpha
- when true, ALWAYS puts the loaded image into a TYPE_INT_ARGB_PRE, which ensures for example PNG images with an alpha channel but of TYPE_CUSTOM to be premultiplied as well.public static BufferedImage openGreyImage(String path)
public static final BufferedImage asGrey(BufferedImage bi)
public static final void debugAlpha()
public static final boolean saveAsPNG(ij.process.ImageProcessor ip, String path)
public static final boolean saveAsPNG(BufferedImage awt, String path)
public static final boolean saveAsTIFF(ij.process.ImageProcessor ip, String path, boolean as_grey)
public static final boolean saveAsTIFF(Image awt, String path, boolean as_grey)
public static final boolean saveAsTIFF(BufferedImage bi, String path, boolean as_grey)
public static final BufferedImage openTIFF(String path, boolean ensure_premultiplied_alpha)
public static final BufferedImage openGreyTIFF(String path)
Copyright © 2015–2021 Fiji. All rights reserved.