22 #define UNUSED __attribute__((unused))
25 void **output, uint32 *output_length)
27 TIFF *tif = TIFFOpen(filename,
"r");
33 TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
34 TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
35 cout <<
"wh: " << width <<
" " << height << endl;
37 int npixels = width * height;
38 int length = npixels *
sizeof (uint32);
39 uint32* raster = (uint32*) malloc(length);
40 assert(raster != NULL);
42 int rc = TIFFReadRGBAImage(tif, width, height, raster, 0);
48 *output_length = length;
54 int objc, Tcl_Obj *
const objv[])
58 char *filename = Tcl_GetString(objv[1]);
59 Tcl_Obj *pointer = objv[2];
60 Tcl_Obj *length = objv[3];
64 bool rc =
tiff_read(filename, &output, &bytes);
68 Tcl_ObjSetVar2(interp, pointer, NULL, Tcl_NewLongObj((
long)output), 0);
69 Tcl_ObjSetVar2(interp, length, NULL, Tcl_NewIntObj((
int)bytes), 0);
static bool tiff_read(char *filename, void **output, uint32 *output_length)
int Cctwtcltiff_Read_Cmd(UNUSED ClientData clientData, UNUSED Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])