00055 {
00056
00057 QImage*
editedImage =
new QImage( filename );
00058
00059
00060
if(
editedImage->depth() < 32 )
00061 {
00062 QImage* tmp =
editedImage;
00063
editedImage =
new QImage( tmp->convertDepth( 32, Qt::AutoColor ) );
00064
delete tmp; tmp=NULL;
00065 }
00066
00067
00068
bool useBusyIndicators =
false;
00069
StatusWidget*
status = NULL;
00070
if( options != NULL && options->
getStatus() != NULL )
00071 {
00072 useBusyIndicators =
true;
00073
status = options->
getStatus();
00074 }
00075
00076
00077
if(useBusyIndicators)
00078 {
00079 QString statusMessage = qApp->translate(
"sepiaEffect",
"Applying Sepia Effect:" );
00080
status->
showProgressBar( statusMessage, 100 );
00081 qApp->processEvents();
00082 }
00083
00084
00085
const int updateIncrement = (
int) ( 0.01 *
editedImage->width() *
editedImage->height() );
00086
int newProgress = 0;
00087
00088
00089
int sepiaH, sepiaS, sepiaL;
00090 QColor(162,128,101).getHsv( &sepiaH, &sepiaS, &sepiaL );
00091
00092
00093
int x, y, pixelLuminance;
00094 QRgb* rgb;
00095 QColor sepiaColor;
00096 uchar* scanLine;
00097
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 pixelLuminance = (
int) (0.2125*qRed(*rgb) + 0.7154*qGreen(*rgb) + 0.0721*qBlue(*rgb));
00107
00108
00109 sepiaColor.setHsv( sepiaH, sepiaS, pixelLuminance );
00110 *rgb = sepiaColor.rgb();
00111
00112
00113
if(useBusyIndicators)
00114 {
00115
newProgress++;
00116
if(
newProgress >=
updateIncrement)
00117 {
00118
newProgress = 0;
00119
status->
incrementProgress();
00120 qApp->processEvents();
00121 }
00122 }
00123
00124 }
00125 }
00126
00127
00128
return editedImage;
00129 }