Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

crop.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

QImage * cropImage (QString filename, QPoint topLeft, QPoint bottomRight)


Function Documentation

QImage* cropImage QString  filename,
QPoint  topLeft,
QPoint  bottomRight
 

Definition at line 36 of file crop.cpp.

References bottomRight, and topLeft.

Referenced by EditingInterface::crop().

00037 {
00038   //load original image
00039   QImage origImage( filename );
00040   
00041   //construct cropped image
00042   QImage* croppedImage = new QImage(bottomRight.x() - topLeft.x() + 1, 
00043                                     bottomRight.y() - topLeft.y() + 1,
00044                                     origImage.depth());  
00045   
00046   //iterate over each selected scanline 
00047   int xOrig, yOrig;
00048   int xCropped, yCropped;
00049   uchar *origScanLine, *croppedScanLine;
00050   
00051   for( yOrig=topLeft.y(),yCropped=0;    yOrig<=bottomRight.y();     yOrig++, yCropped++)
00052   {   
00053     //iterate over each selected pixel in scanline
00054     origScanLine    = origImage.scanLine(yOrig);
00055     croppedScanLine = croppedImage->scanLine(yCropped);
00056     
00057     for( xOrig=topLeft.x(),xCropped=0; xOrig<=bottomRight.x(); xOrig++,xCropped++)
00058     {
00059       //copy pixel color from original image to cropped image
00060       *((QRgb*)croppedScanLine+xCropped) = *((QRgb*)origScanLine+xOrig);      
00061     }
00062   }
00063   
00064   //return pointer to cropped image
00065   return croppedImage;  
00066 }


Generated on Sat Apr 2 05:44:14 2005 for AlbumShaper by  doxygen 1.3.9.1