I am a little lost. I am writing a script in python that gets a screen shot view:
M = view.viewport_trans().mag
res = 0.1
# grab an image
w, h = view.viewport_width()/M/res, view.viewport_height()/M/res
qImg = view.get_image(w, h)
Now I need to get the pixel values from qImg. I saw some online posts doing something like this:
But this gives me an error:
'utf-8' codec can't decode byte 0xff in position 0: invalid start byte in QImage_Native.bits
What am I doing wrong? How can I get the pixel values?
Thank you so much for your help!!
The Qt documentation available on the net should tell more about this.
"qImg.bits" will give you the raw bits. There is no "byte array" in Ruby apart from strings and that is pretty useless for this purpose.
A good way should be to use "qImg.pixel(x, y)" which renders a 32bit value representing a RGB triplet.
But please note that image processing in Ruby may be painfully slow.