Home

Tcl

Photo

画像データの入れ替えと更新

        // gets image handle.
        Tk_PhotoHandle pHandle = Tk_FindPhoto(interp, imageName);
        if (pHandle == 0) {
            Tcl_AppendResult(interp, "could not image[", imageName, "] information.", 0);
            return TCL_ERROR;
        }
         
        // gets image block from handle.
        Tk_PhotoImageBlock block
        Tk_PhotoGetImage(pHandle, block);
        /*
        block.width, block.height, block.pitch, block.pixelSize,
        block.pixelPtr
        block.offset[0], block.offset[1], block.offset[2], block.offset[3]
        */
         
        // pixel manipulation
         
        // put block to handle.
        Tk_PhotoPutBlock(interp, dhandle, &dblock, 0, 0, dblock.width, dblock.height, TK_PHOTO_COMPOSITE_SET);
         
        // update
        const Tk_ImageType* imgType = 0;
        ClientData imgdata = Tk_GetImageMasterData( interp, imageName, &imgType );
        Tk_ImageMaster* master = (Tk_ImageMaster*)imgdata;
        Tk_ImageChanged(*master, 0, 0, block.width, block.height, block.width, block.height);