Results 1 to 6 of 6

Thread: how to load a Qt non-supported Image format

  1. #1
    Join Date
    Apr 2008
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how to load a Qt non-supported Image format

    I wated to load a 'tiff' image as a background image in the widget.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to load a Qt non-supported Image format

    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:
    Qt Code:
    1. qDebug() << QImageReader::supportedImageFormats();
    To copy to clipboard, switch view to plain text mode 
    output?
    J-P Nurmi

  3. #3
    Join Date
    Apr 2008
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy Re: how to load a Qt non-supported Image format

    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".

  4. #4
    Join Date
    Apr 2008
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to load a Qt non-supported Image format

    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.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to load a Qt non-supported Image format

    For unsupported formats you will need to provide an image format plugin.
    J-P Nurmi

  6. #6
    Join Date
    Apr 2008
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to load a Qt non-supported Image format

    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:

    Qt Code:
    1. pafScanline = (uchar *) CPLMalloc(xsize * ysize * 4);
    2. Q_CHECK_PTR(pafScanline);
    3. for (int i = 1; i <= 3; ++i) { // R G B
    4. GDALRasterBand *poBand;
    5. poBand = m_dataset->GetRasterBand(i);
    6. Q_CHECK_PTR(poBand);
    7. static int smap[4] = { 0, 2, 1, 0 };
    8. if (poBand->RasterIO(GF_Read, x_off, y_off, xsize, ysize,
    9. pafScanline + smap[i], xsize, ysize, GDT_Byte,
    10. 4, xsize * 4) == CE_Failure) {
    11. throw gException(QString("RasterIO error:%1").
    12. arg(CPLGetLastErrorMsg()));
    13. }
    14. }
    15. QImage *result = new QImage(xsize, ysize, QImage::Format_RGB32);
    16. Q_CHECK_PTR(result);
    17. for (int y = 0; y < ysize; ++y) {
    18. QRgb *sLine = (QRgb *) result->scanLine(y);
    19. memcpy(sLine, pafScanline + y * xsize * 4, xsize * 4);
    20. }
    21. CPLFree(pafScanline);
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to Vladd for this useful post:

    Nithya (9th April 2008)

Similar Threads

  1. [Qt4] How to load Url image into QImage?
    By Gonzalez in forum Qt Programming
    Replies: 6
    Last Post: 13th October 2014, 10:10
  2. Some very weird compilation warnings
    By MarkoSan in forum Qt Programming
    Replies: 21
    Last Post: 23rd January 2008, 16:48
  3. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.