Changeset View
Changeset View
Standalone View
Standalone View
src/imageformats/psd.cpp
Context not available. | |||||
171 | channel_num = 4; | 171 | channel_num = 4; | ||
---|---|---|---|---|---|
172 | } | 172 | } | ||
173 | img = QImage(header.width, header.height, fmt); | 173 | img = QImage(header.width, header.height, fmt); | ||
174 | if (img.isNull()) { | ||||
175 | qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width, header.height); | ||||
176 | return false; | ||||
177 | } | ||||
174 | img.fill(qRgb(0,0,0)); | 178 | img.fill(qRgb(0,0,0)); | ||
175 | 179 | | |||
176 | const quint32 pixel_count = header.height * header.width; | 180 | const quint32 pixel_count = header.height * header.width; | ||
177 | 181 | | |||
182 | // Verify this, as this is used to write into the memory of the QImage | ||||
183 | if (pixel_count > img.sizeInBytes() / sizeof(QRgb)) { | ||||
184 | qWarning() << "Invalid pixel count!" << pixel_count << "bytes available:" << img.sizeInBytes(); | ||||
185 | return false; | ||||
186 | } | ||||
187 | | ||||
178 | QRgb *image_data = reinterpret_cast<QRgb*>(img.bits()); | 188 | QRgb *image_data = reinterpret_cast<QRgb*>(img.bits()); | ||
179 | 189 | | |||
180 | if (!image_data) { | 190 | if (!image_data) { | ||
Context not available. | |||||
276 | 286 | | |||
277 | char head[4]; | 287 | char head[4]; | ||
278 | qint64 readBytes = device->read(head, sizeof(head)); | 288 | qint64 readBytes = device->read(head, sizeof(head)); | ||
289 | if (readBytes < 0) { | ||||
290 | qWarning() << "Read failed" << device->errorString(); | ||||
291 | return false; | ||||
292 | } | ||||
293 | | ||||
279 | if (readBytes != sizeof(head)) { | 294 | if (readBytes != sizeof(head)) { | ||
280 | if (device->isSequential()) { | 295 | if (device->isSequential()) { | ||
281 | while (readBytes > 0) { | 296 | while (readBytes > 0) { | ||
Context not available. |