00061 {
00062
00063 QImage*
editedImage =
new QImage( filename );
00064
00065
00066
if(
editedImage->depth() < 32 )
00067 {
00068 QImage* tmp =
editedImage;
00069
editedImage =
new QImage( tmp->convertDepth( 32, Qt::AutoColor ) );
00070
delete tmp; tmp=NULL;
00071 }
00072
00073
00074
bool useBusyIndicators =
false;
00075
StatusWidget*
status = NULL;
00076
if( options != NULL && options->
getStatus() != NULL )
00077 {
00078 useBusyIndicators =
true;
00079
status = options->
getStatus();
00080 }
00081
00082
00083
if(useBusyIndicators)
00084 {
00085 QString statusMessage = qApp->translate(
"blackWhiteEffect",
"Applying Black + White Effect:" );
00086
status->
showProgressBar( statusMessage, 100 );
00087 qApp->processEvents();
00088 }
00089
00090
00091
const int updateIncrement = (
int) ( 0.01 *
editedImage->width() *
editedImage->height() );
00092
int newProgress = 0;
00093
00094
00095
int x, y, grayValue;
00096 QRgb* rgb;
00097 uchar* scanLine;
00098
for( y=0; y<
editedImage->height(); y++)
00099 {
00100
00101 scanLine =
editedImage->scanLine(y);
00102
for( x=0; x<
editedImage->width(); x++)
00103 {
00104
00105 rgb = ((QRgb*)scanLine+x);
00106 grayValue = (
int) (0.2125*qRed(*rgb) + 0.7154*qGreen(*rgb) + 0.0721*qBlue(*rgb));
00107
00108
00109 grayValue = QMIN( QMAX( grayValue, 0 ), 255 );
00110
00111
00112 *rgb = qRgb( grayValue, grayValue, grayValue );
00113
00114
00115
if(useBusyIndicators)
00116 {
00117
newProgress++;
00118
if(
newProgress >=
updateIncrement)
00119 {
00120
newProgress = 0;
00121
status->
incrementProgress();
00122 qApp->processEvents();
00123 }
00124 }
00125
00126 }
00127 }
00128
00129
00130
return editedImage;
00131 }