#include QImage rotateRgb(const QImage &in) { QImage out(in.size(), in.format()); //QImage out(in.size(), in.format()); for(int line = 0; line < in.height(); line++) { //const QRgb* inPixels = reinterpret_cast(in.scanLine(line)); //QRgb* outPixels = reinterpret_cast(out.scanLine(line)); for(int pos = 0; pos < in.width(); pos++) { char red = qRed(in.pixel(line, pos)); char green = qGreen(in.pixel(line, pos)); char blue = qBlue(in.pixel(line, pos)); char alpha = qAlpha(in.pixel(line, pos)); //qDebug() << QColor(inPixels[pos]); //QRgb outpix = qRgba(red, green, blue, alpha); //outPixels[pos] = outpix; out.setPixel(line, pos, qRgba(red, green, blue, alpha)); } } return out; } int main(int argc, char* argv[]) { QApplication app(argc, argv); QImage img("qt.png"); QLabel rgb; img = rotateRgb(img); QLabel brg; brg.setPixmap(QPixmap::fromImage(img)); img = rotateRgb(img); QLabel grb; grb.setPixmap(QPixmap::fromImage(img)); img = rotateRgb(img); rgb.setPixmap(QPixmap::fromImage(img)); rgb.show(); brg.show(); grb.show(); return app.exec(); }