re: pixbuf color count



Counting unique colors in a GtkPixbuf should be pretty
easy once you know how to access the pixels as an
array. The put_pixel() example here gives you
everthing you need to know for that:
http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html

Seems like finding unique colors would be just
accessing the pixel array as ints, to compare each int
to those in a linked-list you'd make to hold every
unique int you'd found so-far.

if you only want to see if there are more than two or
three colors, then you can even skip the linked list.

===================================
    * From: Kevin DeKorte <kdekorte gmail com>
    * To: gtk-app-devel-list gnome org
    * Subject: pixbuf color count
    * Date: Mon, 01 Oct 2007 10:49:06 -0600

-----BEGIN PGP SIGNED MESSAGE-----
Hello,

Once I have loaded a pixbuf using

gdk_pixbuf_new_from_file(filename, &error);

Is there a way to get the number of unique colors in
that pixbuf. I
looked at the docs for ColorMap and it says it only
applies to pseudo
color images, but I'm not even sure how that would
apply in this case.

Basically, I just want to know if the image has only a
couple of colors
in it or more.

Thanks,

Kevin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]