exr-load/save: for now, only do associated alpha in EXRs

Not sure if this is *always* correct, it probably most of the time is
and could be manually separated in the cases where it might be wrong
to load as associated.
parent 35bc6f69
Pipeline #88170 passed with stages
in 17 minutes and 18 seconds
......@@ -559,10 +559,19 @@ query_exr (const gchar *path,
(NULL, c2.white[0], c2.white[1], c2.red[0], c2.red[1], c2.green[0], c2.green[1], c2.blue[0], c2.blue[1], babl_trc ("sRGB"), babl_trc ("sRGB"), babl_trc ("sRGB"), BABL_SPACE_FLAG_EQUALIZE);
}
if (ch.findChannel ("A"))
{
format_flags |= COLOR_ALPHA;
}
if (ch.findChannel ("R") || ch.findChannel ("G") || ch.findChannel ("B"))
{
strcpy (format_string, "RGB");
format_flags = COLOR_RGB;
if (format_flags & COLOR_ALPHA)
strcpy (format_string, "RaGaBa");
else
strcpy (format_string, "RGB");
format_flags |= COLOR_RGB;
if ((chan = ch.findChannel ("R")))
pt = chan->type;
......@@ -574,15 +583,21 @@ query_exr (const gchar *path,
else if (ch.findChannel ("Y") &&
(ch.findChannel("RY") || ch.findChannel("BY")))
{
strcpy (format_string, "RGB");
format_flags = COLOR_Y | COLOR_C;
if (format_flags & COLOR_ALPHA)
strcpy (format_string, "RaGaBa");
else
strcpy (format_string, "RGB");
format_flags |= COLOR_Y | COLOR_C;
pt = ch.findChannel ("Y")->type;
}
else if (ch.findChannel ("Y"))
{
strcpy (format_string, "Y");
format_flags = COLOR_Y;
if (format_flags & COLOR_ALPHA)
strcpy (format_string, "Ya");
else
strcpy (format_string, "Y");
format_flags |= COLOR_Y;
pt = ch.findChannel ("Y")->type;
}
else
......@@ -591,11 +606,8 @@ query_exr (const gchar *path,
return FALSE;
}
if (ch.findChannel ("A"))
{
strcat (format_string, "A");
format_flags |= COLOR_ALPHA;
}
if (format_flags & COLOR_ALPHA)
strcat (format_string, "A");
switch (pt)
{
......
......@@ -243,16 +243,16 @@ gegl_exr_save_process (GeglOperation *operation,
*/
const Babl *original_format = gegl_buffer_get_format (input);
const Babl *original_space = babl_format_get_space (original_format);
unsigned depth = babl_format_get_n_components (original_format);
unsigned n_components = babl_format_get_n_components (original_format);
switch (depth)
switch (n_components)
{
case 1: output_format = "Y float"; break;
case 2: output_format = "YA float"; break;
case 3: output_format = "RGB float"; break;
case 4: output_format = "RGBA float"; break;
case 1: output_format = "Y float"; break;
case 2: output_format = "YaA float"; break;
case 3: output_format = "RGB float"; break;
case 4: output_format = "RaGaBaA float"; break;
default:
g_warning ("exr-save: cannot write exr with depth %d.", depth);
g_warning ("exr-save: cannot write exr with n_components %d.", n_components);
return FALSE;
break;
}
......@@ -262,11 +262,11 @@ gegl_exr_save_process (GeglOperation *operation,
* can set the origin.
*/
float *pixels
= (float *) g_malloc (rect->width * rect->height * depth * sizeof *pixels);
= (float *) g_malloc (rect->width * rect->height * n_components * sizeof *pixels);
if (pixels == 0)
{
g_warning ("exr-save: could allocate %d*%d*%d pixels.",
rect->width, rect->height, depth);
rect->width, rect->height, n_components);
return FALSE;
}
......@@ -277,7 +277,7 @@ gegl_exr_save_process (GeglOperation *operation,
try
{
exr_save_process (pixels, original_space, rect->width, rect->height,
depth, tile_size, filename);
n_components, tile_size, filename);
status = TRUE;
}
catch (std::exception &e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment