StreamContainer Class

Summary: Represents stream container which contains the stream and provides stream processing routines.

Module: aspose.imaging

Full Name: aspose.imaging.StreamContainer

Inheritance: DisposableObject

Constructors

NameDescription
StreamContainer(stream)Initializes a new instance of the StreamContainer class.
StreamContainer(stream, dispose_stream)Initializes a new instance of the StreamContainer class.

Properties

NameTypeAccessDescription
READ_WRITE_BYTES_COUNT [static]intrSpecifies read and write bytes count when reading sequentially.
can_readboolrGets a value indicating whether stream supports reading.
can_seekboolrGets a value indicating whether stream supports seeking.
can_writeboolrGets a value indicating whether stream supports writing.
disposedboolrGets a value indicating whether this instance is disposed.
is_stream_disposed_on_closeboolrGets a value indicating whether this stream is disposed on close.
lengthlongr/wGets or sets the stream length in bytes. This value is less than the by the starting stream position passed in the StreamContainer constructor.
positionlongr/wGets or sets the current position within the stream. This value represents offset from the starting stream position passed in the StreamContainer constructor.
stream_io.BufferedRandomrGets the data stream.
sync_rootobjectrGets an object that can be used to synchronize access to the synchronized resource.

Methods

NameDescription
flush()Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
read(buffer, offset, count)Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
read(bytes)Reads bytes to fill the specified bytes buffer.
read_byte()Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
save(destination_stream)Saves (copies) the stream’s data to the specified stream. Uses default buffer size StreamContainer.READ_WRITE_BYTES_COUNT and stream StreamContainer.length value.
save(destination_stream, buffer_size)Saves (copies) all the stream’s data to the specified stream. Uses stream StreamContainer.length value.
save(destination_stream, buffer_size, length)Saves (copies) the stream’s data to the specified stream.
save(file_path)Saves (copies) the stream’s data to the specified stream. Uses default buffer size StreamContainer.READ_WRITE_BYTES_COUNT and stream StreamContainer.length value.
save(file_path, buffer_size)Saves (copies) the stream’s data to the specified stream. Uses stream StreamContainer.length value.
save(file_path, buffer_size, length)Saves (copies) the stream’s data to the specified stream.
save_to_stream(destination_stream)Saves (copies) the stream’s data to the specified stream. Uses default buffer size StreamContainer.READ_WRITE_BYTES_COUNT and stream StreamContainer.length value.
save_to_stream_with_buf_size(destination_stream, buffer_size)Saves (copies) all the stream’s data to the specified stream. Uses stream StreamContainer.length value.
save_to_stream_with_buf_size_and_len(destination_stream, buffer_size, length)Saves (copies) the stream’s data to the specified stream.
save_with_buf_size(file_path, buffer_size)Saves (copies) the stream’s data to the specified stream. Uses stream StreamContainer.length value.
save_with_buf_size_and_len(file_path, buffer_size, length)Saves (copies) the stream’s data to the specified stream.
seek(offset, origin)Sets the position within the current stream.
seek_begin()Sets the stream position to the beginning of the stream. This value represents offset from the starting stream position passed in the StreamContainer constructor.
to_bytes()Converts the stream data to the int array.
to_bytes(position, bytes_count)Converts the stream data to the int array.
write(buffer, offset, count)Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
write(bytes)Writes all of the specified bytes to the stream.
write_byte(value)Writes a byte to the current position in the stream and advances the position within the stream by one byte.
write_to(stream_container)Copies the contained data to another StreamContainer.
write_to(stream_container, length)Copies the contained data to another StreamContainer.

Constructor: StreamContainer(stream)

 StreamContainer(stream) 

Initializes a new instance of the StreamContainer class.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream.

Constructor: StreamContainer(stream, dispose_stream)

 StreamContainer(stream, dispose_stream) 

Initializes a new instance of the StreamContainer class.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe data stream.
dispose_streamboolif set to true the stream will be disposed when container is disposed.

Method: read(buffer, offset, count)

 read(buffer, offset, count) 

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Parameters:

ParameterTypeDescription
bufferbyteAn array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
offsetintThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
countintThe maximum number of bytes to be read from the current stream.

Returns

TypeDescription
intThe total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.

Method: read(bytes)

 read(bytes) 

Reads bytes to fill the specified bytes buffer.

Parameters:

ParameterTypeDescription
bytesbyteThe bytes to fill.

Returns

TypeDescription
intThe number of bytes read. This value can be less than the number of bytes in the buffer if there is not enough bytes in the stream.

Method: read_byte()

 read_byte() 

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Returns

TypeDescription
intThe unsigned byte cast to an Int32, or -1 if at the end of the stream.

Method: save(destination_stream)

 save(destination_stream) 

Saves (copies) the stream’s data to the specified stream. Uses default buffer size StreamContainer.READ_WRITE_BYTES_COUNT and stream StreamContainer.length value.

Parameters:

ParameterTypeDescription
destination_stream_io.BufferedRandomThe stream to save the data to.

Method: save(destination_stream, buffer_size)

 save(destination_stream, buffer_size) 

Saves (copies) all the stream’s data to the specified stream. Uses stream StreamContainer.length value.

Parameters:

ParameterTypeDescription
destination_stream_io.BufferedRandomThe stream to save the data to.
buffer_sizeintThe buffer.

Method: save(destination_stream, buffer_size, length)

 save(destination_stream, buffer_size, length) 

Saves (copies) the stream’s data to the specified stream.

Parameters:

ParameterTypeDescription
destination_stream_io.BufferedRandomThe stream to save the data to.
buffer_sizeintThe buffer size. By default StreamContainer.READ_WRITE_BYTES_COUNT value is used.
lengthlongThe stream data length to copy. By default the length is set to StreamContainer.length value.

Method: save(file_path)

 save(file_path) 

Saves (copies) the stream’s data to the specified stream. Uses default buffer size StreamContainer.READ_WRITE_BYTES_COUNT and stream StreamContainer.length value.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to save the stream data to.

Method: save(file_path, buffer_size)

 save(file_path, buffer_size) 

Saves (copies) the stream’s data to the specified stream. Uses stream StreamContainer.length value.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to save the stream data to.
buffer_sizeintThe buffer size. By default StreamContainer.READ_WRITE_BYTES_COUNT value is used.

Method: save(file_path, buffer_size, length)

 save(file_path, buffer_size, length) 

Saves (copies) the stream’s data to the specified stream.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to save the stream data to.
buffer_sizeintThe buffer size. By default StreamContainer.READ_WRITE_BYTES_COUNT value is used.
lengthlongThe stream data length to copy. By default the length is set to StreamContainer.length value.

Method: save_to_stream(destination_stream)

 save_to_stream(destination_stream) 

Saves (copies) the stream’s data to the specified stream. Uses default buffer size StreamContainer.READ_WRITE_BYTES_COUNT and stream StreamContainer.length value.

Parameters:

ParameterTypeDescription
destination_stream_io.BufferedRandomThe stream to save the data to.

Method: save_to_stream_with_buf_size(destination_stream, buffer_size)

 save_to_stream_with_buf_size(destination_stream, buffer_size) 

Saves (copies) all the stream’s data to the specified stream. Uses stream StreamContainer.length value.

Parameters:

ParameterTypeDescription
destination_stream_io.BufferedRandomThe stream to save the data to.
buffer_sizeintThe buffer.

Method: save_to_stream_with_buf_size_and_len(destination_stream, buffer_size, length)

 save_to_stream_with_buf_size_and_len(destination_stream, buffer_size, length) 

Saves (copies) the stream’s data to the specified stream.

Parameters:

ParameterTypeDescription
destination_stream_io.BufferedRandomThe stream to save the data to.
buffer_sizeintThe buffer size. By default StreamContainer.READ_WRITE_BYTES_COUNT value is used.
lengthlongThe stream data length to copy. By default the length is set to StreamContainer.length value.

Method: save_with_buf_size(file_path, buffer_size)

 save_with_buf_size(file_path, buffer_size) 

Saves (copies) the stream’s data to the specified stream. Uses stream StreamContainer.length value.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to save the stream data to.
buffer_sizeintThe buffer size. By default StreamContainer.READ_WRITE_BYTES_COUNT value is used.

Method: save_with_buf_size_and_len(file_path, buffer_size, length)

 save_with_buf_size_and_len(file_path, buffer_size, length) 

Saves (copies) the stream’s data to the specified stream.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to save the stream data to.
buffer_sizeintThe buffer size. By default StreamContainer.READ_WRITE_BYTES_COUNT value is used.
lengthlongThe stream data length to copy. By default the length is set to StreamContainer.length value.

Method: seek(offset, origin)

 seek(offset, origin) 

Sets the position within the current stream.

Parameters:

ParameterTypeDescription
offsetlongA byte offset relative to the origin parameter. This value represents offset from the starting stream position passed in the StreamContainer constructor.
originSeekOriginA value of type SeekOrigin indicating the reference point used to obtain the new position.

Returns

TypeDescription
longThe new position within the current stream.

Method: to_bytes()

 to_bytes() 

Converts the stream data to the int array.

Returns

TypeDescription
byteThe stream data converted to the int array.

Method: to_bytes(position, bytes_count)

 to_bytes(position, bytes_count) 

Converts the stream data to the int array.

Parameters:

ParameterTypeDescription
positionlongThe position to start reading bytes from.
bytes_countlongThe bytes count to read.

Returns

TypeDescription
byteThe stream data converted to the int array.

Method: write(buffer, offset, count)

 write(buffer, offset, count) 

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Parameters:

ParameterTypeDescription
bufferbyteAn array of bytes. This method copies count bytes from buffer to the current stream.
offsetintThe zero-based byte offset in buffer at which to begin copying bytes to the current stream.
countintThe number of bytes to be written to the current stream.

Method: write(bytes)

 write(bytes) 

Writes all of the specified bytes to the stream.

Parameters:

ParameterTypeDescription
bytesbyteThe bytes to write.

Method: write_byte(value)

 write_byte(value) 

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

Parameters:

ParameterTypeDescription
valuebyteThe byte to write to the stream.

Method: write_to(stream_container)

 write_to(stream_container) 

Copies the contained data to another StreamContainer.

Parameters:

ParameterTypeDescription
stream_containerStreamContainerThe stream container to copy to.

Method: write_to(stream_container, length)

 write_to(stream_container, length) 

Copies the contained data to another StreamContainer.

Parameters:

ParameterTypeDescription
stream_containerStreamContainerThe stream container to copy to.
lengthlongThe bytes count to write.