I've written a python program using GTK+2 (pygtk). Now I want to update the program to GTK+3, so I have to use pyGObject instead of pygtk.
My problem is, that I have to get the color from individual pixels on a GdkPixbuf.Pixbuf object.
In pygtk i could just use Pixbuf.get_pixels_array() to get a n array containing all the pixels.
In pyGObject there is no Pixbuf.get_pixels_array(), so I have to use Pixbuf.get_pixels(), which returns me a string.
Does anyone know how to get individual pixels from this string?
(In C Pixbuf.get_pixels_array() returns a pointer, so you can do this: http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#image-data , but in python it returns a string)
Thanks for helping.
Python PyGObject Get pixel from GdkPixbuf.get_pixels()
1.5k Views Asked by freundTech At
2
There are 2 best solutions below
0
am70
On
In my answer to question How to turn Gdk pixbuf object into numpy array you may find two functions that convert from GdxPixbuf to numpy arrays, and back; once you have data into numpy arrays, it is much easier to manipulate them
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in PYGTK
- python, gtk and opengl: render after mouseclick
- How to loop through open Gtk.Windows?
- How to re-draw (refresh, update, replace) container in GTK3?
- Appliction command line int option with value 0 not availible
- Is it possible to use other widget in the tab lable other than Gtk.Label?
- How to change differnt treeviews headers different colors
- How to use a socket as the pty in libvte?
- How to selectively apply different stylesheets in GTK application (python)?
- How to add some index or ID to object or function?
- Apperance settings not staying as set
- show popup window from a thread pygtk make GUI freeze
- PyGObject Scroll to bottom of ScrolledWindow() after adding row to child TreeView
- replacement of get_data and set_data in pygtk3
- PyGTK calculator
- PyGtk with Gtk+3 gives illegal instruction 4
Related Questions in GTK3
- Why does GTK beep when calling `gtk_entry_set_text` (while resizing a window)?
- Django deployment with GTK3
- How to set transparent background for gtk_plug_new window
- Convert Wand image to GTK image
- how do I change the alpha channel along a path in cairo?
- GtkScrolledWindow not aware of scrollable WebKit2.WebView content
- GdkCursor is randomly resetting to default with wglContext and gtk3
- Gstreaming from GTK Python application and sychronously displaying the stream
- Resize window while maintaining aspect ratio
- Rust and GTK Text Editor: Troubleshooting Undo and Redo Operations with Shared Data
- Problems compiling GTK3
- error to convert a gtk2 application with drag and drop to gtk3 (python)
- GTK3: GtkIconView: Is it possible to style the selected cell, which have the cursor focus, differently than other selected cells?
- Sharing variables between closures in GTK Rust
- How do I get VSCode to recognise my GTK installation?
Related Questions in PYGOBJECT
- Preparing metadata (pyproject.toml)
- Installing gst-python in macOS
- Setting GStreamer custom logging from Python triggers Segmentation fault
- How do I set the position of a item in a Gtk Stack?
- How to install PyGObject with a specific version of GLib?
- Python 3: How do I assert that the value of a gobject.GParamSpec is of a particular type?
- Popup windows for every new connection
- Appliction command line int option with value 0 not availible
- Is it possible to use other widget in the tab lable other than Gtk.Label?
- How do you solve no matching distribution found for kivy_deps.gstreamer_dev~=0.3.3 in mingw64?
- How to build a undo-redo function for rich text on Gtk4
- Python GI repository: cannot import name Flatpak, introspection typelib not found
- Replacing udpsrc with appsrc in Gstreamer pipe
- How to reproduce visual division of pages with Gtk.TextView
- Can't build a Python Docker container on Raspberry Pi
Related Questions in PIXBUF
- Not easily debuggable crash on GDK at Gdk::Cairo::set_source_pixbuf()
- Creating an Async Image Gtk3 Rust
- GTK: How can I fix this problem: Could not load a pixbuf from /org/gtk/libgtk/icons/16x16/status/image-missing.png
- GTK - Python Getting Difference Between Pixbuf Images
- bitmap is loaded mirrored and inverted
- Something faster than Python's multiprocessing.Process for screen recording in OS X?
- GdkPixbuf : is it possible to change the data without instancing a new Pixbuf?
- GdkPixbuf can be created with `new_from_data` and `new_from_stream`. Why doesn't the latter require the resolution?
- playing a video by retrieving and manipulating frame by frame: is creating a new pixbuf at every frame the way to go or is there an easier way?
- is there some documentation on all methods of PixBuf, especially replace_data? (gtk3)
- Can a GDK Pixbuf be rotated by something less than 90 degrees?
- GTK# Pixbuf Icon in TreeView
- Improve OCR of image without scaling (using PIL, pixbuf)?
- Why are Gdk::Pixbufs not visible in Gtk::TreeView?
- How to load GdkPixbuf from file in a callback function?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It is not a string, it is a byte array. You may get values (int) like from list: mybyte[2:4]; if you print this, yes, the chr() values are show. Be careful at image type and check the length of the „string”: for a png you have 4 values (RGBA) per pixel, for a 'RGB' jpeg - 3, for 'L' - 1. The values are in range 0-255, as usual. P.S: the values are not splited in bands, so pixel 1 from jpg has RGB at index 0,1,2 pixel 2 at 3,4,5 and so on