Provides for the conversion of a Translation Kit bitmap object to a BBitmap. More...
Inherits BPositionIO.
Public Member Functions | |
BBitmapStream (BBitmap *bitmap=NULL) | |
Initializes this object to either use the BBitmap passed to it as the object to read/write to or to create a BBitmap when data is written to this object. | |
virtual | ~BBitmapStream () |
Destroys the object and the BBitmap object if attached. | |
status_t | DetachBitmap (BBitmap **_bitmap) |
Sets _bitmap to point to the internal bitmap object. | |
virtual off_t | Position () const |
Gets the current stream position. | |
virtual ssize_t | ReadAt (off_t offset, void *buffer, size_t size) |
Reads data from the stream into buffer at a specific position and size. | |
virtual off_t | Seek (off_t position, uint32 seekMode) |
Changes the current stream position. | |
virtual status_t | SetSize (off_t size) |
Sets the size of the data. | |
virtual off_t | Size () const |
Gets the current stream size. | |
virtual ssize_t | WriteAt (off_t offset, const void *buffer, size_t size) |
Writes data to the bitmap starting at a specific position and size. | |
![]() | |
BPositionIO () | |
This constructor does nothing. | |
virtual | ~BPositionIO () |
This destructor does nothing. | |
virtual status_t | GetSize (off_t *size) const |
Get the size of the object or data. | |
virtual off_t | Position () const =0 |
Pure virtual to return the current position of the cursor. | |
virtual ssize_t | Read (void *buffer, size_t size) |
Read data from current position. | |
virtual ssize_t | ReadAt (off_t position, void *buffer, size_t size)=0 |
Pure virtual to read data from a certain position. | |
status_t | ReadAtExactly (off_t position, void *buffer, size_t size, size_t *_bytesRead=NULL) |
Reads an exact amount of data from the object at the specified position into a buffer. | |
virtual off_t | Seek (off_t position, uint32 seekMode)=0 |
Pure virtual to move the cursor to a certain position. | |
virtual status_t | SetSize (off_t size) |
Set the size of the object or data. | |
virtual ssize_t | Write (const void *buffer, size_t size) |
Write data to the current position. | |
virtual ssize_t | WriteAt (off_t position, const void *buffer, size_t size)=0 |
Pure virtual to write data to a certain position. | |
status_t | WriteAtExactly (off_t position, const void *buffer, size_t size, size_t *_bytesWritten=NULL) |
Writes an exact amount of data from a buffer to the object at the specified position. | |
![]() | |
BDataIO () | |
This constructor does nothing. | |
virtual | ~BDataIO () |
This destructor does nothing. | |
virtual status_t | Flush () |
Writes pending data to underlying storage. | |
virtual ssize_t | Read (void *buffer, size_t size) |
Reads data from the object into a buffer. | |
status_t | ReadExactly (void *buffer, size_t size, size_t *_bytesRead=NULL) |
Reads an exact amount of data from the object into a buffer. | |
virtual ssize_t | Write (const void *buffer, size_t size) |
Writes data from a buffer to the object. | |
status_t | WriteExactly (const void *buffer, size_t size, size_t *_bytesWritten=NULL) |
Writes an exact amount of data from a buffer to the object. | |
Protected Member Functions | |
void | SwapHeader (const TranslatorBitmap *source, TranslatorBitmap *destination) |
Swaps the byte order of source, no matter the byte order, and copies the result to destination. | |
Provides for the conversion of a Translation Kit bitmap object to a BBitmap.
BBitmapStream is limited subclass of BPositionIO that is good at reading and writing Translation Kit bitmaps. The DetachBitmap() method is the main method of this class as it returns the contents of the Translation Kit bitmap object into a BBitmap.
In most cases you shouldn't have to use this class directly as BTranslationUtils contains methods to load images from files and resources.
Sets _bitmap to point to the internal bitmap object.
The bitmap is not deleted when the BBitmapStream is deleted. After the bitmap has been detached it is still used by the stream, but it is never deleted by the stream.
Once you have called DetachBitmap() no further operations should be performed on the BBitmapStream except to destroy the object.
_bitmap | A BBitmap pointer that will be set to point to the internal bitmap object. |
B_OK
on success or an error code. B_OK | The bitmap was detached. |
B_BAD_VALUE | _bitmap is NULL . |
B_ERROR | The internal bitmap object is NULL or has already been detached. |
|
virtual |
|
virtual |
Reads data from the stream into buffer at a specific position and size.
The first sizeof(TranslatorBitmap) bytes are the bitmap header. The header is always written out and read in as big endian byte order.
pos | The position in the stream to read from. |
buffer | Where the data will be read into |
size | The amount of data to be read. |
B_BAD_VALUE | buffer is NULL or pos is invalid or the amount read if the result >= 0 |
B_NO_INIT | There is no bitmap stored by the stream. |
Implements BPositionIO.
|
virtual |
Changes the current stream position.
position | The position offset. |
seekMode | Decides how the position offset is used:
|
B_BAD_VALUE | position was bad. |
Implements BPositionIO.
|
virtual |
Sets the size of the data.
size | The size to set the stream size to. |
B_NO_ERROR
on success or an error code. B_NO_ERROR | (or B_OK ) Size is a valid value. |
B_BAD_VALUE | size is NOT a valid value. |
Reimplemented from BPositionIO.
|
virtual |
Gets the current stream size.
|
protected |
Swaps the byte order of source, no matter the byte order, and copies the result to destination.
source | Data to be swapped. |
destination | Where the swapped data will be copied to. |
|
virtual |
Writes data to the bitmap starting at a specific position and size.
The first sizeof(TranslatorBitmap) bytes of data must be the TranslatorBitmap header in big endian byte order or the data will not be written.
pos | The position in the stream to write to data. |
data | The data to write to the stream. |
size | The size of the data to write to the stream. |
B_BAD_VALUE | Size is bad or data is NULL or pos is invalid. |
B_MISMATCHED_VALUES | The bitmap header is bad. |
B_ERROR | Error allocating memory or setting up big endian header, |
Implements BPositionIO.