04-05-2025, 01:24 PM
(04-04-2025, 09:09 PM)TheInstinct Wrote: Hi everybody,
I'm facing a serious problem when porting a plugin I wrote in Gimp 2.10 to Gimp 3.0 in python.
In Gimp 2, I used the following way to the color index of each pixel. It works very well:
pixels contains the index of the color [0;255] which is a byte.Code:
layer = img.layers[0]
region = layer.get_pixel_rgn(0, 0, img.width, img.height, False, False)
pixels = array("B", region[0:img.width, 0:img.height])
In Gimp 3, you can get access to color information of the layer by using layer.get_buffer(...) but you won't get the color index as you must provide a Babl format. So you will get a color, or luminance in the format you selected "RGB u8" for example, but you won't get the indexes of the colors used by each pixel.
I made research but can't find how to get color index of each pixel. I hope some of you will be able to help me.
Thank you in advance for your support.
Can you show you current Gimp3 code?