![]() |
Endianess of pixel data in a Python region for gimp 2.10. - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: Endianess of pixel data in a Python region for gimp 2.10. (/Thread-Endianess-of-pixel-data-in-a-Python-region-for-gimp-2-10) |
Endianess of pixel data in a Python region for gimp 2.10. - teapot - 07-14-2025 For gimp 2.10, is my understanding correct? Given a region's bytes from a layer ‘l’: r = l.get_pixel_rgn(0, 0, w, h) rb = r[:, :] I think rb will hold the bytes of the channel's values in the machine's native endianess because: - a region maps onto tiles, - getting the tile's pixels uses a simple memcpy(), and - a tile's pixels are in the native endianess. I'm aware tile data in an XCF file is big-endian from https://testing.developer.gimp.org/core/standards/xcf/#tile-data-organization But I'm interested in what's in memory and guaranteed to be seen through slicing a Python region into a string of bytes. RE: Endianess of pixel data in a Python region for gimp 2.10. - Ofnuts - 07-14-2025 In my code it appears that I assume it's R,G,B. Worrying about endianness would imply that you expect values in data types bigger than bytes? RE: Endianess of pixel data in a Python region for gimp 2.10. - teapot - 07-14-2025 Hi Ofnuts, Yes, that's right. The image's precision can be integers or floats of 16 or 32 bits. RE: Endianess of pixel data in a Python region for gimp 2.10. - Ofnuts - 07-14-2025 (07-14-2025, 05:52 PM)teapot Wrote: Hi Ofnuts, Yes, that's right. The image's precision can be integers or floats of 16 or 32 bits. OK, so
Code: ➤> rgn=image.active_layer.get_pixel_rgn(0,0,10,10) |