summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-24 11:34:36 (UTC)
committer alwin <alwin>2005-03-24 11:34:36 (UTC)
commitc635023dd68edd0cb0cbb2827b926f33e27e0404 (patch) (unidiff)
tree199e63c6e873398696d705c7d44a0854e3d49872
parent108720c1f24c31e67ccc0225073a726d5edd81ae (diff)
downloadopie-c635023dd68edd0cb0cbb2827b926f33e27e0404.zip
opie-c635023dd68edd0cb0cbb2827b926f33e27e0404.tar.gz
opie-c635023dd68edd0cb0cbb2827b926f33e27e0404.tar.bz2
- removed a lot of useless debugoutput
- fixed a small display problem
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/oimagescrollview.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/libopie2/opiemm/oimagescrollview.cpp b/libopie2/opiemm/oimagescrollview.cpp
index 58a9748..10da823 100644
--- a/libopie2/opiemm/oimagescrollview.cpp
+++ b/libopie2/opiemm/oimagescrollview.cpp
@@ -92,80 +92,74 @@ void OImageScrollView::loadJpeg(bool interncall)
92 bool real_load = false; 92 bool real_load = false;
93 _newImage = true; 93 _newImage = true;
94 if (AutoScale()) { 94 if (AutoScale()) {
95 if (!interncall) { 95 if (!interncall) {
96 ExifData xf; 96 ExifData xf;
97 bool scanned = xf.scan(m_lastName); 97 bool scanned = xf.scan(m_lastName);
98 int wid, hei; 98 int wid, hei;
99 wid = QApplication::desktop()->width(); 99 wid = QApplication::desktop()->width();
100 hei = QApplication::desktop()->height(); 100 hei = QApplication::desktop()->height();
101 if (hei>wid) { 101 if (hei>wid) {
102 wid = hei; 102 wid = hei;
103 } else { 103 } else {
104 hei = wid; 104 hei = wid;
105 } 105 }
106 if ( (scanned && (wid<xf.getWidth()||hei<xf.getHeight()))||!scanned ) { 106 if ( (scanned && (wid<xf.getWidth()||hei<xf.getHeight()))||!scanned ) {
107 param = QString( "Fast Shrink( 3 ) Scale( %1, %2, ScaleMin)" ).arg( wid ).arg( hei ); 107 param = QString( "Fast Shrink( 3 ) Scale( %1, %2, ScaleMin)" ).arg( wid ).arg( hei );
108 odebug << "Load jpeg scaled \"" << param << "\"" << oendl;
109 iio.setParameters(param.latin1()); 108 iio.setParameters(param.latin1());
110 setImageScaledLoaded(true); 109 setImageScaledLoaded(true);
111 } 110 }
112 111
113 real_load = true; 112 real_load = true;
114 } 113 }
115 } else { 114 } else {
116 if (ImageScaledLoaded()||!interncall) { 115 if (ImageScaledLoaded()||!interncall) {
117 odebug << "Load jpeg unscaled" << oendl;
118 real_load = true; 116 real_load = true;
119 } 117 }
120 setImageScaledLoaded(false); 118 setImageScaledLoaded(false);
121 } 119 }
122 if (real_load) { 120 if (real_load) {
123 _original_data = iio.read() ? iio.image() : QImage(); 121 _original_data = iio.read() ? iio.image() : QImage();
124 } 122 }
125} 123}
126 124
127void OImageScrollView::setImage( const QString& path ) { 125void OImageScrollView::setImage( const QString& path ) {
128 odebug << "load new image " << oendl;
129 if (m_lastName == path) return; 126 if (m_lastName == path) return;
130 m_lastName = path; 127 m_lastName = path;
131 _newImage = true; 128 _newImage = true;
132 _original_data = QImage(); 129 _original_data = QImage();
133 QString itype = QImage::imageFormat(m_lastName); 130 QString itype = QImage::imageFormat(m_lastName);
134 odebug << "Image type = " << itype << oendl;
135 if (itype == "JPEG") { 131 if (itype == "JPEG") {
136 setImageIsJpeg(true); 132 setImageIsJpeg(true);
137 loadJpeg(); 133 loadJpeg();
138 } else { 134 } else {
139 setImageIsJpeg(false); 135 setImageIsJpeg(false);
140 _original_data.load(path); 136 _original_data.load(path);
141 _original_data.convertDepth(QPixmap::defaultDepth()); 137 _original_data.convertDepth(QPixmap::defaultDepth());
142 _original_data.setAlphaBuffer(false); 138 _original_data.setAlphaBuffer(false);
143 } 139 }
144 _image_data = QImage(); 140 _image_data = QImage();
145 if (FirstResizeDone()) { 141 if (FirstResizeDone()) {
146 generateImage(); 142 generateImage();
147 if (isVisible()) viewport()->repaint(true); 143 if (isVisible()) viewport()->repaint(true);
148 } 144 }
149} 145}
150 146
151/* should be called every time the QImage changed it content */ 147/* should be called every time the QImage changed it content */
152void OImageScrollView::init() 148void OImageScrollView::init()
153{ 149{
154 odebug << "init " << oendl;
155
156 /* 150 /*
157 * create the zoomer 151 * create the zoomer
158 * and connect ther various signals 152 * and connect ther various signals
159 */ 153 */
160 _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); 154 _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" );
161 connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), 155 connect(_zoomer, SIGNAL( zoomAreaRel(int,int)),
162 this, SLOT(scrollBy(int,int)) ); 156 this, SLOT(scrollBy(int,int)) );
163 connect(_zoomer, SIGNAL( zoomArea(int,int)), 157 connect(_zoomer, SIGNAL( zoomArea(int,int)),
164 this, SLOT(center(int,int)) ); 158 this, SLOT(center(int,int)) );
165 connect(this,SIGNAL(contentsMoving(int,int)), 159 connect(this,SIGNAL(contentsMoving(int,int)),
166 _zoomer, (SLOT(setVisiblePoint(int,int))) ); 160 _zoomer, (SLOT(setVisiblePoint(int,int))) );
167 connect(this,SIGNAL(imageSizeChanged(const QSize&)), 161 connect(this,SIGNAL(imageSizeChanged(const QSize&)),
168 _zoomer, SLOT(setImageSize(const QSize&)) ); 162 _zoomer, SLOT(setImageSize(const QSize&)) );
169 connect(this,SIGNAL(viewportSizeChanged(const QSize&)), 163 connect(this,SIGNAL(viewportSizeChanged(const QSize&)),
170 _zoomer, SLOT(setViewPortSize(const QSize&)) ); 164 _zoomer, SLOT(setViewPortSize(const QSize&)) );
171 165
@@ -338,60 +332,68 @@ void OImageScrollView::rotate_into_data(Rotation r)
338 { 332 {
339 destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); 333 destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1);
340 destData[y] = srcData[x]; 334 destData[y] = srcData[x];
341 } 335 }
342 } 336 }
343 break; 337 break;
344 default: 338 default:
345 dest = _original_data; 339 dest = _original_data;
346 break; 340 break;
347 } 341 }
348 342
349 } 343 }
350 _newImage = true; 344 _newImage = true;
351 _image_data = dest; 345 _image_data = dest;
352} 346}
353 347
348// yes - sorry - it is NOT gamma it is just BRIGHTNESS. Alwin
354void OImageScrollView::apply_gamma(int aValue) 349void OImageScrollView::apply_gamma(int aValue)
355{ 350{
356 if (!_image_data.size().isValid()) return; 351 if (!_image_data.size().isValid()) return;
357 float percent = ((float)aValue/100); 352 float percent = ((float)aValue/100.0);
358 odebug << "Apply gamma " << percent << oendl; 353
359 int pixels = _image_data.depth()>8?_image_data.width()*_image_data.height() : _image_data.numColors();
360 int segColors = _image_data.depth() > 8 ? 256 : _image_data.numColors(); 354 int segColors = _image_data.depth() > 8 ? 256 : _image_data.numColors();
355 /* must be - otherwise it displays some ... strange colors */
356 if (segColors<256) segColors=256;
357
361 unsigned char *segTbl = new unsigned char[segColors]; 358 unsigned char *segTbl = new unsigned char[segColors];
359 int pixels = _image_data.depth()>8?_image_data.width()*_image_data.height() : _image_data.numColors();
360
361
362 bool brighten = (percent >= 0); 362 bool brighten = (percent >= 0);
363 if ( percent < 0 ) 363 if ( percent < 0 ) {
364 percent = -percent; 364 percent = -percent;
365 }
365 366
366 unsigned int *data = _image_data.depth() > 8 ? (unsigned int *)_image_data.bits() : 367 unsigned int *data = _image_data.depth() > 8 ? (unsigned int *)_image_data.bits() :
367 (unsigned int *)_image_data.colorTable(); 368 (unsigned int *)_image_data.colorTable();
368 369
370 int tmp = 0;
369 371
370 if (brighten) { 372 if (brighten) {
371 for ( int i=0; i < segColors; ++i ) 373 for ( int i=0; i < segColors; ++i )
372 { 374 {
373 int tmp = (int)(i*percent); 375 tmp = (int)(i*percent);
374 if ( tmp > 255 ) 376 if ( tmp > 255 )
375 tmp = 255; 377 tmp = 255;
376 segTbl[i] = tmp; 378 segTbl[i] = tmp;
377 } 379 }
378 } else { 380 } else {
379 for ( int i=0; i < segColors; ++i ) 381 for ( int i=0; i < segColors; ++i )
380 { 382 {
381 int tmp = (int)(i*percent); 383 tmp = (int)(i*percent);
382 if ( tmp < 0 ) 384 if ( tmp < 0 )
383 tmp = 0; 385 tmp = 0;
384 segTbl[i] = tmp; 386 segTbl[i] = tmp;
385 } 387 }
386 } 388 }
387 if (brighten) { 389 if (brighten) {
388 for ( int i=0; i < pixels; ++i ) 390 for ( int i=0; i < pixels; ++i )
389 { 391 {
390 int r = qRed(data[i]); 392 int r = qRed(data[i]);
391 int g = qGreen(data[i]); 393 int g = qGreen(data[i]);
392 int b = qBlue(data[i]); 394 int b = qBlue(data[i]);
393 int a = qAlpha(data[i]); 395 int a = qAlpha(data[i]);
394 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; 396 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r];
395 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; 397 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g];
396 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; 398 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b];
397 data[i] = qRgba(r, g, b,a); 399 data[i] = qRgba(r, g, b,a);
@@ -445,36 +447,34 @@ int OImageScrollView::setIntensity(int value,bool reload)
445 447
446void OImageScrollView::generateImage() 448void OImageScrollView::generateImage()
447{ 449{
448 Rotation r = Rotate0; 450 Rotation r = Rotate0;
449 _pdata = QPixmap(); 451 _pdata = QPixmap();
450 if (_original_data.isNull()) { 452 if (_original_data.isNull()) {
451 emit imageSizeChanged( _image_data.size() ); 453 emit imageSizeChanged( _image_data.size() );
452 if (_zoomer) _zoomer->setImage( _image_data ); 454 if (_zoomer) _zoomer->setImage( _image_data );
453 return; 455 return;
454 } 456 }
455 if (width()>height()&&_original_data.width()<_original_data.height() || 457 if (width()>height()&&_original_data.width()<_original_data.height() ||
456 width()<height()&&_original_data.width()>_original_data.height()) { 458 width()<height()&&_original_data.width()>_original_data.height()) {
457 if (AutoRotate()) r = Rotate90; 459 if (AutoRotate()) r = Rotate90;
458 } 460 }
459 461
460 int twidth,theight; 462 int twidth,theight;
461 odebug << " r = " << r << oendl;
462 if (AutoScale() && (_original_data.width()>width() || _original_data.height() > height()) ) { 463 if (AutoScale() && (_original_data.width()>width() || _original_data.height() > height()) ) {
463 if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { 464 if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) {
464 odebug << "Rescaling data" << oendl;
465 if (r==Rotate0) { 465 if (r==Rotate0) {
466 _image_data = _original_data; 466 _image_data = _original_data;
467 } else { 467 } else {
468 rotate_into_data(r); 468 rotate_into_data(r);
469 } 469 }
470 _newImage = true; 470 _newImage = true;
471 } 471 }
472 rescaleImage(width(),height()); 472 rescaleImage(width(),height());
473 } else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) { 473 } else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) {
474 if (r==Rotate0) { 474 if (r==Rotate0) {
475 _image_data = _original_data; 475 _image_data = _original_data;
476 } else { 476 } else {
477 rotate_into_data(r); 477 rotate_into_data(r);
478 } 478 }
479 m_last_rot = r; 479 m_last_rot = r;
480 } 480 }
@@ -501,33 +501,32 @@ void OImageScrollView::generateImage()
501 if (_zoomer) { 501 if (_zoomer) {
502 _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, 502 _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2,
503 _image_data.width()/2, _image_data.height()/2 ); 503 _image_data.width()/2, _image_data.height()/2 );
504 _zoomer->setImage( _image_data ); 504 _zoomer->setImage( _image_data );
505 } 505 }
506 /* 506 /*
507 * invalidate 507 * invalidate
508 */ 508 */
509 _image_data=QImage(); 509 _image_data=QImage();
510 if (isVisible()) { 510 if (isVisible()) {
511 updateContents(contentsX(),contentsY(),width(),height()); 511 updateContents(contentsX(),contentsY(),width(),height());
512 } 512 }
513} 513}
514 514
515void OImageScrollView::resizeEvent(QResizeEvent * e) 515void OImageScrollView::resizeEvent(QResizeEvent * e)
516{ 516{
517 odebug << "OImageScrollView resizeEvent (" << e->size() << " - " << e->oldSize() << oendl;
518 QScrollView::resizeEvent(e); 517 QScrollView::resizeEvent(e);
519 if (e->oldSize()==e->size()||!isUpdatesEnabled ()) return; 518 if (e->oldSize()==e->size()||!isUpdatesEnabled ()) return;
520 generateImage(); 519 generateImage();
521 setFirstResizeDone(true); 520 setFirstResizeDone(true);
522 emit viewportSizeChanged( viewport()->size() ); 521 emit viewportSizeChanged( viewport()->size() );
523 522
524} 523}
525 524
526void OImageScrollView::keyPressEvent(QKeyEvent * e) 525void OImageScrollView::keyPressEvent(QKeyEvent * e)
527{ 526{
528 if (!e) return; 527 if (!e) return;
529 int dx = horizontalScrollBar()->lineStep(); 528 int dx = horizontalScrollBar()->lineStep();
530 int dy = verticalScrollBar()->lineStep(); 529 int dy = verticalScrollBar()->lineStep();
531 if (e->key()==Qt::Key_Right) { 530 if (e->key()==Qt::Key_Right) {
532 scrollBy(dx,0); 531 scrollBy(dx,0);
533 e->accept(); 532 e->accept();
@@ -582,33 +581,32 @@ void OImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clip
582void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) 581void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e)
583{ 582{
584 int mx, my; 583 int mx, my;
585 mx = e->x(); 584 mx = e->x();
586 my = e->y(); 585 my = e->y();
587 if (_mouseStartPosX!=-1 && _mouseStartPosY!=-1) { 586 if (_mouseStartPosX!=-1 && _mouseStartPosY!=-1) {
588 int diffx = _mouseStartPosX-mx; 587 int diffx = _mouseStartPosX-mx;
589 int diffy = _mouseStartPosY-my; 588 int diffy = _mouseStartPosY-my;
590 scrollBy(diffx,diffy); 589 scrollBy(diffx,diffy);
591 } 590 }
592 _mouseStartPosX=mx; 591 _mouseStartPosX=mx;
593 _mouseStartPosY=my; 592 _mouseStartPosY=my;
594} 593}
595 594
596void OImageScrollView::contentsMousePressEvent ( QMouseEvent * e) 595void OImageScrollView::contentsMousePressEvent ( QMouseEvent * e)
597{ 596{
598 odebug << " X and Y " << e->x() << " " << e->y() << oendl;
599 /* this marks the beginning of a possible mouse move. Due internal reasons of QT 597 /* this marks the beginning of a possible mouse move. Due internal reasons of QT
600 the geometry values here may real differ from that set in MoveEvent (I don't know 598 the geometry values here may real differ from that set in MoveEvent (I don't know
601 why). For getting them in real context, we use the first move-event to set the start 599 why). For getting them in real context, we use the first move-event to set the start
602 position ;) 600 position ;)
603 */ 601 */
604 _mouseStartPosX = -1; 602 _mouseStartPosX = -1;
605 _mouseStartPosY = -1; 603 _mouseStartPosY = -1;
606} 604}
607 605
608void OImageScrollView::setDestructiveClose() { 606void OImageScrollView::setDestructiveClose() {
609 WFlags fl = getWFlags(); 607 WFlags fl = getWFlags();
610 /* clear it just in case */ 608 /* clear it just in case */
611 fl &= ~WDestructiveClose; 609 fl &= ~WDestructiveClose;
612 fl |= WDestructiveClose; 610 fl |= WDestructiveClose;
613 setWFlags( fl ); 611 setWFlags( fl );
614} 612}