Package com.sksamuel.scrimage.nio
Class ImmutableImageLoader
- java.lang.Object
-
- com.sksamuel.scrimage.nio.ImmutableImageLoader
-
public class ImmutableImageLoader extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ImmutableImageLoader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImmutableImageLoader
create()
ImmutableImageLoader
detectMetadata(boolean metadata)
Set to true to load metadata from the file.ImmutableImageLoader
detectOrientation(boolean reorientate)
Set to true to reorientate the image if applicable.ImmutableImage
fromBytes(byte[] bytes)
ImmutableImage
fromFile(java.io.File file)
ImmutableImage
fromFile(java.lang.String file)
ImmutableImage
fromPath(java.nio.file.Path path)
ImmutableImage
fromResource(java.lang.String resource)
ImmutableImage
fromStream(java.io.InputStream in)
Configures this loader to read from the provided input stream.ImmutableImage
load(ImageSource source)
ImmutableImageLoader
sourceRegion(java.awt.Rectangle rectangle)
Specifies a region of the image to be loaded.ImmutableImageLoader
type(int type)
Set the BufferedImage type for the backing image.ImmutableImageLoader
withClassLoader(java.lang.ClassLoader classloader)
ImmutableImageLoader
withImageReaders(java.util.List<ImageReader> readers)
Specifies the ImageReader's to use when trying to decode an image.ImmutableImageLoader
withJavaxImageReaders()
Specifies to use [javax.image.ImageReader] implementations only.ImmutableImageLoader
withJavaxImageReaders(java.util.List<javax.imageio.ImageReader> readers)
Specifies to use the given [javax.image.ImageReader] implementations only.
-
-
-
Method Detail
-
create
public static ImmutableImageLoader create()
-
detectOrientation
public ImmutableImageLoader detectOrientation(boolean reorientate)
Set to true to reorientate the image if applicable. Requires metadata to be enabled. Default true.
-
detectMetadata
public ImmutableImageLoader detectMetadata(boolean metadata)
Set to true to load metadata from the file. Set to false to skip metadata load. Default true.
-
sourceRegion
public ImmutableImageLoader sourceRegion(java.awt.Rectangle rectangle)
Specifies a region of the image to be loaded. Specifying a region here, rather than resizing the canvas after load can result in a performance gain under certain loaders.
-
type
public ImmutableImageLoader type(int type)
Set the BufferedImage type for the backing image. If the specified type is different from the type detected on load, this can result in an image copy operation. Default is to use the type in the underlying format.
-
withImageReaders
public ImmutableImageLoader withImageReaders(java.util.List<ImageReader> readers)
Specifies the ImageReader's to use when trying to decode an image. If not specified, then Scrimage will default to detecting the image readers on the classpath, through the Java Service Loader API.
-
withJavaxImageReaders
public ImmutableImageLoader withJavaxImageReaders()
Specifies to use [javax.image.ImageReader] implementations only. The javax.image.ImageReader to use will be detected by the JDK based on the stream contents.
-
withJavaxImageReaders
public ImmutableImageLoader withJavaxImageReaders(java.util.List<javax.imageio.ImageReader> readers)
Specifies to use the given [javax.image.ImageReader] implementations only.
-
withClassLoader
public ImmutableImageLoader withClassLoader(java.lang.ClassLoader classloader)
-
fromBytes
public ImmutableImage fromBytes(byte[] bytes) throws java.io.IOException
- Throws:
java.io.IOException
-
fromFile
public ImmutableImage fromFile(java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
fromFile
public ImmutableImage fromFile(java.lang.String file) throws java.io.IOException
- Throws:
java.io.IOException
-
fromPath
public ImmutableImage fromPath(java.nio.file.Path path) throws java.io.IOException
- Throws:
java.io.IOException
-
fromResource
public ImmutableImage fromResource(java.lang.String resource) throws java.io.IOException
- Throws:
java.io.IOException
-
fromStream
public ImmutableImage fromStream(java.io.InputStream in) throws java.io.IOException
Configures this loader to read from the provided input stream. The stream should be closed by the caller after this method has returned.- Throws:
java.io.IOException
-
load
public ImmutableImage load(ImageSource source) throws java.io.IOException
- Throws:
java.io.IOException
-
-