It is currently 27 Sep 2020, 22:53

• Featuring Members' Works (Image Attachments) •
1: member
2: member
3: member
4: member
5: member

GIMP/GL:  Tutorials | Tips | 🡆 Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Creating an indexed image - working with Pixel Regions

GIMP or GIMP LEARN forum related Questions
Janek
Forum Member

Creating an indexed image - working with Pixel Regions

Post#1 by Janek » 03 Mar 2019, 16:31


Hi,

I'm working on a plugin written in python that aims to import a format of file not natively supported by GIMP. This file uses indexed colors. I've been able to set the colormap properly but I don't know how to set the values of the layer in an easy way as it is done using C language:
gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, drawable->width, drawable->height, TRUE, FALSE);
gimp_pixel_rgn_set_rect(&pixel_rgn, buf, 0, 0, drawable->width, drawable->height);
The first line initiate pixels region. the second one associate buf content to the pixels region. Each value of buf corresponds to an index of the colormap.

I'd like to know how I have to proceed in python to do the same thing.

I hope you'll be able to help.
GIMP Learn rocks...
0

Janek
Forum Member

Post#2 by Janek » 03 Mar 2019, 16:43


I progress and so I wanted to share this with you. It sounds like I must use method that are part of the LAYER type. As an example I can use:

region = layer.get_pixel_rgn(0, 0, img_width, img_height, False, False)

So I have another question. Is there somewhere a documentation in which I can consult method that are part of each type?
GIMP Learn rocks...
0

tim
GL Blogger

Post#3 by tim » 03 Mar 2019, 16:51


I have worked with pixel region before and I always had trouble when I worked with it and always had to look things up.
Maybe this will help: http://gimpbook.com/scripting/slides/pixelrgns.html

To see methods of each type like layer:
I open up GIMP. then Filters/Python-Fu/Console
and use this in the console
image = gimp.image_list()[0]
layer = image.layers[0]
then
dir(layer)
will show you all methods that layer has.
but it doesn't tell you what parameters it needs so I usually google for the method name and some key word like GIMP or Python-Fu and something usually shows up or I just try using the method in the console or guess what parameters it needs usually it's the similar to a method shown in procedure browser of GIMP (Help/Procedure Browser) with less parameters
for example if you're using layer.some_method then you don't need to pass in the layer as parameter anymore so usually it has less parameters than some methods shown in Procedure Browser.
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

Janek
Forum Member

Post#4 by Janek » 03 Mar 2019, 17:26


Thank you very much tim. Your link includes exactly what I was looking for.

Also thank you for the tip to get method inside a type. Marvelous.
GIMP Learn rocks...
1

tim
GL Blogger

Post#5 by tim » 03 Mar 2019, 17:34


Glad that helped you.
Welcome to GL.
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

tim
GL Blogger

Post#6 by tim » 04 Mar 2019, 16:05


I split your question under different topic here
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

Janek
Forum Member

Post#7 by Janek » 05 Mar 2019, 17:58


Seen that. Ty
GIMP Learn rocks...
0


GIMP/GL:  Tutorials | Tips | 🡆 Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 9 guests