From 11ef2e4432c2a674da4f1bf9ead97308b32275d1 Mon Sep 17 00:00:00 2001 From: Jacob Boerema Date: Tue, 7 Jun 2022 18:41:00 -0400 Subject: [PATCH] plug-ins: move static variables for grayscale mapping to the top In preparation of using some of them earlier, we move the variables used for grayscale mapping of 1, 2 and 4-bit per pixel images to the top of file-tiff-load. --- plug-ins/file-tiff/file-tiff-load.c | 75 +++++++++++++++-------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c index 5d3c39ca81..22faca72eb 100644 --- a/plug-ins/file-tiff/file-tiff-load.c +++ b/plug-ins/file-tiff/file-tiff-load.c @@ -154,6 +154,44 @@ static gboolean load_dialog (TIFF *tif, DefaultExtra *default_extra); +/* Grayscale conversion mappings */ +static const guchar _1_to_8_bitmap [2] = +{ + 0, 255 +}; + +static const guchar _1_to_8_bitmap_rev [2] = +{ + 255, 0 +}; + +static const guchar _2_to_8_bitmap [4] = +{ + 0, 85, 170, 255 +}; + +static const guchar _2_to_8_bitmap_rev [4] = +{ + 255, 170, 85, 0 +}; + +static const guchar _4_to_8_bitmap [16] = +{ + 0, 17, 34, 51, 68, 85, 102, 119, + 136, 153, 170, 187, 204, 221, 238, 255 +}; + +static const guchar _4_to_8_bitmap_rev [16] = +{ + 255, 238, 221, 204, 187, 170, 153, 136, + 119, 102, 85, 68, 51, 34, 17, 0 +}; + +static guchar bit2byte[256 * 8]; +static guchar _2bit2byte[256 * 4]; +static guchar _4bit2byte[256 * 2]; + + /* returns a pointer into the TIFF */ static const gchar * tiff_get_page_name (TIFF *tif) @@ -2255,43 +2293,6 @@ load_separate (TIFF *tif, g_free (bw_buffer); } - -static guchar bit2byte[256 * 8]; -static guchar _2bit2byte[256 * 4]; -static guchar _4bit2byte[256 * 2]; - -static const guchar _1_to_8_bitmap [2] = -{ - 0, 255 -}; - -static const guchar _1_to_8_bitmap_rev [2] = -{ - 255, 0 -}; - -static const guchar _2_to_8_bitmap [4] = -{ - 0, 85, 170, 255 -}; - -static const guchar _2_to_8_bitmap_rev [4] = -{ - 255, 170, 85, 0 -}; - -static const guchar _4_to_8_bitmap [16] = -{ - 0, 17, 34, 51, 68, 85, 102, 119, - 136, 153, 170, 187, 204, 221, 238, 255 -}; - -static const guchar _4_to_8_bitmap_rev [16] = -{ - 255, 238, 221, 204, 187, 170, 153, 136, - 119, 102, 85, 68, 51, 34, 17, 0 -}; - static void fill_bit2byte (TiffColorMode tiff_mode) {