39 QImage origImage( filename );
42 if( origImage.depth() < 32 ) { origImage = origImage.convertDepth( 32, Qt::AutoColor ); }
45 QImage* croppedImage =
new QImage(bottomRight.x() - topLeft.x() + 1,
46 bottomRight.y() - topLeft.y() + 1,
51 int xCropped, yCropped;
52 uchar *origScanLine, *croppedScanLine;
54 for( yOrig=topLeft.y(),yCropped=0; yOrig<=bottomRight.y(); yOrig++, yCropped++)
57 origScanLine = origImage.scanLine(yOrig);
58 croppedScanLine = croppedImage->scanLine(yCropped);
60 for( xOrig=topLeft.x(),xCropped=0; xOrig<=bottomRight.x(); xOrig++,xCropped++)
63 *((QRgb*)croppedScanLine+xCropped) = *((QRgb*)origScanLine+xOrig);
QImage * cropImage(QString filename, QPoint topLeft, QPoint bottomRight)