summaryrefslogtreecommitdiff
path: root/desktop/bitmap.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2022-03-26 15:36:55 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2022-03-27 09:58:21 +0100
commitc69bc8ba9ceeb5096a2312fb74176f49e8d3a5f8 (patch)
treed2d2a1ff6302917bcb1682439e9cb057c58257b6 /desktop/bitmap.c
parent05a0a6997eca876230e9230375ef8601c5cdcfa3 (diff)
downloadnetsurf-c69bc8ba9ceeb5096a2312fb74176f49e8d3a5f8.tar.gz
Bitmap: Colour layout converter doesn't need to be exposed.
Diffstat (limited to 'desktop/bitmap.c')
-rw-r--r--desktop/bitmap.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/desktop/bitmap.c b/desktop/bitmap.c
index 4977f7a0a..a78057631 100644
--- a/desktop/bitmap.c
+++ b/desktop/bitmap.c
@@ -41,6 +41,52 @@ struct bitmap_colour_layout bitmap_layout = {
.a = 3,
};
+/**
+ * Get the colour layout for the given bitmap format.
+ *
+ * \param[in] fmt Pixel format to get channel layout for,
+ * \return channel layout structure.
+ */
+static struct bitmap_colour_layout bitmap__get_colour_layout(
+ const bitmap_fmt_t *fmt)
+{
+ switch (fmt->layout) {
+ default:
+ /* Fall through. */
+ case BITMAP_LAYOUT_R8G8B8A8:
+ return (struct bitmap_colour_layout) {
+ .r = 0,
+ .g = 1,
+ .b = 2,
+ .a = 3,
+ };
+
+ case BITMAP_LAYOUT_B8G8R8A8:
+ return (struct bitmap_colour_layout) {
+ .b = 0,
+ .g = 1,
+ .r = 2,
+ .a = 3,
+ };
+
+ case BITMAP_LAYOUT_A8R8G8B8:
+ return (struct bitmap_colour_layout) {
+ .a = 0,
+ .r = 1,
+ .g = 2,
+ .b = 3,
+ };
+
+ case BITMAP_LAYOUT_A8B8G8R8:
+ return (struct bitmap_colour_layout) {
+ .a = 0,
+ .b = 1,
+ .g = 2,
+ .r = 3,
+ };
+ }
+}
+
/* Exported function, documented in include/netsurf/bitmap.h */
void bitmap_set_format(const bitmap_fmt_t *bitmap_format)
{