[Gimp-developer] Need help with Python plugin exporting to raw file (using Gimp 2.9)

I'm using Gimp 2.9 experimental build, which I downloaded from 
partha.com, to specifically have edit ability with 16-bit per channel 
images.  I originally posted in gimpforums.com and was told I should try here.

I'm trying to write a Python plugin to export an image as a raw file 
(just data, no header).  The current option to export as raw image data 
(File -> Export as -> Raw image data) seems to only support writing out as 8-bit even when the image precision
 is greater than 8-bit.  So I wanted to write a plugin so I could export
 my 16-bit per channel image to a raw file with the 16-bit data 

My image is a 16-bit grayscale 3x3 image with a checkerboard pattern of alternating white and black pixels.

I used the sample script 'test-discolour-layer-v4.py' from http://registry.gimp.org/node/28124
 as a guide on how to iterate through every pixel.  I have some 
questions and ran into some problems.  What I have so far can be seen here (http://pastebin.com/U49VZYVT).  
It just iterates through the pixels and outputs values to the 
error console.

1. How do I query for the precision?  That is, I want to know if the 
current image is 8-bit gamma integer, or 16-bit linear integer, or 
something else.  I looked at the image object's attributes and didn't 
find anything.

2. When I get the pixel value from srcTile[x,y], the value is always 
8-bit.  With the white pixels, the value should be 65535 but I got 255.  How do I get the 
proper value?  When I use the Color Picker tool with info window, it says 65535 for white.  How do I get that 

3. My code creates a new layer from visible and then queries the pixels from that.  In my image, all values 
returned are 255 even for the black pixels.  When I put my checkboard pattern on the Background layer and 
query that layer, I get correct values (though in 8-bit).  For any other layer other than Background, the 
values are always 255.  I don't know what I'm doing wrong.  

Can someone help me or point me in the right direction?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]