[babl] palette: initialize with 8bit fast path buffer
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] palette: initialize with 8bit fast path buffer
- Date: Sun, 18 Mar 2012 13:11:27 +0000 (UTC)
commit 5945aea4b04d90274e263731cde180bf4d3fafd9
Author: Ãyvind KolÃs <pippin gimp org>
Date: Sun Mar 18 02:52:00 2012 +0000
palette: initialize with 8bit fast path buffer
babl/babl-palette.c | 4 +++-
tests/palette.c | 33 +++++++++++++++++++++++++++------
2 files changed, 30 insertions(+), 7 deletions(-)
---
diff --git a/babl/babl-palette.c b/babl/babl-palette.c
index a904eb8..3b0c84c 100644
--- a/babl/babl-palette.c
+++ b/babl/babl-palette.c
@@ -44,6 +44,8 @@ static BablPalette *make_pal (Babl *format, void *data, int count)
memcpy (pal->data, data, bpp * count);
babl_process (babl_fish (format, babl_format ("RGBA double")),
pal->data, pal->data_double, count);
+ babl_process (babl_fish (format, babl_format ("RGBA u8")),
+ pal->data, pal->data_u8, count);
return pal;
}
@@ -108,7 +110,6 @@ rgba_to_pal (char *src,
void *dst_model_data)
{
BablPalette *pal = dst_model_data;
-
while (n--)
{
int idx;
@@ -343,6 +344,7 @@ Babl *babl_new_palette (const char *name, int with_alpha)
babl_type ("u8"),
babl_component ("I"), NULL);
+if(1)
babl_conversion_new (
format,
babl_format ("RGBA u8"),
diff --git a/tests/palette.c b/tests/palette.c
index afd52f9..7dbf74f 100644
--- a/tests/palette.c
+++ b/tests/palette.c
@@ -54,7 +54,6 @@ main (int argc,
{
int OK = 1;
babl_init ();
-
{
unsigned char in[][1] = {{ 0},{ 1},{ 2},{15}};
unsigned char out[][4] = {{0,0,0,255},{127,0,0,255},{0,127,0,255},{255,255,255,255}};
@@ -65,6 +64,7 @@ main (int argc,
palA, babl_format("RGBA u8"),
in, out);
+
CHECK_CONV("pal to rgba", unsigned char,
palB, babl_format("RGBA u8"),
in, out);
@@ -92,7 +92,7 @@ main (int argc,
in, out);
}
- /* check with a custom floating point palette */
+ /* check with a custom floating point palette, _and_ alpha component */
{
float palette[] = {
0.5, 1.0,
@@ -100,18 +100,19 @@ main (int argc,
1.0, 0.2
};
- unsigned char in[][1] = {{ 0},{ 1},{ 2}};
- unsigned char out[][4] = {{128,128,128,255},{59,59,59,107},{255,255,255,51}};
+ unsigned char in[][2] = {{ 0,255},{0,127},{ 1,255},{ 2,255}};
+ unsigned char out[][4] = {{128,128,128,255},{128,128,128,127},{59,59,59,107},{255,255,255,51}};
- Babl *pal = babl_new_palette (NULL, 0);
+ Babl *pal = babl_new_palette (NULL, 1);
babl_palette_set_palette (pal, babl_format ("YA float"), palette, 3);
- CHECK_CONV("rgba to YA float pal", unsigned char,
+ CHECK_CONV("rgba to YA float pal+alpha", unsigned char,
pal, babl_format("RGBA u8"),
in, out);
}
+
/* check with a custom floating point palette, _and_ alpha component */
{
float palette[] = {
@@ -132,6 +133,26 @@ main (int argc,
in, out);
}
+ /* check with a custom floating point palette */
+ {
+ float palette[] = {
+ 0.5, 1.0,
+ 0.23, 0.42,
+ 1.0, 0.2
+ };
+
+ unsigned char in[][1] = {{ 0},{ 1},{ 2}};
+ unsigned char out[][4] = {{128,128,128,255},{59,59,59,107},{255,255,255,51}};
+
+ Babl *pal = babl_new_palette (NULL, 0);
+
+ babl_palette_set_palette (pal, babl_format ("YA float"), palette, 3);
+
+ CHECK_CONV("rgba to float pal", unsigned char,
+ pal, babl_format("RGBA u8"),
+ in, out);
+ }
+
babl_exit ();
return !OK;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]