58 for( y=0; y<image.height(); y++)
60 scanLine = image.scanLine(y);
61 for( x=0; x<image.width(); x++)
63 rgb = ((QRgb*)scanLine+x);
64 double r = ((double)qRed(*rgb) )/255.0;
65 double g = ((double)qGreen(*rgb) )/255.0;
66 double b = ((double)qBlue(*rgb) )/255.0;
73 meanR =
meanR / ( image.width() * image.height() );
74 meanG =
meanG / ( image.width() * image.height() );
75 meanB =
meanB / ( image.width() * image.height() );
93 "histogramInterface" );
101 histogramType =
new QComboBox( visibleFrame,
"histogramType" );
107 QToolTip::add(
histogramType, tr(
"Histogram channel displayed") );
110 QString noChange = QString( tr(
"No change") );
117 connect(
brightness, SIGNAL(valueChanged(
int)),
119 QToolTip::add(
brightness, tr(
"Drag to adjust image brightness") );
131 connect(
contrast, SIGNAL(valueChanged(
int)),
133 QToolTip::add(
contrast, tr(
"Drag to adjust image contrast") );
143 QPushButton* applyButton =
new QPushButton( tr(
"Apply"),
buttonsFrame );
144 applyButton->setDefault(
true);
145 applyButton->setFocus();
146 connect( applyButton, SIGNAL(clicked()), SLOT(
applyAction()) );
148 QPushButton* cancelButton =
new QPushButton( tr(
"Cancel"),
buttonsFrame );
149 connect( cancelButton, SIGNAL(clicked()), SLOT(reject()) );
151 QPushButton* resetButton =
new QPushButton( tr(
"Reset"),
buttonsFrame );
152 connect( resetButton, SIGNAL(clicked()), SLOT(
resetAction()) );
154 Q3GridLayout* buttonsGrid =
new Q3GridLayout(
buttonsFrame, 1, 5, 0 );
155 buttonsGrid->setColStretch( 0, 1 );
156 buttonsGrid->addWidget( applyButton, 0, 1 );
157 buttonsGrid->addWidget( cancelButton, 0, 2 );
158 buttonsGrid->addWidget( resetButton, 0, 3 );
159 buttonsGrid->setColStretch( 4, 1 );
162 Q3GridLayout* mainGrid =
new Q3GridLayout( visibleFrame, 5, 3, 0 );
165 mainGrid->addMultiCellWidget(
previewSelection, 1,1, 0,2, Qt::AlignHCenter );
169 mainGrid->addWidget(
contrast, 2, 2 );
174 mainGrid->addWidget(
histogramType, 3, 0, Qt::AlignHCenter );
180 mainGrid->setRowStretch( 0, 1 );
181 mainGrid->setColStretch( 0, 1 );
186 Q3GridLayout* invisibleGrid =
new Q3GridLayout(
this, 2, 1, 0 );
187 invisibleGrid->addWidget( visibleFrame, 0, 0 );
188 invisibleGrid->setRowStretch( 0, 1 );
194 QSizeGrip* sizeGrip =
new QSizeGrip(
this );
195 invisibleGrid->addWidget( sizeGrip, 1, 0, Qt::AlignRight | Qt::AlignBottom );
202 setCaption( tr(
"Histogram Editor") );
213 int lumLeft, lumRight, redLeft, redRight, greenLeft, greenRight, blueLeft, blueRight;
216 greenLeft, greenRight,
217 blueLeft, blueRight );
219 lumLeft != 0 || lumRight != 255 ||
220 redLeft !=0 || redRight != 255 ||
221 greenLeft != 0 || greenRight != 255 ||
222 blueLeft != 0 || blueRight != 255 )
306 int lumLeft, lumRight, redLeft, redRight, greenLeft, greenRight, blueLeft, blueRight;
311 greenLeft, greenRight,
312 blueLeft, blueRight );
316 lumLeft = 0; lumRight = 255;
317 redLeft = 0; redRight = 255;
318 greenLeft = 0; greenRight = 255;
319 blueLeft = 0; blueRight = 255;
323 double displayToOneScalar = 1.0/255.0;
324 double scaledMeanR = displayToOneScalar*
scaleColor( 255.0*
meanR, redLeft, redRight );
325 double scaledMeanG = displayToOneScalar*
scaleColor( 255.0*
meanG, greenLeft, greenRight );
326 double scaledMeanB = displayToOneScalar*
scaleColor( 255.0*
meanB, blueLeft, blueRight );
328 double brightnessScalar, addedBrightnessColor;
332 addedBrightnessColor = 1.0 - brightnessScalar;
337 addedBrightnessColor = 0.0;
344 int rPrime, gPrime, bPrime;
347 for( y=0; y<image.height(); y++)
349 scanLine = image.scanLine(y);
350 for( x=0; x<image.width(); x++)
353 rgb = ((QRgb*)scanLine+x);
368 r = r*displayToOneScalar;
369 g = g*displayToOneScalar;
370 b =
b*displayToOneScalar;
379 r = brightnessScalar*r + addedBrightnessColor;
380 g = brightnessScalar*g + addedBrightnessColor;
381 b = brightnessScalar*
b + addedBrightnessColor;
384 rPrime = (int)
MIN(
MAX((r*255), 0), 255 );
385 gPrime = (int)
MIN(
MAX((g*255), 0), 255 );
386 bPrime = (int)
MIN(
MAX((
b*255), 0), 255 );
389 *rgb = qRgb(rPrime, gPrime, bPrime);
void getHistBoundaries(int &lumLeft, int &lumRight, int &redLeft, int &redRight, int &greenLeft, int &greenRight, int &blueLeft, int &blueRight)
returns histogram boundaries
void getHistBoundaries(int &lumLeft, int &lumRight, int &redLeft, int &redRight, int &greenLeft, int &greenRight, int &blueLeft, int &blueRight)
returns histogram boundaries