Hi All.

I found some doubtful example code on EFL Programming guide.
(https://www.enlightenment.org/program_guide/evas/image_objects)

We can notify that result(blur) image is too much spread only horizontally,
  when if set higher value to "blur_size".
Because, calculation about average color is used recursively.
(calc result is re-used for calc in 6th and 7th for loop)

So, I fixed the example code.
If I fixed by incorrect way, please fix again.

Regards.
Jiwon Kim.

========================================================
void image_blur(Evas_Object *img)
{
   unsigned char *img_src = evas_object_image_data_get(img, EINA_TRUE);

   int w, h;
   evas_object_image_size_get(img, &w, &h);
   int blur_size = 4;
   int x, y, xx, yy;

   for (y = 0; y < h; y++)
   {
      for (x = 0; x < w; x++)
      {
         int avg_color[3] = {0, 0, 0};
         int blur_pixel_cnt = 0;

         for (xx = x; (xx < x + blur_size) && (xx < w); xx++)
         {
            for (yy = y; (yy < y + blur_size) && (yy < h); yy++)
            {
               int idx = (yy * w * 4) + (xx * 4);
               avg_color[0] += img_src[idx + 0];
               avg_color[1] += img_src[idx + 1];
               avg_color[2] += img_src[idx + 2];
               ++blur_pixel_cnt;
            }
         }
         avg_color[0] /= blur_pixel_cnt;
         avg_color[1] /= blur_pixel_cnt;
         avg_color[2] /= blur_pixel_cnt;

*         // Fixed newly*
         int idx = (y * w * 4) + (x * 4);
         img_src[idx + 0] = avg_color[0];
         img_src[idx + 1] = avg_color[1];
         img_src[idx + 2] = avg_color[2];

*         // Removed*
*         for (xx = x; (xx < x + blur_size) && (xx < w); xx++)*
*         {*
*            for (yy = y; (yy < y + blur_size) && (yy < h); yy++)*
*            {*
*               int idx = (yy * w * 4) + (xx * 4);*
*               img_src[idx + 0] = avg_color[0];*
*               img_src[idx + 1] = avg_color[1];*
*               img_src[idx + 2] = avg_color[2];*
*            }*
*         }*
      }
   }
   evas_object_image_data_update_add(img, 0, 0, w, h);
}

========================================================
------------------------------------------------------------------------------
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to