1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| void MainWindow::readFile()
{
char* emsg =new char[1024];
int count = 0;
if(tif == NULL)
{
fprintf(stderr, "tif == NULL\n");
return;
}
if(TIFFRGBAImageBegin(&img, tif, 0, emsg))
{
do{
readTiff(count);
count ++;
}while(TIFFReadDirectory(img.tif));
}
else
{
TIFFError(pathName.toStdString().c_str(), emsg);
return;
}
TIFFRGBAImageEnd(&img);
qDebug("teds");
delete[] emsg;
}
void MainWindow::readTiff(int count){
uint32* raster;
size_t npixels;
int imgwidth, imgheight;
npixels = img.width * img.height;
raster = (uint32 *) _TIFFmalloc(npixels * sizeof(uint32));
if(raster != NULL)
{
if(TIFFRGBAImageGet(&img, raster, img.width, img.height) == 0)
{
//TIFFError(pathName.toStdString().c_str(), emsg);
return;
}
}
imgwidth = img.width;
imgheight = img.height;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imgwidth, imgheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, raster);
ui->widget->setGlTex(texture,imgwidth, imgheight);
_TIFFfree(raster);
} |
Partager