-rw-r--r-- | libopie2/opiemm/oimagescrollview.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libopie2/opiemm/oimagescrollview.cpp b/libopie2/opiemm/oimagescrollview.cpp index 10da823..76f50e1 100644 --- a/libopie2/opiemm/oimagescrollview.cpp +++ b/libopie2/opiemm/oimagescrollview.cpp | |||
@@ -184,48 +184,49 @@ void OImageScrollView::setAutoRotate(bool how) | |||
184 | m_states.setBit(AUTO_ROTATE,how); | 184 | m_states.setBit(AUTO_ROTATE,how); |
185 | _image_data = QImage(); | 185 | _image_data = QImage(); |
186 | generateImage(); | 186 | generateImage(); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | bool OImageScrollView::AutoRotate()const | 190 | bool OImageScrollView::AutoRotate()const |
191 | { | 191 | { |
192 | return m_states.testBit(AUTO_ROTATE); | 192 | return m_states.testBit(AUTO_ROTATE); |
193 | } | 193 | } |
194 | 194 | ||
195 | void OImageScrollView::setAutoScaleRotate(bool scale, bool rotate) | 195 | void OImageScrollView::setAutoScaleRotate(bool scale, bool rotate) |
196 | { | 196 | { |
197 | m_states.setBit(AUTO_ROTATE,rotate); | 197 | m_states.setBit(AUTO_ROTATE,rotate); |
198 | setAutoScale(scale); | 198 | setAutoScale(scale); |
199 | } | 199 | } |
200 | 200 | ||
201 | void OImageScrollView::setAutoScale(bool how) | 201 | void OImageScrollView::setAutoScale(bool how) |
202 | { | 202 | { |
203 | m_states.setBit(AUTO_SCALE,how); | 203 | m_states.setBit(AUTO_SCALE,how); |
204 | _image_data = QImage(); | 204 | _image_data = QImage(); |
205 | if (ImageIsJpeg() && how == false && ImageScaledLoaded()==true) { | 205 | if (ImageIsJpeg() && how == false && ImageScaledLoaded()==true) { |
206 | loadJpeg(true); | 206 | loadJpeg(true); |
207 | } | 207 | } |
208 | _newImage = true; | ||
208 | generateImage(); | 209 | generateImage(); |
209 | } | 210 | } |
210 | 211 | ||
211 | bool OImageScrollView::AutoScale()const | 212 | bool OImageScrollView::AutoScale()const |
212 | { | 213 | { |
213 | return m_states.testBit(AUTO_SCALE); | 214 | return m_states.testBit(AUTO_SCALE); |
214 | } | 215 | } |
215 | 216 | ||
216 | OImageScrollView::~OImageScrollView() | 217 | OImageScrollView::~OImageScrollView() |
217 | { | 218 | { |
218 | } | 219 | } |
219 | 220 | ||
220 | void OImageScrollView::rescaleImage(int w, int h) | 221 | void OImageScrollView::rescaleImage(int w, int h) |
221 | { | 222 | { |
222 | if (_image_data.width()==w && _image_data.height()==h) { | 223 | if (_image_data.width()==w && _image_data.height()==h) { |
223 | return; | 224 | return; |
224 | } | 225 | } |
225 | double hs = (double)h / (double)_image_data.height() ; | 226 | double hs = (double)h / (double)_image_data.height() ; |
226 | double ws = (double)w / (double)_image_data.width() ; | 227 | double ws = (double)w / (double)_image_data.width() ; |
227 | double scaleFactor = (hs > ws) ? ws : hs; | 228 | double scaleFactor = (hs > ws) ? ws : hs; |
228 | int smoothW = (int)(scaleFactor * _image_data.width()); | 229 | int smoothW = (int)(scaleFactor * _image_data.width()); |
229 | int smoothH = (int)(scaleFactor * _image_data.height()); | 230 | int smoothH = (int)(scaleFactor * _image_data.height()); |
230 | _image_data = _image_data.smoothScale(smoothW,smoothH); | 231 | _image_data = _image_data.smoothScale(smoothW,smoothH); |
231 | } | 232 | } |
@@ -327,50 +328,52 @@ void OImageScrollView::rotate_into_data(Rotation r) | |||
327 | destTable[x] = srcTable[x]; | 328 | destTable[x] = srcTable[x]; |
328 | for ( y=0; y < _original_data.height(); ++y ) | 329 | for ( y=0; y < _original_data.height(); ++y ) |
329 | { | 330 | { |
330 | srcData = (unsigned char *)_original_data.scanLine(y); | 331 | srcData = (unsigned char *)_original_data.scanLine(y); |
331 | for ( x=0; x < _original_data.width(); ++x ) | 332 | for ( x=0; x < _original_data.width(); ++x ) |
332 | { | 333 | { |
333 | destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); | 334 | destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); |
334 | destData[y] = srcData[x]; | 335 | destData[y] = srcData[x]; |
335 | } | 336 | } |
336 | } | 337 | } |
337 | break; | 338 | break; |
338 | default: | 339 | default: |
339 | dest = _original_data; | 340 | dest = _original_data; |
340 | break; | 341 | break; |
341 | } | 342 | } |
342 | 343 | ||
343 | } | 344 | } |
344 | _newImage = true; | 345 | _newImage = true; |
345 | _image_data = dest; | 346 | _image_data = dest; |
346 | } | 347 | } |
347 | 348 | ||
348 | // yes - sorry - it is NOT gamma it is just BRIGHTNESS. Alwin | 349 | // yes - sorry - it is NOT gamma it is just BRIGHTNESS. Alwin |
349 | void OImageScrollView::apply_gamma(int aValue) | 350 | void OImageScrollView::apply_gamma(int aValue) |
350 | { | 351 | { |
351 | if (!_image_data.size().isValid()) return; | 352 | if (aValue==0 || !_image_data.size().isValid()) return; |
352 | float percent = ((float)aValue/100.0); | 353 | float percent = ((float)aValue/100.0); |
354 | /* make sure working on a copy */ | ||
355 | _image_data.detach(); | ||
353 | 356 | ||
354 | int segColors = _image_data.depth() > 8 ? 256 : _image_data.numColors(); | 357 | int segColors = _image_data.depth() > 8 ? 256 : _image_data.numColors(); |
355 | /* must be - otherwise it displays some ... strange colors */ | 358 | /* must be - otherwise it displays some ... strange colors */ |
356 | if (segColors<256) segColors=256; | 359 | if (segColors<256) segColors=256; |
357 | 360 | ||
358 | unsigned char *segTbl = new unsigned char[segColors]; | 361 | unsigned char *segTbl = new unsigned char[segColors]; |
359 | int pixels = _image_data.depth()>8?_image_data.width()*_image_data.height() : _image_data.numColors(); | 362 | int pixels = _image_data.depth()>8?_image_data.width()*_image_data.height() : _image_data.numColors(); |
360 | 363 | ||
361 | 364 | ||
362 | bool brighten = (percent >= 0); | 365 | bool brighten = (percent >= 0); |
363 | if ( percent < 0 ) { | 366 | if ( percent < 0 ) { |
364 | percent = -percent; | 367 | percent = -percent; |
365 | } | 368 | } |
366 | 369 | ||
367 | unsigned int *data = _image_data.depth() > 8 ? (unsigned int *)_image_data.bits() : | 370 | unsigned int *data = _image_data.depth() > 8 ? (unsigned int *)_image_data.bits() : |
368 | (unsigned int *)_image_data.colorTable(); | 371 | (unsigned int *)_image_data.colorTable(); |
369 | 372 | ||
370 | int tmp = 0; | 373 | int tmp = 0; |
371 | 374 | ||
372 | if (brighten) { | 375 | if (brighten) { |
373 | for ( int i=0; i < segColors; ++i ) | 376 | for ( int i=0; i < segColors; ++i ) |
374 | { | 377 | { |
375 | tmp = (int)(i*percent); | 378 | tmp = (int)(i*percent); |
376 | if ( tmp > 255 ) | 379 | if ( tmp > 255 ) |