Diffstat (limited to 'libopie2/opiemm/oimagescrollview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiemm/oimagescrollview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiemm/oimagescrollview.cpp b/libopie2/opiemm/oimagescrollview.cpp index 0e86bd0..68b06af 100644 --- a/libopie2/opiemm/oimagescrollview.cpp +++ b/libopie2/opiemm/oimagescrollview.cpp @@ -3,193 +3,193 @@ #include <opie2/oimagezoomer.h> #include <opie2/odebug.h> #include <opie2/oapplication.h> #include <opie2/owait.h> #include <qimage.h> #include <qlayout.h> #include <qpe/qcopenvelope_qws.h> /* for usage with the bitset */ #define AUTO_SCALE 0 #define AUTO_ROTATE 1 #define SHOW_ZOOMER 2 #define FIRST_RESIZE_DONE 3 #define IMAGE_IS_JPEG 4 #define IMAGE_SCALED_LOADED 5 #define SCROLLVIEW_BITSET_SIZE 6 namespace Opie { namespace MM { OImageScrollView::OImageScrollView( QWidget* parent, const char* name, WFlags f ) :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(), m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") { _zoomer = 0; m_states[AUTO_SCALE]=true; m_states[AUTO_ROTATE]=true; m_states[FIRST_RESIZE_DONE]=false; m_states[IMAGE_IS_JPEG]=false; m_states[IMAGE_SCALED_LOADED]=false; m_states[SHOW_ZOOMER]=true; init(); } OImageScrollView::OImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img), m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") { _zoomer = 0; m_states[AUTO_SCALE]=always_scale; m_states[AUTO_ROTATE]=rfit; m_states[FIRST_RESIZE_DONE]=false; m_states[IMAGE_IS_JPEG]=false; m_states[IMAGE_SCALED_LOADED]=false; m_states[SHOW_ZOOMER]=true; _original_data.convertDepth(QPixmap::defaultDepth()); _original_data.setAlphaBuffer(false); init(); } OImageScrollView::OImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") { _zoomer = 0; m_states.resize(SCROLLVIEW_BITSET_SIZE); m_states[AUTO_SCALE]=always_scale; m_states[AUTO_ROTATE]=rfit; m_states[FIRST_RESIZE_DONE]=false; m_states[IMAGE_IS_JPEG]=false; m_states[IMAGE_SCALED_LOADED]=false; m_states[SHOW_ZOOMER]=true; init(); setImage(img); } void OImageScrollView::setImage(const QImage&img) { _image_data = QImage(); _original_data=img; _original_data.convertDepth(QPixmap::defaultDepth()); _original_data.setAlphaBuffer(false); m_lastName = ""; setImageIsJpeg(false); setImageScaledLoaded(false); if (FirstResizeDone()) { generateImage(); } } void OImageScrollView::loadJpeg(bool interncall) { if (m_lastName.isEmpty()) return; QImageIO iio( m_lastName, 0l ); QString param; bool real_load = false; if (AutoScale()) { 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 ); + param = QString( "Fast Shrink( 3 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei ); odebug << "Load jpeg scaled \"" << param << "\"" << oendl; iio.setParameters(param.latin1()); setImageScaledLoaded(true); real_load = true; } } else { if (ImageScaledLoaded()||!interncall) { odebug << "Load jpeg unscaled" << oendl; real_load = true; } setImageScaledLoaded(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 OImageScrollView::setImage( const QString& path ) { odebug << "load new image " << oendl; if (m_lastName == path) return; m_lastName = path; QString itype = QImage::imageFormat(m_lastName); odebug << "Image type = " << itype << oendl; if (itype == "JPEG") { setImageIsJpeg(true); loadJpeg(); } else { { QCopEnvelope( "QPE/System", "busy()" ); } setImageIsJpeg(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(); if (FirstResizeDone()) { generateImage(); } } /* should be called every time the QImage changed it content */ void OImageScrollView::init() { odebug << "init " << oendl; /* * create the zoomer * and connect ther various signals */ _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), this, SLOT(scrollBy(int,int)) ); connect(_zoomer, SIGNAL( zoomArea(int,int)), this, SLOT(center(int,int)) ); connect(this,SIGNAL(contentsMoving(int,int)), _zoomer, (SLOT(setVisiblePoint(int,int))) ); connect(this,SIGNAL(imageSizeChanged(const QSize&)), _zoomer, SLOT(setImageSize(const QSize&)) ); connect(this,SIGNAL(viewportSizeChanged(const QSize&)), _zoomer, SLOT(setViewPortSize(const QSize&)) ); viewport()->setBackgroundColor(white); setFocusPolicy(QWidget::StrongFocus); setImageScaledLoaded(false); setImageIsJpeg(false); if (FirstResizeDone()) { m_last_rot = Rotate0; generateImage(); } else if (_original_data.size().isValid()) { if (image_fit_into(_original_data.size()) || !ShowZoomer()) _zoomer->hide(); resizeContents(_original_data.width(),_original_data.height()); } } void OImageScrollView::setAutoRotate(bool how) { /* to avoid double repaints */ if (AutoRotate() != how) { m_states.setBit(AUTO_ROTATE,how); _image_data = QImage(); generateImage(); } } |