StreamSource
Inheritance: java.lang.Object, com.aspose.imaging.Source
public final class StreamSource extends Source
Represents a stream source.
Constructors
Constructor | Description |
---|---|
StreamSource(System.IO.Stream stream) | Initializes a new instance of the StreamSource class. |
StreamSource(InputStream stream) | Initializes a new instance of the StreamSource class. |
StreamSource(byte[] data) | Initializes a new instance of the StreamSource class. |
StreamSource(ByteBuffer buffer) | Initializes a new instance of the StreamSource class. |
StreamSource() | Initializes a new instance of the StreamSource class with Null stream. |
StreamSource(RandomAccessFile file) | Initializes a new instance of the StreamSource class. |
StreamSource(RandomAccessFile file, boolean disposeStream) | Initializes a new instance of the StreamSource class. |
StreamSource(System.IO.Stream stream, boolean disposeStream) | Initializes a new instance of the StreamSource class. |
StreamSource(InputStream stream, boolean disposeStream) | Initializes a new instance of the StreamSource class. |
Methods
Method | Description |
---|---|
getStream() | Gets the stream. |
getDisposeStream() | Gets a value indicating whether stream should be disposed whenever container gets disposed. |
getStreamContainer() | Gets the stream container. |
Example: This example demonstrates how to use StreamSource to create a new Image file (a JPEG type)
//Creates an instance of JpegOptions and set its various properties
com.aspose.imaging.imageoptions.JpegOptions jpegOptions = new com.aspose.imaging.imageoptions.JpegOptions();
//Create an instance of System.IO.Stream
java.io.InputStream stream = new java.io.FileInputStream("C:\\temp\\sample.jpeg");
// Define the source property for the instance of JpegOptions
// Second boolean parameter determines if the Stream is disposed once get out of scope
jpegOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream, true));
// Creates an instance of Image and call Create method with JpegOptions as parameter to initialize the Image object
com.aspose.imaging.Image image = com.aspose.imaging.Image.create(jpegOptions, 500, 500);
try {
// Do some image processing
} finally {
image.dispose();
}
StreamSource(System.IO.Stream stream)
public StreamSource(System.IO.Stream stream)
Initializes a new instance of the StreamSource
class.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | com.aspose.ms.System.IO.Stream | The stream to open. |
StreamSource(InputStream stream)
public StreamSource(InputStream stream)
Initializes a new instance of the StreamSource
class.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | The stream to open. |
StreamSource(byte[] data)
public StreamSource(byte[] data)
Initializes a new instance of the StreamSource
class.
Parameters:
Parameter | Type | Description |
---|---|---|
data | byte[] | byte array which is stored the image |
StreamSource(ByteBuffer buffer)
public StreamSource(ByteBuffer buffer)
Initializes a new instance of the StreamSource
class.
Parameters:
Parameter | Type | Description |
---|---|---|
buffer | java.nio.ByteBuffer | ByteBuffer buffer for storing the image |
StreamSource()
public StreamSource()
Initializes a new instance of the StreamSource
class with Null stream. This constructor allows to create new images without input stream, images stored only in memory.
StreamSource(RandomAccessFile file)
public StreamSource(RandomAccessFile file)
Initializes a new instance of the StreamSource
class.
Parameters:
Parameter | Type | Description |
---|---|---|
file | java.io.RandomAccessFile | The file to open. |
StreamSource(RandomAccessFile file, boolean disposeStream)
public StreamSource(RandomAccessFile file, boolean disposeStream)
Initializes a new instance of the StreamSource
class.
Parameters:
Parameter | Type | Description |
---|---|---|
file | java.io.RandomAccessFile | The file to open. |
disposeStream | boolean | if set to true the stream will be disposed. |
StreamSource(System.IO.Stream stream, boolean disposeStream)
public StreamSource(System.IO.Stream stream, boolean disposeStream)
Initializes a new instance of the StreamSource
class.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | com.aspose.ms.System.IO.Stream | The stream |
disposeStream | boolean | if set to true the stream will be disposed. |
StreamSource(InputStream stream, boolean disposeStream)
public StreamSource(InputStream stream, boolean disposeStream)
Initializes a new instance of the StreamSource
class.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | The stream to open. |
disposeStream | boolean | if set to true the stream will be disposed. |
getStream()
public System.IO.Stream getStream()
Gets the stream.
Returns: com.aspose.ms.System.IO.Stream - The stream.
getDisposeStream()
public boolean getDisposeStream()
Gets a value indicating whether stream should be disposed whenever container gets disposed.
Returns:
boolean - true
if stream should be disposed; otherwise, false
.
getStreamContainer()
public StreamContainer getStreamContainer()
Gets the stream container.
Returns: StreamContainer - the stream container.
Use with caution. You will need to dispose the stream container after retrieval.