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
@@ -102,39 +102,35 @@ void OImageScrollView::loadJpeg(bool interncall)
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);
@@ -148,14 +144,12 @@ void OImageScrollView::setImage( const QString& path ) {
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)),
@@ -348,40 +342,48 @@ void OImageScrollView::rotate_into_data(Rotation r)
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) {
@@ -455,16 +457,14 @@ void OImageScrollView::generateImage()
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;
@@ -511,13 +511,12 @@ void OImageScrollView::generateImage()
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
@@ -592,13 +591,12 @@ void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e)
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;