#include <assert.h>
#include <inttypes.h>
#include <iostream>
#include <stdlib.h>
#include <tiffio.h>
#include <tiffio.hxx>
#include <tcl.h>
#include "cctwtcltiff.h"
Go to the source code of this file.
|
#define | UNUSED __attribute__((unused)) |
|
#define UNUSED __attribute__((unused)) |
int Cctwtcltiff_Read_Cmd |
( |
UNUSED ClientData |
clientData, |
|
|
UNUSED Tcl_Interp * |
interp, |
|
|
int |
objc, |
|
|
Tcl_Obj *const |
objv[] |
|
) |
| |
Definition at line 52 of file cctwtcltiff.cpp.
References tiff_read().
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)
static bool tiff_read |
( |
char * |
filename, |
|
|
void ** |
output, |
|
|
uint32 * |
output_length |
|
) |
| |
|
static |
Definition at line 24 of file cctwtcltiff.cpp.
Referenced by Cctwtcltiff_Read_Cmd().
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;