Updated 2014-06-30 12:16:08 by RLE

Tk Library command to set the data of a photo image type:

Man Page Tk8.6

  Source data without alpha channel

HaO 2014-06-30 What I did not find in the man page is how to copy source data which does not have any alpha channel.

By inspection of some examples and the Tk source code (tkImgPhoto.c from Tk8.5) :
 if (alphaOffset == 0) {
* This is the non-alpha case, so can still be fairly
* fast. Note that in the non-alpha-source case, the
* compositing rule doesn't apply.

I suppose, that setting the pixel size to 3 and the alpha offset to 0 implicitly says "no alpha".

So, a program example with source data rgbrgbrgb (from zint_tcl):
 Tk_PhotoImageBlock sImageBlock;
sImageBlock.pixelPtr = hSymbol->bitmap;
sImageBlock.width = hSymbol->bitmap_width;
sImageBlock.height = hSymbol->bitmap_height;
sImageBlock.pitch = 3*hSymbol->bitmap_width;
sImageBlock.pixelSize = 3;
sImageBlock.offset[0] = 0;
sImageBlock.offset[1] = 1;
sImageBlock.offset[2] = 2;
sImageBlock.offset[3] = 0;
if (TCL_OK != Tk_PhotoPutBlock(interp, hPhoto, &sImageBlock,
destX0, destY0, destWidth, destHeight,
fError = 1;