QImage convertToGray(QImage &img){ QImage converted = img; QRgb col; int gray; int width = img.width(); int height = img.height();\ for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { col = img.pixel(i, j); gray = qGray(col); converted.setPixel(i, j, qRgb(gray, gray, gray)); } } return converted.convertToFormat(QImage::Format_Indexed8);}
C++ (Qt)QImage convertToGray(const QImage &img)
C++ (Qt) return converted.convertToFormat(QImage::Format_Indexed8);
QTransform trans = QTransform().translate(cent.x(), cent.y()).rotate(-_rotat).translate(-cent.x(), -cent.y());QImage targImg = sourceImg.transformed(trans);
targImg = targImg.scaled(128,128, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
QImage target =convertToGray(source).convertToFormat(QImage::Format_RGB32). convertToFormat(QImage::Format_Indexed8);