Hej!

>+                 sum += pixels[x+c+y*rowstride];

Det virker ikke:

1) x i lookup skal ganges med channels.
2) Hvis channels > 3 regner du alpha med.



Regards, Klaus Post

http://www.klauspost.com


On Mon, Sep 3, 2012 at 10:12 PM, Anders Kvist <[email protected]> wrote:

> Author: akv
> Date: 2012-09-03 22:12:47 +0200 (Mon, 03 Sep 2012)
> New Revision: 4276
>
> Modified:
>    branches/4175-enfuse/src/rs-enfuse.c
> Log:
> Rewrote pixelcalculation in calculate_lightness().
>
> Modified: branches/4175-enfuse/src/rs-enfuse.c
> ===================================================================
> --- branches/4175-enfuse/src/rs-enfuse.c        2012-09-03 19:16:14 UTC
> (rev 4275)
> +++ branches/4175-enfuse/src/rs-enfuse.c        2012-09-03 20:12:47 UTC
> (rev 4276)
> @@ -60,19 +60,27 @@
>        guchar *pixels = gdk_pixbuf_get_pixels(pixbuf);
>        gint rowstride = gdk_pixbuf_get_rowstride(pixbuf);
>        gint height = gdk_pixbuf_get_height(pixbuf);
> +      gint width = gdk_pixbuf_get_width(pixbuf);
> +      gint channels = gdk_pixbuf_get_n_channels(pixbuf);
>
> -      gint i;
> +      gint x,y,c;
>        gulong sum = 0;
>        gint num = 0;
>
> -      for (i = 0; i<rowstride*height; i++)
> -       {
> -         sum += pixels[i];
> -         num++;
> +      for (y = 0; y < height; y++)
> +        {
> +         for (x = 0; x < width; x++)
> +           {
> +             for (c = 0; c < channels; c++)
> +               {
> +                 sum += pixels[x+c+y*rowstride];
> +               }
> +           }
>         }
>
>        g_object_unref(pixbuf);
>
> +      num = width*height*channels;
>        return (gint) (sum/num);
>  }
>
>
>
> _______________________________________________
> Rawstudio-commit mailing list
> [email protected]
> http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit
>
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to