I wated to load a 'tiff' image as a background image in the widget.
Printable View
I wated to load a 'tiff' image as a background image in the widget.
Which version of Qt are you using? As far as I remember, TIFF is supported since Qt 4.3. However, you will have to build the plugin if it's not already built. What does:
output?
I'm using Qt 4.2.2.And it doesnot support "tiff"
The list of supported formats are only
"bmp", "jpeg", "jpg", "mng", "pbm", "pgm", "png", "ppm", "svg", "xbm", "xpm".
I am now trying with TiffIO plugin to load the Tiff.But I need a general solution to load any kind of non-supported format.Because I have to load dgn format and many other map formats to be loaded.
For unsupported formats you will need to provide an image format plugin.
I am loading map image using GDAL library. Do this not by plugin. You can see this on https://sourceforge.net/projects/kmapexplorer, file gimgview.cpp function GImgLoader::loadTile.
Map are usually big and program load image block only when request come.
Here code:
Code:
pafScanline = (uchar *) CPLMalloc(xsize * ysize * 4); Q_CHECK_PTR(pafScanline); for (int i = 1; i <= 3; ++i) { // R G B GDALRasterBand *poBand; poBand = m_dataset->GetRasterBand(i); Q_CHECK_PTR(poBand); static int smap[4] = { 0, 2, 1, 0 }; if (poBand->RasterIO(GF_Read, x_off, y_off, xsize, ysize, pafScanline + smap[i], xsize, ysize, GDT_Byte, 4, xsize * 4) == CE_Failure) { arg(CPLGetLastErrorMsg())); } } Q_CHECK_PTR(result); for (int y = 0; y < ysize; ++y) { QRgb *sLine = (QRgb *) result->scanLine(y); memcpy(sLine, pafScanline + y * xsize * 4, xsize * 4); } CPLFree(pafScanline);