gegl: add GEGL_BABL_VARIANT_ALPHA

parent 196898b8
......@@ -123,6 +123,7 @@ gegl_babl_variant_get_type (void)
{ GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED, N_("Perceptual-premultiplied"), "perceptual-premultiplied"},
{ GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED_IF_ALPHA, N_("Linear-premultiplied-if-alpha"), "linear-premultiplied-if-alpha"},
{ GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED_IF_ALPHA, N_("Perceptual-premultiplied-if-alpha"), "perceptual-premultiplied-if-alpha"},
{ GEGL_BABL_VARIANT_ALPHA, N_("add-alpha"), "add-alpha"},
{ 0, NULL, NULL }
};
gint i;
......
......@@ -91,6 +91,8 @@ enum _GeglBablVariant
/* Y YaA RGB RaGaBaA */
GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED_IF_ALPHA,
/* Y~ Y~aA R~G~B~A R~aG~aB~aA */
GEGL_BABL_VARIANT_ALPHA
/* add alpha if missing keep as premultiplied if already so */
};
typedef enum _GeglBablVariant GeglBablVariant;
......
......@@ -108,7 +108,7 @@ gegl_create_chain_argv (char **ops,
if (error && *error)
{
GeglNode **an = (void*)error;
ret_sinkp = *an;
ret_sinkp = (void*)*an;
*error = NULL;
}
......
......@@ -327,6 +327,7 @@ static const Babl *gegl_babl_format_float (const Babl *format)
space = babl_format_get_space (format);
encoding = babl_format_get_encoding (format);
{
char *encdup = g_strdup (encoding);
char *newenc;
char *s = strrchr (encdup, ' ');
......@@ -336,9 +337,50 @@ static const Babl *gegl_babl_format_float (const Babl *format)
g_free (encdup);
g_free (newenc);
}
return format;
}
static const Babl *gegl_babl_format_alpha (const Babl *format)
{
const Babl *model = babl_format_get_model (format);
if (babl_get_model_flags (model) & BABL_MODEL_FLAG_ALPHA)
{
const Babl *type = babl_format_get_type (format, 0);
if (type == babl_type ("float"))
return format;
}
if (babl_model_is (model, "Y'"))
{
return babl_format_with_space ("Y'A float", format);
}
else if (babl_model_is (model, "Y"))
{
return babl_format_with_space ("YA float", format);
}
else if (babl_model_is (model, "RGB"))
{
return babl_format_with_space ("RGBA float", format);
}
else if (babl_model_is (model, "R'G'B'"))
{
return babl_format_with_space ("R'G'B'A float", format);
}
else if (babl_model_is (model, "cmyk") ||
babl_model_is (model, "CMYK") ||
babl_model_is (model, "CMYKA") ||
babl_model_is (model, "cmykaA") ||
babl_model_is (model, "CaMaYaKaA") ||
babl_model_is (model, "camayakaA"))
{
return babl_format_with_space ("cmykA float", format);
}
return babl_format_with_space ("RGBA float", format);
}
static const Babl *gegl_babl_format_float_premultiplied_linear_if_alpha (const Babl *format)
{
if (!format)
......@@ -363,6 +405,8 @@ const Babl *gegl_babl_variant (const Babl *format, GeglBablVariant variant)
return NULL;
switch (variant)
{
case GEGL_BABL_VARIANT_ALPHA:
return gegl_babl_format_alpha (format);
case GEGL_BABL_VARIANT_FLOAT:
return gegl_babl_format_float (format);
case GEGL_BABL_VARIANT_LINEAR:
......
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