Results 1 to 2 of 2

Thread: Issue with QImage::loadFromData.

  1. #1
    Join Date
    Jun 2013
    Posts
    1
    Qt products
    Qt4

    Default Issue with QImage::loadFromData.

    Hi All,

    I am working on a blackberry application. Developing Blacberry 10 OS apps is based on Qt. I am processing image data with the following method

    Qt Code:
    1. #include "ImageProcessor.hpp"
    2.  
    3. ImageProcessor::ImageProcessor(const QByteArray &imageData, QObject *parent) :
    4. QObject(parent), m_data(imageData) {
    5. }
    6.  
    7. void ImageProcessor::start() {
    8. QImage image;
    9.  
    10. //QByteArray img_32bit = m_data.repeated(4);
    11. image.loadFromData(m_data); //QImage::Format_Indexed8
    12.  
    13.  
    14. image = image.scaled(256, 256, Qt::KeepAspectRatioByExpanding);
    15.  
    16. // Image processing goes here, example could be adding water mark to the downloaded image
    17.  
    18. emit finished(image);
    19. }
    To copy to clipboard, switch view to plain text mode 

    My images all appear black. After debuging, i noticed m_data contain this bytes

    m_data
    Details:"\211PNG\\r\\n\\032\\n" = {[0] = -119 '\211', [1] = 80 'P', [2] = 78 'N', [3] = 71 'G', [4] = 13 '\\r', [5] = 10 '\\n', [6] = 26 '\\032', [7] = 10 '\\n', [8] = 0 '\\000', [9] = 0 '\\000', [10] = 0 '\\000', [11] = 13 '\\r', [12] = 73 'I', [13] = 72 'H', [14] = 68 'D', [15] = 82 'R', [16] = 0 '\\000', [17] = 0 '\\000', [18] = 1 '\\001', [19] = 0 '\\000', [20] = 0 '\\000', [21] = 0 '\\000', [22] = 1 '\\001', [23] = 0 '\\000', [24] = 8 '\\b', [25] = 3 '\\003', [26] = 0 '\\000', [27] = 0 '\\000', [28] = 0 '\\000', [29] = 107 'k', [30] = -84 '\254', [31] = 88 'X', [32] = 84 'T', [33] = 0 '\\000', [34] = 0 '\\000', [35] = 0 '\\000', [36] = 6 '\\006', [37] = 80 'P', [38] = 76 'L', [39] = 84 'T', [40] = 69 'E', [41] = -71 '\271', [42] = -49 '\317', [43] = -21 '\353', [44] = -1 '\\377', [45] = -1 '\\377', [46] = -1 '\\377', [47] = -14 '\362', [48] = 39 '\\'', [49] = 100 'd', [50] = 83 'S', [51] = 0 '\\000', [52] = 0 '\\000', [53] = 0 '\\000', [54] = 84 'T', [55] = 73 'I', [56] = 68 'D', [57] = 65 'A', [58] = 84 'T', [59] = 24 '\\030', [60] = 25 '\\031', [61] = -19 '\355', [62] = -63 '\301', [63] = 1 '\\001', [64] = 1 '\\001', [65] = 0 '\\000', [66] = 0 '\\000', [67] = 0 '\\000', [68] = -128 '\\200', [69] = -112 '\\220', [70] = -2 '\376', [71] = -81 '\257', [72] = -18 '\356', [73] = 8 '\\b', [74] = 10 '\\n', [75] = 0 '\\000', [76] = 0 '\\000', [77] = 0 '\\000', [78] = 0 '\\000', [79] = 0 '\\000', [80] = 0 '\\000', [81] = 0 '\\000', [82] = 0 '\\000', [83] = 0 '\\000', [84] = 0 '\\000', [85] = 0 '\\000', [86] = 0 '\\000', [87] = 0 '\\000', [88] = 0 '\\000', [89] = 0 '\\000', [90] = 0 '\\000', [91] = 0 '\\000', [92] = 0 '\\000', [93] = 0 '\\000', [94] = 0 '\\000', [95] = 0 '\\000', [96] = 0 '\\000', [97] = 0 '\\000', [98] = 0 '\\000', [99] = 0 '\\000', [100] = 0 '\\000', [101] = 0 '\\000', [102] = 0 '\\000', [103] = 0 '\\000', [104] = 0 '\\000', [105] = 0 '\\000', [106] = 0 '\\000', [107] = 0 '\\000', [108] = 0 '\\000', [109] = 0 '\\000', [110] = 0 '\\000', [111] = 0 '\\000', [112] = 0 '\\000', [113] = 0 '\\000', [114] = 0 '\\000', [115] = 0 '\\000', [116] = 0 '\\000', [117] = 0 '\\000', [118] = 0 '\\000', [119] = 0 '\\000', [120] = 0 '\\000', [121] = 0 '\\000', [122] = 0 '\\000', [123] = 0 '\\000', [124] = 0 '\\000', [125] = 0 '\\000', [126] = 0 '\\000', [127] = 0 '\\000', [128] = 0 '\\000', [129] = 0 '\\000', [130] = 0 '\\000', [131] = 0 '\\000', [132] = 0 '\\000', [133] = 0 '\\000', [134] = 0 '\\000', [135] = 0 '\\000', [136] = 0 '\\000', [137] = 0 '\\000', [138] = 24 '\\030', [139] = 1 '\\001', [140] = 15 '\\017', [141] = 0 '\\000', [142] = 1 '\\001', [143] = -84 '\254', [144] = -14 '\362', [145] = 112 'p', [146] = -78 '\262', [147] = 0 '\\000', [148] = 0 '\\000', [149] = 0 '\\000', [150] = 0 '\\000', [151] = 73 'I', [152] = 69 'E', [153] = 78 'N', [154] = 68 'D', [155] = -82 '\256', [156] = 66 'B', [157] = 96 '`', [158] = -126 '\202'}
    Default:{...}

    can someone help explain to me what is wrong and how to go about it.

    Thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Issue with QImage::loadFromData.

    Is loadFromData() returning true?
    Is your original PNG file exactly 159 bytes long?
    Is your original PNG file valid?
    Does the BB version of the Qt libraries have PNG support? (look at QImageReader::supportedImageFormats())
    Does it work if you explicitly set the data type as "PNG"?

    Is the image valid immediately after successful loading?

    Can you post your PNG file somewhere we could get it?

Similar Threads

  1. QImage.loadFromData won't work
    By cil in forum Qt Programming
    Replies: 2
    Last Post: 18th April 2011, 17:22
  2. loadFromData() of QImage crash in case of .gif loading
    By santosh.kumar in forum Qt Programming
    Replies: 11
    Last Post: 9th March 2011, 12:52
  3. QImage loadFromData
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 22nd March 2008, 19:57
  4. QImage::loadFromData() behaviour
    By Caius Aérobus in forum Qt Programming
    Replies: 10
    Last Post: 29th November 2007, 22:21
  5. QImage loadFromData not run... XPDF data
    By patrik08 in forum Qt Programming
    Replies: 7
    Last Post: 24th April 2007, 12:51

Tags for this Thread

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.