Changeset View
Changeset View
Standalone View
Standalone View
src/imageformats/rgb.cpp
Context not available. | |||||
313 | } | 313 | } | ||
---|---|---|---|---|---|
314 | 314 | | |||
315 | img = QImage(_xsize, _ysize, QImage::Format_RGB32); | 315 | img = QImage(_xsize, _ysize, QImage::Format_RGB32); | ||
316 | if (img.isNull()) { | ||||
317 | qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(_xsize, _ysize); | ||||
318 | return false; | ||||
319 | } | ||||
316 | 320 | | |||
317 | if (_zsize == 0 ) | 321 | if (_zsize == 0 ) | ||
318 | return false; | 322 | return false; | ||
Context not available. | |||||
470 | uint len; | 474 | uint len; | ||
471 | 475 | | |||
472 | for (y = 0; y < _ysize; y++) { | 476 | for (y = 0; y < _ysize; y++) { | ||
473 | c = reinterpret_cast<const QRgb *>(img.scanLine(_ysize - y - 1)); | 477 | const int yPos = _ysize - y - 1; // scanline doesn't do any sanity checking | ||
478 | if (yPos >= img.height()) { | ||||
479 | qWarning() << "Failed to get scanline for" << yPos; | ||||
480 | return false; | ||||
481 | } | ||||
482 | | ||||
483 | c = reinterpret_cast<const QRgb *>(img.scanLine(yPos)); | ||||
484 | | ||||
474 | for (x = 0; x < _xsize; x++) { | 485 | for (x = 0; x < _xsize; x++) { | ||
475 | buf[x] = intensity(qRed(*c++)); | 486 | buf[x] = intensity(qRed(*c++)); | ||
476 | } | 487 | } | ||
Context not available. | |||||
484 | 495 | | |||
485 | if (_zsize != 2) { | 496 | if (_zsize != 2) { | ||
486 | for (y = 0; y < _ysize; y++) { | 497 | for (y = 0; y < _ysize; y++) { | ||
487 | c = reinterpret_cast<const QRgb *>(img.scanLine(_ysize - y - 1)); | 498 | const int yPos = _ysize - y - 1; | ||
499 | if (yPos >= img.height()) { | ||||
500 | qWarning() << "Failed to get scanline for" << yPos; | ||||
501 | return false; | ||||
502 | } | ||||
503 | | ||||
504 | c = reinterpret_cast<const QRgb *>(img.scanLine(yPos)); | ||||
488 | for (x = 0; x < _xsize; x++) { | 505 | for (x = 0; x < _xsize; x++) { | ||
489 | buf[x] = intensity(qGreen(*c++)); | 506 | buf[x] = intensity(qGreen(*c++)); | ||
490 | } | 507 | } | ||
Context not available. | |||||
493 | } | 510 | } | ||
494 | 511 | | |||
495 | for (y = 0; y < _ysize; y++) { | 512 | for (y = 0; y < _ysize; y++) { | ||
496 | c = reinterpret_cast<const QRgb *>(img.scanLine(_ysize - y - 1)); | 513 | const int yPos = _ysize - y - 1; | ||
514 | if (yPos >= img.height()) { | ||||
515 | qWarning() << "Failed to get scanline for" << yPos; | ||||
516 | return false; | ||||
517 | } | ||||
518 | | ||||
519 | c = reinterpret_cast<const QRgb *>(img.scanLine(yPos)); | ||||
497 | for (x = 0; x < _xsize; x++) { | 520 | for (x = 0; x < _xsize; x++) { | ||
498 | buf[x] = intensity(qBlue(*c++)); | 521 | buf[x] = intensity(qBlue(*c++)); | ||
499 | } | 522 | } | ||
Context not available. | |||||
507 | } | 530 | } | ||
508 | 531 | | |||
509 | for (y = 0; y < _ysize; y++) { | 532 | for (y = 0; y < _ysize; y++) { | ||
510 | c = reinterpret_cast<const QRgb *>(img.scanLine(_ysize - y - 1)); | 533 | const int yPos = _ysize - y - 1; | ||
534 | if (yPos >= img.height()) { | ||||
535 | qWarning() << "Failed to get scanline for" << yPos; | ||||
536 | return false; | ||||
537 | } | ||||
538 | | ||||
539 | c = reinterpret_cast<const QRgb *>(img.scanLine(yPos)); | ||||
511 | for (x = 0; x < _xsize; x++) { | 540 | for (x = 0; x < _xsize; x++) { | ||
512 | buf[x] = intensity(qAlpha(*c++)); | 541 | buf[x] = intensity(qAlpha(*c++)); | ||
513 | } | 542 | } | ||
Context not available. |