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
Code:
#include "ImageProcessor.hpp"
QObject(parent
), m_data
(imageData
) { }
void ImageProcessor::start() {
//QByteArray img_32bit = m_data.repeated(4);
image.loadFromData(m_data); //QImage::Format_Indexed8
image = image.scaled(256, 256, Qt::KeepAspectRatioByExpanding);
// Image processing goes here, example could be adding water mark to the downloaded image
emit finished(image);
}
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 :)
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?