-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 86 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.h | 3 |
2 files changed, 83 insertions, 6 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp index 2f16d82..d034ee0 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp +++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp @@ -3,2 +3,4 @@ #include <opie2/odebug.h> +#include <opie2/oapplication.h> +#include <opie2/owait.h> @@ -8,2 +10,3 @@ using namespace Opie::Core; #include <qlayout.h> +#include <qpe/qcopenvelope_qws.h> @@ -40,2 +43,4 @@ void ImageScrollView::setImage(const QImage&img) m_lastName = ""; + image_is_jpeg = false; + image_scaled_loaded = false; if (first_resize_done) { @@ -45,2 +50,43 @@ void ImageScrollView::setImage(const QImage&img) +void ImageScrollView::loadJpeg(bool interncall) +{ + if (m_lastName.isEmpty()) return; + QImageIO iio( m_lastName, 0l ); + QString param; + bool real_load = false; + if (scale_to_fit) { + if (!interncall) { + int wid, hei; + wid = QApplication::desktop()->width(); + hei = QApplication::desktop()->height(); + if (hei>wid) { + wid = hei; + } else { + hei = wid; + } + param = QString( "Fast Shrink( 7 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei ); + odebug << "Load jpeg scaled \"" << param << "\"" << oendl; + iio.setParameters(param.latin1()); + image_scaled_loaded = true; + real_load = true; + } + } else { + if (image_scaled_loaded||!interncall) { + odebug << "Load jpeg unscaled" << oendl; + real_load = true; + } + image_scaled_loaded = false; + } + if (real_load) { + { + QCopEnvelope( "QPE/System", "busy()" ); + } + _original_data = iio.read() ? iio.image() : QImage(); + { + QCopEnvelope env( "QPE/System", "notBusy(QString)" ); + env << "Image loaded"; + } + } +} + void ImageScrollView::setImage( const QString& path ) { @@ -49,5 +95,20 @@ void ImageScrollView::setImage( const QString& path ) { m_lastName = path; - _original_data.load(path); - _original_data.convertDepth(QPixmap::defaultDepth()); - _original_data.setAlphaBuffer(false); + QString itype = QImage::imageFormat(m_lastName); + odebug << "Image type = " << itype << oendl; + if (itype == "JPEG") { + image_is_jpeg = true; + loadJpeg(); + } else { + { + QCopEnvelope( "QPE/System", "busy()" ); + } + image_is_jpeg = false; + _original_data.load(path); + _original_data.convertDepth(QPixmap::defaultDepth()); + _original_data.setAlphaBuffer(false); + { + QCopEnvelope env( "QPE/System", "notBusy(QString)" ); + env << "Image loaded"; + } + } _image_data = QImage(); @@ -79,2 +140,4 @@ void ImageScrollView::init() setFocusPolicy(QWidget::StrongFocus); + image_scaled_loaded = false; + image_is_jpeg = false; if (first_resize_done) { @@ -105,2 +168,5 @@ void ImageScrollView::setAutoScale(bool how) _image_data = QImage(); + if (image_is_jpeg && how == false && image_scaled_loaded==true) { + loadJpeg(true); + } generateImage(); @@ -242,2 +308,5 @@ void ImageScrollView::generateImage() Rotation r = Rotate0; + { + QCopEnvelope( "QPE/System", "busy()" ); + } if (width()>height()&&_original_data.width()<_original_data.height() || @@ -246,2 +315,3 @@ void ImageScrollView::generateImage() } + odebug << " r = " << r << oendl; @@ -268,3 +338,3 @@ void ImageScrollView::generateImage() _pdata.convertFromImage(_image_data); - + @@ -273,3 +343,3 @@ void ImageScrollView::generateImage() */ - check_zoomer(); + check_zoomer(); emit imageSizeChanged( _image_data.size() ); @@ -281,3 +351,3 @@ void ImageScrollView::generateImage() _image_data.width()/2, _image_data.height()/2 ); - + _zoomer->setImage( _image_data ); @@ -287,2 +357,6 @@ void ImageScrollView::generateImage() _image_data=QImage(); + { + QCopEnvelope env( "QPE/System", "notBusy(QString)" ); + env << "Image generated"; + } } diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h index e209dfb..f6e187d 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.h +++ b/noncore/graphics/opie-eye/gui/imagescrollview.h @@ -59,2 +59,4 @@ protected: bool first_resize_done; + bool image_is_jpeg; + bool image_scaled_loaded; Rotation last_rot; @@ -65,2 +67,3 @@ protected: virtual void generateImage(); + virtual void loadJpeg(bool interncall = false); bool image_fit_into(const QSize&s); |