NetSurf
|
Internal core bitmap interface. More...
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "utils/log.h"
#include "utils/errors.h"
#include "desktop/bitmap.h"
#include "desktop/gui_internal.h"
Go to the source code of this file.
Functions | |
static struct bitmap_colour_layout | bitmap__get_colour_layout (const bitmap_fmt_t *fmt) |
Get the colour layout for the given bitmap format. More... | |
static const char * | bitmap__layout_to_str (enum bitmap_layout layout) |
Get string for given pixel layout. More... | |
void | bitmap_set_format (const bitmap_fmt_t *bitmap_format) |
Set client bitmap format. More... | |
static void | bitmap__format_convert (int width, int height, uint8_t *buffer, size_t rowstride, struct bitmap_colour_layout to, struct bitmap_colour_layout from) |
Swap colour component order. More... | |
static void | bitmap__format_convert_to_pma (int width, int height, uint8_t *buffer, size_t rowstride, struct bitmap_colour_layout to, struct bitmap_colour_layout from) |
Convert plain alpha to premultiplied alpha. More... | |
static void | bitmap__format_convert_from_pma (int width, int height, uint8_t *buffer, size_t rowstride, struct bitmap_colour_layout to, struct bitmap_colour_layout from) |
Convert from premultiplied alpha to plain alpha. More... | |
void | bitmap_format_convert (void *bitmap, const bitmap_fmt_t *fmt_from, const bitmap_fmt_t *fmt_to) |
Convert bitmap from one format to another. More... | |
bool | bitmap_test_opaque (void *bitmap) |
Test whether a bitmap is completely opaque (no transparency). More... | |
Variables | |
bitmap_fmt_t | bitmap_fmt |
The client bitmap format. More... | |
struct bitmap_colour_layout | bitmap_layout |
The client bitmap colour channel layout. More... | |
Internal core bitmap interface.
Definition in file bitmap.c.
|
inlinestatic |
Swap colour component order.
[in] | width | Bitmap width in pixels. |
[in] | height | Bitmap height in pixels. |
[in] | buffer | Pixel buffer. |
[in] | rowstride | Pixel buffer row stride in bytes. |
[in] | to | Pixel layout to convert to. |
[in] | from | Pixel layout to convert from. |
Definition at line 146 of file bitmap.c.
References buffer, from, height, to, and width.
Referenced by bitmap_format_convert().
|
inlinestatic |
Convert from premultiplied alpha to plain alpha.
[in] | width | Bitmap width in pixels. |
[in] | height | Bitmap height in pixels. |
[in] | buffer | Pixel buffer. |
[in] | rowstride | Pixel buffer row stride in bytes. |
[in] | to | Pixel layout to convert to. |
[in] | from | Pixel layout to convert from. |
Definition at line 233 of file bitmap.c.
References bitmap_colour_layout::a, bitmap_colour_layout::b, buffer, from, bitmap_colour_layout::g, height, bitmap_colour_layout::r, to, and width.
Referenced by bitmap_format_convert().
|
inlinestatic |
Convert plain alpha to premultiplied alpha.
[in] | width | Bitmap width in pixels. |
[in] | height | Bitmap height in pixels. |
[in] | buffer | Pixel buffer. |
[in] | rowstride | Pixel buffer row stride in bytes. |
[in] | to | Pixel layout to convert to. |
[in] | from | Pixel layout to convert from. |
Definition at line 183 of file bitmap.c.
References bitmap_colour_layout::a, bitmap_colour_layout::b, buffer, from, bitmap_colour_layout::g, height, bitmap_colour_layout::r, to, and width.
Referenced by bitmap_format_convert().
|
static |
Get the colour layout for the given bitmap format.
[in] | fmt | Pixel format to get channel layout for, |
Definition at line 50 of file bitmap.c.
References BITMAP_LAYOUT_A8B8G8R8, BITMAP_LAYOUT_A8R8G8B8, BITMAP_LAYOUT_B8G8R8A8, and BITMAP_LAYOUT_R8G8B8A8.
Referenced by bitmap_format_convert(), and bitmap_set_format().
|
static |
Get string for given pixel layout.
[in] | layout | The pixel layout to get string for, |
Definition at line 96 of file bitmap.c.
References BITMAP_LAYOUT_A8B8G8R8, BITMAP_LAYOUT_A8R8G8B8, BITMAP_LAYOUT_ABGR8888, BITMAP_LAYOUT_ARGB8888, BITMAP_LAYOUT_B8G8R8A8, BITMAP_LAYOUT_BGRA8888, BITMAP_LAYOUT_R8G8B8A8, and BITMAP_LAYOUT_RGBA8888.
Referenced by bitmap_set_format().
void bitmap_format_convert | ( | void * | bitmap, |
const bitmap_fmt_t * | from, | ||
const bitmap_fmt_t * | to | ||
) |
Convert bitmap from one format to another.
Note that both formats should be sanitised.
[in] | bitmap | The bitmap to convert. |
[in] | from | The current bitmap format specifier. |
[in] | to | The bitmap format to convert to. |
Definition at line 278 of file bitmap.c.
References netsurf_table::bitmap, bitmap__format_convert(), bitmap__format_convert_from_pma(), bitmap__format_convert_to_pma(), bitmap__get_colour_layout(), buffer, from, gui_bitmap_table::get_buffer, gui_bitmap_table::get_height, gui_bitmap_table::get_opaque, gui_bitmap_table::get_rowstride, gui_bitmap_table::get_width, guit, height, bitmap_fmt::layout, NSLOG, bitmap_fmt::pma, to, and width.
Referenced by bitmap_format_from_client(), and bitmap_format_to_client().
void bitmap_set_format | ( | const bitmap_fmt_t * | bitmap_format | ) |
Set client bitmap format.
Set this to ensure that the bitmaps decoded by the core are in the correct format for the front end.
[in] | bitmap_format | The bitmap format specification to set. |
Definition at line 118 of file bitmap.c.
References bitmap__get_colour_layout(), bitmap__layout_to_str(), bitmap_sanitise_bitmap_layout(), bitmap_fmt::layout, NSLOG, and bitmap_fmt::pma.
Referenced by ami_plot_ra_alloc(), and nsgtk_setup().
bool bitmap_test_opaque | ( | void * | bitmap | ) |
Test whether a bitmap is completely opaque (no transparency).
[in] | bitmap | The bitmap to test. |
Definition at line 316 of file bitmap.c.
References netsurf_table::bitmap, buffer, gui_bitmap_table::get_buffer, gui_bitmap_table::get_height, gui_bitmap_table::get_rowstride, gui_bitmap_table::get_width, guit, height, and width.
Referenced by ami_bitmap_from_datatype(), gif_create_gif_data(), nspng_convert(), and png_cache_convert().