author | alwin <alwin> | 2004-04-15 07:44:42 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-15 07:44:42 (UTC) |
commit | 41203805fb5e70df84cc2894dbd6e030c6355041 (patch) (unidiff) | |
tree | 3bffe09aeff1a69d9912193c481a2effe990d5db | |
parent | 20175bc18b278426c80ff890853cbf54839f88be (diff) | |
download | opie-41203805fb5e70df84cc2894dbd6e030c6355041.zip opie-41203805fb5e70df84cc2894dbd6e030c6355041.tar.gz opie-41203805fb5e70df84cc2894dbd6e030c6355041.tar.bz2 |
using other values when scaled loading of jpegs
-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 | |||
@@ -1,355 +1,355 @@ | |||
1 | #include "oimagescrollview.h" | 1 | #include "oimagescrollview.h" |
2 | 2 | ||
3 | #include <opie2/oimagezoomer.h> | 3 | #include <opie2/oimagezoomer.h> |
4 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
5 | #include <opie2/oapplication.h> | 5 | #include <opie2/oapplication.h> |
6 | #include <opie2/owait.h> | 6 | #include <opie2/owait.h> |
7 | 7 | ||
8 | #include <qimage.h> | 8 | #include <qimage.h> |
9 | #include <qlayout.h> | 9 | #include <qlayout.h> |
10 | #include <qpe/qcopenvelope_qws.h> | 10 | #include <qpe/qcopenvelope_qws.h> |
11 | 11 | ||
12 | /* for usage with the bitset */ | 12 | /* for usage with the bitset */ |
13 | #define AUTO_SCALE 0 | 13 | #define AUTO_SCALE 0 |
14 | #define AUTO_ROTATE 1 | 14 | #define AUTO_ROTATE 1 |
15 | #define SHOW_ZOOMER 2 | 15 | #define SHOW_ZOOMER 2 |
16 | #define FIRST_RESIZE_DONE 3 | 16 | #define FIRST_RESIZE_DONE 3 |
17 | #define IMAGE_IS_JPEG 4 | 17 | #define IMAGE_IS_JPEG 4 |
18 | #define IMAGE_SCALED_LOADED 5 | 18 | #define IMAGE_SCALED_LOADED 5 |
19 | 19 | ||
20 | #define SCROLLVIEW_BITSET_SIZE 6 | 20 | #define SCROLLVIEW_BITSET_SIZE 6 |
21 | 21 | ||
22 | namespace Opie { | 22 | namespace Opie { |
23 | namespace MM { | 23 | namespace MM { |
24 | OImageScrollView::OImageScrollView( QWidget* parent, const char* name, WFlags f ) | 24 | OImageScrollView::OImageScrollView( QWidget* parent, const char* name, WFlags f ) |
25 | :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(), | 25 | :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(), |
26 | m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") | 26 | m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") |
27 | { | 27 | { |
28 | _zoomer = 0; | 28 | _zoomer = 0; |
29 | m_states[AUTO_SCALE]=true; | 29 | m_states[AUTO_SCALE]=true; |
30 | m_states[AUTO_ROTATE]=true; | 30 | m_states[AUTO_ROTATE]=true; |
31 | m_states[FIRST_RESIZE_DONE]=false; | 31 | m_states[FIRST_RESIZE_DONE]=false; |
32 | m_states[IMAGE_IS_JPEG]=false; | 32 | m_states[IMAGE_IS_JPEG]=false; |
33 | m_states[IMAGE_SCALED_LOADED]=false; | 33 | m_states[IMAGE_SCALED_LOADED]=false; |
34 | m_states[SHOW_ZOOMER]=true; | 34 | m_states[SHOW_ZOOMER]=true; |
35 | init(); | 35 | init(); |
36 | } | 36 | } |
37 | 37 | ||
38 | OImageScrollView::OImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 38 | OImageScrollView::OImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
39 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img), | 39 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img), |
40 | m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") | 40 | m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") |
41 | { | 41 | { |
42 | _zoomer = 0; | 42 | _zoomer = 0; |
43 | m_states[AUTO_SCALE]=always_scale; | 43 | m_states[AUTO_SCALE]=always_scale; |
44 | m_states[AUTO_ROTATE]=rfit; | 44 | m_states[AUTO_ROTATE]=rfit; |
45 | m_states[FIRST_RESIZE_DONE]=false; | 45 | m_states[FIRST_RESIZE_DONE]=false; |
46 | m_states[IMAGE_IS_JPEG]=false; | 46 | m_states[IMAGE_IS_JPEG]=false; |
47 | m_states[IMAGE_SCALED_LOADED]=false; | 47 | m_states[IMAGE_SCALED_LOADED]=false; |
48 | m_states[SHOW_ZOOMER]=true; | 48 | m_states[SHOW_ZOOMER]=true; |
49 | _original_data.convertDepth(QPixmap::defaultDepth()); | 49 | _original_data.convertDepth(QPixmap::defaultDepth()); |
50 | _original_data.setAlphaBuffer(false); | 50 | _original_data.setAlphaBuffer(false); |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | OImageScrollView::OImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 54 | OImageScrollView::OImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
55 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") | 55 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") |
56 | { | 56 | { |
57 | _zoomer = 0; | 57 | _zoomer = 0; |
58 | m_states.resize(SCROLLVIEW_BITSET_SIZE); | 58 | m_states.resize(SCROLLVIEW_BITSET_SIZE); |
59 | m_states[AUTO_SCALE]=always_scale; | 59 | m_states[AUTO_SCALE]=always_scale; |
60 | m_states[AUTO_ROTATE]=rfit; | 60 | m_states[AUTO_ROTATE]=rfit; |
61 | m_states[FIRST_RESIZE_DONE]=false; | 61 | m_states[FIRST_RESIZE_DONE]=false; |
62 | m_states[IMAGE_IS_JPEG]=false; | 62 | m_states[IMAGE_IS_JPEG]=false; |
63 | m_states[IMAGE_SCALED_LOADED]=false; | 63 | m_states[IMAGE_SCALED_LOADED]=false; |
64 | m_states[SHOW_ZOOMER]=true; | 64 | m_states[SHOW_ZOOMER]=true; |
65 | init(); | 65 | init(); |
66 | setImage(img); | 66 | setImage(img); |
67 | } | 67 | } |
68 | 68 | ||
69 | void OImageScrollView::setImage(const QImage&img) | 69 | void OImageScrollView::setImage(const QImage&img) |
70 | { | 70 | { |
71 | _image_data = QImage(); | 71 | _image_data = QImage(); |
72 | _original_data=img; | 72 | _original_data=img; |
73 | _original_data.convertDepth(QPixmap::defaultDepth()); | 73 | _original_data.convertDepth(QPixmap::defaultDepth()); |
74 | _original_data.setAlphaBuffer(false); | 74 | _original_data.setAlphaBuffer(false); |
75 | m_lastName = ""; | 75 | m_lastName = ""; |
76 | setImageIsJpeg(false); | 76 | setImageIsJpeg(false); |
77 | setImageScaledLoaded(false); | 77 | setImageScaledLoaded(false); |
78 | if (FirstResizeDone()) { | 78 | if (FirstResizeDone()) { |
79 | generateImage(); | 79 | generateImage(); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | void OImageScrollView::loadJpeg(bool interncall) | 83 | void OImageScrollView::loadJpeg(bool interncall) |
84 | { | 84 | { |
85 | if (m_lastName.isEmpty()) return; | 85 | if (m_lastName.isEmpty()) return; |
86 | QImageIO iio( m_lastName, 0l ); | 86 | QImageIO iio( m_lastName, 0l ); |
87 | QString param; | 87 | QString param; |
88 | bool real_load = false; | 88 | bool real_load = false; |
89 | if (AutoScale()) { | 89 | if (AutoScale()) { |
90 | if (!interncall) { | 90 | if (!interncall) { |
91 | int wid, hei; | 91 | int wid, hei; |
92 | wid = QApplication::desktop()->width(); | 92 | wid = QApplication::desktop()->width(); |
93 | hei = QApplication::desktop()->height(); | 93 | hei = QApplication::desktop()->height(); |
94 | if (hei>wid) { | 94 | if (hei>wid) { |
95 | wid = hei; | 95 | wid = hei; |
96 | } else { | 96 | } else { |
97 | hei = wid; | 97 | hei = wid; |
98 | } | 98 | } |
99 | param = QString( "Fast Shrink( 7 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei ); | 99 | param = QString( "Fast Shrink( 3 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei ); |
100 | odebug << "Load jpeg scaled \"" << param << "\"" << oendl; | 100 | odebug << "Load jpeg scaled \"" << param << "\"" << oendl; |
101 | iio.setParameters(param.latin1()); | 101 | iio.setParameters(param.latin1()); |
102 | setImageScaledLoaded(true); | 102 | setImageScaledLoaded(true); |
103 | real_load = true; | 103 | real_load = true; |
104 | } | 104 | } |
105 | } else { | 105 | } else { |
106 | if (ImageScaledLoaded()||!interncall) { | 106 | if (ImageScaledLoaded()||!interncall) { |
107 | odebug << "Load jpeg unscaled" << oendl; | 107 | odebug << "Load jpeg unscaled" << oendl; |
108 | real_load = true; | 108 | real_load = true; |
109 | } | 109 | } |
110 | setImageScaledLoaded(false); | 110 | setImageScaledLoaded(false); |
111 | } | 111 | } |
112 | if (real_load) { | 112 | if (real_load) { |
113 | { | 113 | { |
114 | QCopEnvelope( "QPE/System", "busy()" ); | 114 | QCopEnvelope( "QPE/System", "busy()" ); |
115 | } | 115 | } |
116 | _original_data = iio.read() ? iio.image() : QImage(); | 116 | _original_data = iio.read() ? iio.image() : QImage(); |
117 | { | 117 | { |
118 | QCopEnvelope env( "QPE/System", "notBusy(QString)" ); | 118 | QCopEnvelope env( "QPE/System", "notBusy(QString)" ); |
119 | env << "Image loaded"; | 119 | env << "Image loaded"; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | void OImageScrollView::setImage( const QString& path ) { | 124 | void OImageScrollView::setImage( const QString& path ) { |
125 | odebug << "load new image " << oendl; | 125 | odebug << "load new image " << oendl; |
126 | if (m_lastName == path) return; | 126 | if (m_lastName == path) return; |
127 | m_lastName = path; | 127 | m_lastName = path; |
128 | QString itype = QImage::imageFormat(m_lastName); | 128 | QString itype = QImage::imageFormat(m_lastName); |
129 | odebug << "Image type = " << itype << oendl; | 129 | odebug << "Image type = " << itype << oendl; |
130 | if (itype == "JPEG") { | 130 | if (itype == "JPEG") { |
131 | setImageIsJpeg(true); | 131 | setImageIsJpeg(true); |
132 | loadJpeg(); | 132 | loadJpeg(); |
133 | } else { | 133 | } else { |
134 | { | 134 | { |
135 | QCopEnvelope( "QPE/System", "busy()" ); | 135 | QCopEnvelope( "QPE/System", "busy()" ); |
136 | } | 136 | } |
137 | setImageIsJpeg(false); | 137 | setImageIsJpeg(false); |
138 | _original_data.load(path); | 138 | _original_data.load(path); |
139 | _original_data.convertDepth(QPixmap::defaultDepth()); | 139 | _original_data.convertDepth(QPixmap::defaultDepth()); |
140 | _original_data.setAlphaBuffer(false); | 140 | _original_data.setAlphaBuffer(false); |
141 | { | 141 | { |
142 | QCopEnvelope env( "QPE/System", "notBusy(QString)" ); | 142 | QCopEnvelope env( "QPE/System", "notBusy(QString)" ); |
143 | env << "Image loaded"; | 143 | env << "Image loaded"; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | _image_data = QImage(); | 146 | _image_data = QImage(); |
147 | if (FirstResizeDone()) { | 147 | if (FirstResizeDone()) { |
148 | generateImage(); | 148 | generateImage(); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | /* should be called every time the QImage changed it content */ | 152 | /* should be called every time the QImage changed it content */ |
153 | void OImageScrollView::init() | 153 | void OImageScrollView::init() |
154 | { | 154 | { |
155 | odebug << "init " << oendl; | 155 | odebug << "init " << oendl; |
156 | 156 | ||
157 | /* | 157 | /* |
158 | * create the zoomer | 158 | * create the zoomer |
159 | * and connect ther various signals | 159 | * and connect ther various signals |
160 | */ | 160 | */ |
161 | _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); | 161 | _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); |
162 | connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), | 162 | connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), |
163 | this, SLOT(scrollBy(int,int)) ); | 163 | this, SLOT(scrollBy(int,int)) ); |
164 | connect(_zoomer, SIGNAL( zoomArea(int,int)), | 164 | connect(_zoomer, SIGNAL( zoomArea(int,int)), |
165 | this, SLOT(center(int,int)) ); | 165 | this, SLOT(center(int,int)) ); |
166 | connect(this,SIGNAL(contentsMoving(int,int)), | 166 | connect(this,SIGNAL(contentsMoving(int,int)), |
167 | _zoomer, (SLOT(setVisiblePoint(int,int))) ); | 167 | _zoomer, (SLOT(setVisiblePoint(int,int))) ); |
168 | connect(this,SIGNAL(imageSizeChanged(const QSize&)), | 168 | connect(this,SIGNAL(imageSizeChanged(const QSize&)), |
169 | _zoomer, SLOT(setImageSize(const QSize&)) ); | 169 | _zoomer, SLOT(setImageSize(const QSize&)) ); |
170 | connect(this,SIGNAL(viewportSizeChanged(const QSize&)), | 170 | connect(this,SIGNAL(viewportSizeChanged(const QSize&)), |
171 | _zoomer, SLOT(setViewPortSize(const QSize&)) ); | 171 | _zoomer, SLOT(setViewPortSize(const QSize&)) ); |
172 | 172 | ||
173 | viewport()->setBackgroundColor(white); | 173 | viewport()->setBackgroundColor(white); |
174 | setFocusPolicy(QWidget::StrongFocus); | 174 | setFocusPolicy(QWidget::StrongFocus); |
175 | setImageScaledLoaded(false); | 175 | setImageScaledLoaded(false); |
176 | setImageIsJpeg(false); | 176 | setImageIsJpeg(false); |
177 | if (FirstResizeDone()) { | 177 | if (FirstResizeDone()) { |
178 | m_last_rot = Rotate0; | 178 | m_last_rot = Rotate0; |
179 | generateImage(); | 179 | generateImage(); |
180 | } else if (_original_data.size().isValid()) { | 180 | } else if (_original_data.size().isValid()) { |
181 | if (image_fit_into(_original_data.size()) || !ShowZoomer()) _zoomer->hide(); | 181 | if (image_fit_into(_original_data.size()) || !ShowZoomer()) _zoomer->hide(); |
182 | resizeContents(_original_data.width(),_original_data.height()); | 182 | resizeContents(_original_data.width(),_original_data.height()); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | void OImageScrollView::setAutoRotate(bool how) | 186 | void OImageScrollView::setAutoRotate(bool how) |
187 | { | 187 | { |
188 | /* to avoid double repaints */ | 188 | /* to avoid double repaints */ |
189 | if (AutoRotate() != how) { | 189 | if (AutoRotate() != how) { |
190 | m_states.setBit(AUTO_ROTATE,how); | 190 | m_states.setBit(AUTO_ROTATE,how); |
191 | _image_data = QImage(); | 191 | _image_data = QImage(); |
192 | generateImage(); | 192 | generateImage(); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | bool OImageScrollView::AutoRotate()const | 196 | bool OImageScrollView::AutoRotate()const |
197 | { | 197 | { |
198 | return m_states.testBit(AUTO_ROTATE); | 198 | return m_states.testBit(AUTO_ROTATE); |
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 | if (!how) { | 204 | if (!how) { |
205 | setAutoRotate(false); | 205 | setAutoRotate(false); |
206 | } | 206 | } |
207 | _image_data = QImage(); | 207 | _image_data = QImage(); |
208 | if (ImageIsJpeg() && how == false && ImageScaledLoaded()==true) { | 208 | if (ImageIsJpeg() && how == false && ImageScaledLoaded()==true) { |
209 | loadJpeg(true); | 209 | loadJpeg(true); |
210 | } | 210 | } |
211 | generateImage(); | 211 | generateImage(); |
212 | } | 212 | } |
213 | 213 | ||
214 | bool OImageScrollView::AutoScale()const | 214 | bool OImageScrollView::AutoScale()const |
215 | { | 215 | { |
216 | return m_states.testBit(AUTO_SCALE); | 216 | return m_states.testBit(AUTO_SCALE); |
217 | } | 217 | } |
218 | 218 | ||
219 | OImageScrollView::~OImageScrollView() | 219 | OImageScrollView::~OImageScrollView() |
220 | { | 220 | { |
221 | } | 221 | } |
222 | 222 | ||
223 | void OImageScrollView::rescaleImage(int w, int h) | 223 | void OImageScrollView::rescaleImage(int w, int h) |
224 | { | 224 | { |
225 | if (_image_data.width()==w && _image_data.height()==h) { | 225 | if (_image_data.width()==w && _image_data.height()==h) { |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | double hs = (double)h / (double)_image_data.height() ; | 228 | double hs = (double)h / (double)_image_data.height() ; |
229 | double ws = (double)w / (double)_image_data.width() ; | 229 | double ws = (double)w / (double)_image_data.width() ; |
230 | double scaleFactor = (hs > ws) ? ws : hs; | 230 | double scaleFactor = (hs > ws) ? ws : hs; |
231 | int smoothW = (int)(scaleFactor * _image_data.width()); | 231 | int smoothW = (int)(scaleFactor * _image_data.width()); |
232 | int smoothH = (int)(scaleFactor * _image_data.height()); | 232 | int smoothH = (int)(scaleFactor * _image_data.height()); |
233 | _image_data = _image_data.smoothScale(smoothW,smoothH); | 233 | _image_data = _image_data.smoothScale(smoothW,smoothH); |
234 | } | 234 | } |
235 | 235 | ||
236 | void OImageScrollView::rotate_into_data(Rotation r) | 236 | void OImageScrollView::rotate_into_data(Rotation r) |
237 | { | 237 | { |
238 | /* realy - we must do this that way, 'cause when acting direct on _image_data the app will | 238 | /* realy - we must do this that way, 'cause when acting direct on _image_data the app will |
239 | segfault :( */ | 239 | segfault :( */ |
240 | QImage dest; | 240 | QImage dest; |
241 | int x, y; | 241 | int x, y; |
242 | if ( _original_data.depth() > 8 ) | 242 | if ( _original_data.depth() > 8 ) |
243 | { | 243 | { |
244 | unsigned int *srcData, *destData; | 244 | unsigned int *srcData, *destData; |
245 | switch ( r ) | 245 | switch ( r ) |
246 | { | 246 | { |
247 | case Rotate90: | 247 | case Rotate90: |
248 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | 248 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); |
249 | for ( y=0; y < _original_data.height(); ++y ) | 249 | for ( y=0; y < _original_data.height(); ++y ) |
250 | { | 250 | { |
251 | srcData = (unsigned int *)_original_data.scanLine(y); | 251 | srcData = (unsigned int *)_original_data.scanLine(y); |
252 | for ( x=0; x < _original_data.width(); ++x ) | 252 | for ( x=0; x < _original_data.width(); ++x ) |
253 | { | 253 | { |
254 | destData = (unsigned int *)dest.scanLine(x); | 254 | destData = (unsigned int *)dest.scanLine(x); |
255 | destData[_original_data.height()-y-1] = srcData[x]; | 255 | destData[_original_data.height()-y-1] = srcData[x]; |
256 | } | 256 | } |
257 | } | 257 | } |
258 | break; | 258 | break; |
259 | case Rotate180: | 259 | case Rotate180: |
260 | dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); | 260 | dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); |
261 | for ( y=0; y < _original_data.height(); ++y ) | 261 | for ( y=0; y < _original_data.height(); ++y ) |
262 | { | 262 | { |
263 | srcData = (unsigned int *)_original_data.scanLine(y); | 263 | srcData = (unsigned int *)_original_data.scanLine(y); |
264 | destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1); | 264 | destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1); |
265 | for ( x=0; x < _original_data.width(); ++x ) | 265 | for ( x=0; x < _original_data.width(); ++x ) |
266 | destData[_original_data.width()-x-1] = srcData[x]; | 266 | destData[_original_data.width()-x-1] = srcData[x]; |
267 | } | 267 | } |
268 | break; | 268 | break; |
269 | case Rotate270: | 269 | case Rotate270: |
270 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | 270 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); |
271 | for ( y=0; y < _original_data.height(); ++y ) | 271 | for ( y=0; y < _original_data.height(); ++y ) |
272 | { | 272 | { |
273 | srcData = (unsigned int *)_original_data.scanLine(y); | 273 | srcData = (unsigned int *)_original_data.scanLine(y); |
274 | for ( x=0; x < _original_data.width(); ++x ) | 274 | for ( x=0; x < _original_data.width(); ++x ) |
275 | { | 275 | { |
276 | destData = (unsigned int *)dest.scanLine(_original_data.width()-x-1); | 276 | destData = (unsigned int *)dest.scanLine(_original_data.width()-x-1); |
277 | destData[y] = srcData[x]; | 277 | destData[y] = srcData[x]; |
278 | } | 278 | } |
279 | } | 279 | } |
280 | break; | 280 | break; |
281 | default: | 281 | default: |
282 | dest = _original_data; | 282 | dest = _original_data; |
283 | break; | 283 | break; |
284 | } | 284 | } |
285 | } | 285 | } |
286 | else | 286 | else |
287 | { | 287 | { |
288 | unsigned char *srcData, *destData; | 288 | unsigned char *srcData, *destData; |
289 | unsigned int *srcTable, *destTable; | 289 | unsigned int *srcTable, *destTable; |
290 | switch ( r ) | 290 | switch ( r ) |
291 | { | 291 | { |
292 | case Rotate90: | 292 | case Rotate90: |
293 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | 293 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); |
294 | dest.setNumColors(_original_data.numColors()); | 294 | dest.setNumColors(_original_data.numColors()); |
295 | srcTable = (unsigned int *)_original_data.colorTable(); | 295 | srcTable = (unsigned int *)_original_data.colorTable(); |
296 | destTable = (unsigned int *)dest.colorTable(); | 296 | destTable = (unsigned int *)dest.colorTable(); |
297 | for ( x=0; x < _original_data.numColors(); ++x ) | 297 | for ( x=0; x < _original_data.numColors(); ++x ) |
298 | destTable[x] = srcTable[x]; | 298 | destTable[x] = srcTable[x]; |
299 | for ( y=0; y < _original_data.height(); ++y ) | 299 | for ( y=0; y < _original_data.height(); ++y ) |
300 | { | 300 | { |
301 | srcData = (unsigned char *)_original_data.scanLine(y); | 301 | srcData = (unsigned char *)_original_data.scanLine(y); |
302 | for ( x=0; x < _original_data.width(); ++x ) | 302 | for ( x=0; x < _original_data.width(); ++x ) |
303 | { | 303 | { |
304 | destData = (unsigned char *)dest.scanLine(x); | 304 | destData = (unsigned char *)dest.scanLine(x); |
305 | destData[_original_data.height()-y-1] = srcData[x]; | 305 | destData[_original_data.height()-y-1] = srcData[x]; |
306 | } | 306 | } |
307 | } | 307 | } |
308 | break; | 308 | break; |
309 | case Rotate180: | 309 | case Rotate180: |
310 | dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); | 310 | dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); |
311 | dest.setNumColors(_original_data.numColors()); | 311 | dest.setNumColors(_original_data.numColors()); |
312 | srcTable = (unsigned int *)_original_data.colorTable(); | 312 | srcTable = (unsigned int *)_original_data.colorTable(); |
313 | destTable = (unsigned int *)dest.colorTable(); | 313 | destTable = (unsigned int *)dest.colorTable(); |
314 | for ( x=0; x < _original_data.numColors(); ++x ) | 314 | for ( x=0; x < _original_data.numColors(); ++x ) |
315 | destTable[x] = srcTable[x]; | 315 | destTable[x] = srcTable[x]; |
316 | for ( y=0; y < _original_data.height(); ++y ) | 316 | for ( y=0; y < _original_data.height(); ++y ) |
317 | { | 317 | { |
318 | srcData = (unsigned char *)_original_data.scanLine(y); | 318 | srcData = (unsigned char *)_original_data.scanLine(y); |
319 | destData = (unsigned char *)dest.scanLine(_original_data.height()-y-1); | 319 | destData = (unsigned char *)dest.scanLine(_original_data.height()-y-1); |
320 | for ( x=0; x < _original_data.width(); ++x ) | 320 | for ( x=0; x < _original_data.width(); ++x ) |
321 | destData[_original_data.width()-x-1] = srcData[x]; | 321 | destData[_original_data.width()-x-1] = srcData[x]; |
322 | } | 322 | } |
323 | break; | 323 | break; |
324 | case Rotate270: | 324 | case Rotate270: |
325 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | 325 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); |
326 | dest.setNumColors(_original_data.numColors()); | 326 | dest.setNumColors(_original_data.numColors()); |
327 | srcTable = (unsigned int *)_original_data.colorTable(); | 327 | srcTable = (unsigned int *)_original_data.colorTable(); |
328 | destTable = (unsigned int *)dest.colorTable(); | 328 | destTable = (unsigned int *)dest.colorTable(); |
329 | for ( x=0; x < _original_data.numColors(); ++x ) | 329 | for ( x=0; x < _original_data.numColors(); ++x ) |
330 | destTable[x] = srcTable[x]; | 330 | destTable[x] = srcTable[x]; |
331 | for ( y=0; y < _original_data.height(); ++y ) | 331 | for ( y=0; y < _original_data.height(); ++y ) |
332 | { | 332 | { |
333 | srcData = (unsigned char *)_original_data.scanLine(y); | 333 | srcData = (unsigned char *)_original_data.scanLine(y); |
334 | for ( x=0; x < _original_data.width(); ++x ) | 334 | for ( x=0; x < _original_data.width(); ++x ) |
335 | { | 335 | { |
336 | destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); | 336 | destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); |
337 | destData[y] = srcData[x]; | 337 | destData[y] = srcData[x]; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | break; | 340 | break; |
341 | default: | 341 | default: |
342 | dest = _original_data; | 342 | dest = _original_data; |
343 | break; | 343 | break; |
344 | } | 344 | } |
345 | 345 | ||
346 | } | 346 | } |
347 | _image_data = dest; | 347 | _image_data = dest; |
348 | } | 348 | } |
349 | 349 | ||
350 | void OImageScrollView::generateImage() | 350 | void OImageScrollView::generateImage() |
351 | { | 351 | { |
352 | Rotation r = Rotate0; | 352 | Rotation r = Rotate0; |
353 | if (_original_data.isNull()) return; | 353 | if (_original_data.isNull()) return; |
354 | { | 354 | { |
355 | QCopEnvelope( "QPE/System", "busy()" ); | 355 | QCopEnvelope( "QPE/System", "busy()" ); |