A bitmap that destroys the underlying reference when destructed.
More...
#include <pebble_graphics_types.hpp>
A bitmap that destroys the underlying reference when destructed.
◆ CreateBlank() [1/2]
Creates a new blank GBitmap on the heap initialized to zeroes. In the case that the format indicates a palettized bitmap, a palette of appropriate size will also be allocated on the heap.
- Parameters
-
size | The Pebble image dimensions as a GSize. |
format | The GBitmapFormat the created image should be in. |
- Returns
- The GBitmap.
◆ CreateBlank() [2/2]
Creates a new blank GBitmap on the heap, initialized to zeroes, and assigns it the given palette. No deep-copying of the palette occurs, so the caller is responsible for making sure the palette remains available when using the resulting bitmap. Management of that memory can be handed off to the system with the free_on_destroy argument.
- Parameters
-
size | The Pebble image dimensions as a GSize. |
format | the GBitmapFormat the created image and palette should be in. |
palette | a pointer to a palette that is to be used for this GBitmap. The palette should be large enough to hold enough colors for the specified format. For example, GBitmapFormat2BitPalette should have 4 colors, since 2^2 = 4. |
free_on_destroy | Set whether the palette data should be freed along with the bitmap data when the GBitmap is destroyed. |
- Returns
- The GBitmap.
◆ CreateFromPngData()
static GOwnedBitmap Pebble::GOwnedBitmap::CreateFromPngData |
( |
const uint8_t * |
png_data, |
|
|
size_t |
png_data_size |
|
) |
| |
|
inlinestatic |
Create a GBitmap based on raw PNG data. The resulting GBitmap must be destroyed using gbitmap_destroy(). The developer is responsible for freeing png_data following this call.
- Note
- PNG decoding currently supports 1,2,4 and 8 bit palettized and grayscale images.
- Parameters
-
png_data | PNG image data. |
png_data_size | PNG image size in bytes. |
- Returns
- Bitmap
◆ CreatePalettizedFrom1bit()
static GOwnedBitmap Pebble::GOwnedBitmap::CreatePalettizedFrom1bit |
( |
const ::GBitmap * |
src_bitmap | ) |
|
|
inlinestatic |
Given a 1-bit GBitmap, create a new bitmap of format GBitmapFormat1BitPalette. The new data buffer is allocated on the heap, and a 2-color palette is allocated as well.
- Parameters
-
src_bitmap | A GBitmap of format GBitmapFormat1Bit which is to be copied into a newly created GBitmap of format GBitmapFormat1BitPalettized. |
- Returns
- The newly created 1-bit palettized GBitmap.
- Note
- The new bitmap does not depend on any data from src_bitmap, so src_bitmap can be freed without worry.
◆ CreateSubBitmap()
Create a new GBitmap on the heap as a sub-bitmap of a 'base' GBitmap, using a GRect to indicate what portion of the base to use. The sub-bitmap will just reference the image data and palette of the base bitmap. No deep-copying occurs as a result of calling this function, thus the caller is responsible for making sure the base bitmap and palette will remain available when using the sub-bitmap. Note that you should not destroy the parent bitmap until the sub_bitmap has been destroyed.
- Parameters
-
[in] | base_bitmap | The bitmap that the sub-bitmap of which the image data will be used by the sub-bitmap |
| sub_rect | The rectangle within the image data of the base bitmap. The bounds of the base bitmap will be used to clip sub_rect . |
- Returns
- A GBitmap.
◆ CreateWithData()
static GOwnedBitmap Pebble::GOwnedBitmap::CreateWithData |
( |
const uint8_t * |
data | ) |
|
|
inlinestatic |
Creates a new GBitmap on the heap initialized with the provided Pebble image data.
When the GBitmap is destroyed but the image data will not be freed automatically. The developer is responsible for keeping the image data in memory as long as the bitmap is used and releasing it after the bitmap is destroyed.
- Note
- One way to generate Pebble image data is to use bitmapgen.py in the Pebble SDK to generate a .pbi file.
- Parameters
-
data | The Pebble image data. Must not be NULL. The function assumes the data to be correct; there are no sanity checks performed on the data. The data will not be copied and the pointer must remain valid for the lifetime of this GBitmap. |
- Returns
- The GBitmap.
◆ CreateWithResource()
static GOwnedBitmap Pebble::GOwnedBitmap::CreateWithResource |
( |
uint32_t |
resource_id | ) |
|
|
inlinestatic |
Creates a new GBitmap on the heap using a Pebble image file stored as a resource.
- Parameters
-
resource_id | The ID of the bitmap resource to load |
- Returns
- The GBitmap.
◆ SetBounds()
void Pebble::GOwnedBitmap::SetBounds |
( |
const GRect & |
bounds | ) |
|
|
inline |
Set the bounds of the given GBitmap.
- Parameters
-
bounds | The bounding box to set. |
- See also
- GetBounds
◆ SetData()
void Pebble::GOwnedBitmap::SetData |
( |
uint8_t * |
data, |
|
|
GBitmapFormat |
format, |
|
|
uint16_t |
row_size_bytes, |
|
|
bool |
free_on_destroy |
|
) |
| |
|
inline |
Set the bitmap data for the given GBitmap.
- Parameters
-
data | A pointer to the bitmap data |
format | the format of the bitmap data. If this is a palettized format, make sure that there is an accompanying call to gbitmap_set_palette. |
row_size_bytes | How many bytes a single row takes. For example, bitmap data of format GBitmapFormat1Bit must have a row size as a multiple of 4 bytes. |
free_on_destroy | Set whether the data should be freed when the GBitmap is destroyed. |
◆ SetPalette()
void Pebble::GOwnedBitmap::SetPalette |
( |
GColor * |
palette, |
|
|
bool |
free_on_destroy |
|
) |
| |
|
inline |
Set the palette for the given GBitmap.
- Parameters
-
palette | The palette to be used. Make sure that the palette is large enough for the bitmap's format. |
free_on_destroy | Set whether the palette data should be freed when the GBitmap is destroyed or when another palette is set. |
- See also
- GetFormat
The documentation for this class was generated from the following file: