00037 {
00038
00039 QImage origImage( filename );
00040
00041
00042
if( origImage.depth() < 32 ) { origImage = origImage.convertDepth( 32, Qt::AutoColor ); }
00043
00044
00045 QImage* croppedImage =
new QImage(
bottomRight.x() -
topLeft.x() + 1,
00046
bottomRight.y() -
topLeft.y() + 1,
00047 origImage.depth());
00048
00049
00050
int xOrig, yOrig;
00051
int xCropped, yCropped;
00052 uchar *origScanLine, *croppedScanLine;
00053
00054
for( yOrig=
topLeft.y(),yCropped=0; yOrig<=
bottomRight.y(); yOrig++, yCropped++)
00055 {
00056
00057 origScanLine = origImage.scanLine(yOrig);
00058 croppedScanLine = croppedImage->scanLine(yCropped);
00059
00060
for( xOrig=
topLeft.x(),xCropped=0; xOrig<=
bottomRight.x(); xOrig++,xCropped++)
00061 {
00062
00063 *((QRgb*)croppedScanLine+xCropped) = *((QRgb*)origScanLine+xOrig);
00064 }
00065 }
00066
00067
00068
return croppedImage;
00069 }