https://bugs.kde.org/show_bug.cgi?id=344287
--- Comment #4 from Mikhail Kandel <kand...@illinois.edu> --- I read them where T=float: static TIFFImage<T> readBuffer(const char* fname)//deallocate with { TIFF* tif = TIFFOpen(fname, "r");//tiff open catch error? assert(tif); int imgH, imgW; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imgH); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imgW); int rowsize = imgW*sizeof(T); auto mydata = (unsigned char*)malloc(rowsize*imgH); for (int row = 0; row < imgH; row++) { auto toMe = (void*)&mydata[rowsize*row]; TIFFReadScanline(tif, toMe, row); } TIFFClose(tif); TIFFImage<T> s; s.c = imgW; s.r = imgH; s.img = (T*)mydata; return s; } write them like static void writeTiffFast(const char* name, const void* buffer, unsigned int w, unsigned int h, bool isfloat, bool fast=false, const TiffExtraMetaData* meta = nullptr) { assert((w>0) && (h > 0)); TIFF* tif = TIFFOpen(name, "w");//quality error correcting code TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, w); // set the width of the image TIFFSetField(tif, TIFFTAG_IMAGELENGTH, h); // set the height of the image TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); // set number of channels per pixel TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); TIFFSetField(tif, TIFFTAG_SOFTWARE, "QLI SLIM5"); TIFFSetField(tif, TIFFTAG_MAKE, "Mikhail Kandel"); if (meta!=nullptr) { TIFFSetField(tif, TIFFTAG_DATETIME, meta->datetime); } else { //get default meta data; TiffExtraMetaData defaulto; TIFFSetField(tif, TIFFTAG_DATETIME, defaulto.datetime); } TIFFSetField(tif, TIFFTAG_MODEL, __DATE__); int rowsize = 0; if (isfloat) { //todo write a LUT //TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8 * sizeof(float)); // set the size of the channels TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); // set number of channels per pixel rowsize = w*sizeof(float); } else { TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8 * sizeof(unsigned short)); // set the size of the channels TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); // set number of channels per pixel rowsize = w*sizeof(unsigned short); } if (fast) //if (0) //todo make this work ? { TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, h); int bytesize = rowsize*h; TIFFWriteRawStrip(tif, 1, (void*)buffer, bytesize); } else { TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); for (unsigned int r = 0; r < h; r++)//'r' for row { auto aschar = (unsigned char*)buffer; auto data = &aschar[rowsize*r]; TIFFWriteScanline(tif, data, r); } } TIFFClose(tif); } -- You are receiving this mail because: You are the assignee for the bug. _______________________________________________ Okular-devel mailing list Okular-devel@kde.org https://mail.kde.org/mailman/listinfo/okular-devel