[Image-SIG] PIL and ICC: littlecms?
Fredrik Lundh
fredrik@pythonware.com
Thu, 19 Dec 2002 10:13:39 +0100
kevin wrote:
> Well, I've managed to get things started
excellent!
> but have a couple problems related to accessing/modifying the image pixel
> data directly in my DLL... I don't think I'm using the right syntax... any help?
I've got no time to dig deeper into this right now, but the following note
discusses the ImagingObject/ImagingNew issues:
http://effbot.org/zone/pil-extending.htm
(in short, use a Python wrapper).
:::
> is this syntax correct for accessing the pixel data for read/write???
im->image[line] gives you a void pointer to a byte array that contains pixel
data for a line (row) of pixels. for colour images (im->mode == "RGB"), the
array contains four bytes per pixel:
"RGBXRGBXRGBX..."
assuming that the cms layer wants pointers to RGBX data, and that "1" you used
is the number of pixels to process, you could just use:
for (line = 0; line < im->ysize; line++)
cmsDoTransform(hTransform, im->image[line], imOut->image[line], im->xsize);
alternatively, to process a pixel at a time, use something like:
for (line = 0; line < im->ysize; line++) {
/* pick up line pointers */
char* in = im->image[line];
char* out = imOut->image[line];
for (i = 0; i < im->xsize; i++) {
cmsDoTransform(hTransform, in, out, 1);
in += 4; out += 4; /* four bytes per pixel */
}
}
hope this helps!
</F>