]> mj.ucw.cz Git - libucw.git/blobdiff - images/alpha.c
some corrections in ImageSim config section
[libucw.git] / images / alpha.c
index f3a85c354a39eff48c0307bf7b461a9a19040066..d97207e8cb4c54589a37186ae94f595624684e58 100644 (file)
@@ -7,7 +7,7 @@
  *     of the GNU Lesser General Public License.
  */
 
-#define LOCAL_DEBUG
+#undef LOCAL_DEBUG
 
 #include "lib/lib.h"
 #include "images/images.h"
@@ -20,7 +20,7 @@ merge_func(uns value, uns alpha, uns acoef, uns bcoef)
 }
 
 int
-image_apply_background(struct image_thread *thread UNUSED, struct image *dest, struct image *src, struct color *background)
+image_apply_background(struct image_context *ctx UNUSED, struct image *dest, struct image *src, struct color *background)
 {
   DBG("image_apply_background()");
 
@@ -29,7 +29,10 @@ image_apply_background(struct image_thread *thread UNUSED, struct image *dest, s
     {
       ASSERT(dest->pixel_size == 1);
       byte bg;
-      color_put_grayscale(&bg, background);
+      if (background->color_space)
+        color_put_grayscale(&bg, background);
+      else
+       bg = 0;
       uns a = 255 * bg, b = bg;
 #     define IMAGE_WALK_PREFIX(x) walk_##x
 #     define IMAGE_WALK_INLINE
@@ -48,7 +51,10 @@ image_apply_background(struct image_thread *thread UNUSED, struct image *dest, s
     {
       ASSERT((src->flags & IMAGE_ALPHA) && dest->pixel_size >= 3 && !(dest->flags & IMAGE_ALPHA));
       byte bg[3];
-      color_put_rgb(bg, background);
+      if (background->color_space)
+        color_put_rgb(bg, background);
+      else
+       bg[0] = bg[1] = bg[2] = 0;
       uns a0 = 255 * bg[0], b0 = bg[0];
       uns a1 = 255 * bg[1], b1 = bg[1];
       uns a2 = 255 * bg[2], b2 = bg[2];