95 } |
95 } |
96 |
96 |
97 /*! |
97 /*! |
98 Returns target centering |
98 Returns target centering |
99 */ |
99 */ |
100 bool HsWallpaperImageReader::getCenterTarget() |
100 bool HsWallpaperImageReader::centerTarget() |
101 { |
101 { |
102 return mCenterTarget; |
102 return mCenterTarget; |
103 } |
103 } |
104 |
104 |
105 /*! |
105 /*! |
106 Returns processed image |
106 Returns processed image |
107 */ |
107 */ |
108 QImage HsWallpaperImageReader::getProcessedImage() const |
108 QImage HsWallpaperImageReader::processedImage() const |
109 { |
109 { |
110 return mProcessedImage; |
110 return mProcessedImage; |
111 } |
111 } |
112 |
112 |
113 /*! |
113 /*! |
115 Scales and crops (if needed) image using target rect. |
115 Scales and crops (if needed) image using target rect. |
116 Centers target rect automatically if mCenterTarget is true. |
116 Centers target rect automatically if mCenterTarget is true. |
117 Pass empty set sourceRect to empty to use full size source image as starting point. |
117 Pass empty set sourceRect to empty to use full size source image as starting point. |
118 Returns processed image or null image if operation fails. |
118 Returns processed image or null image if operation fails. |
119 */ |
119 */ |
120 void HsWallpaperImageReader::processImage() |
120 void HsWallpaperImageReader::run() |
121 { |
121 { |
122 QImageReader imageReader(mSourcePath); |
122 QImageReader imageReader(mSourcePath); |
123 |
123 |
124 QRect tempTargetRect = mTargetRect; |
124 QRect tempTargetRect = mTargetRect; |
125 QRect tempSourceRect = mSourceRect; |
125 QRect tempSourceRect = mSourceRect; |
126 |
126 |
127 if (imageReader.canRead()) { |
127 if (imageReader.canRead()) { |
128 QSize sourceSize = imageReader.size(); |
128 QSize sourceSize = imageReader.size(); |
129 if (tempSourceRect.isEmpty()) { |
129 if (tempSourceRect.isEmpty()) { |
130 // If sourceRect not defined, uses full size image as source. |
130 // If sourceRect not defined, uses full size image as source. |
131 tempSourceRect.setRect(0, 0, sourceSize.width(), sourceSize.height()); |
131 tempSourceRect.setRect(0, 0, sourceSize.width(), sourceSize.height()); |
132 } |
132 } |
133 sourceSize.scale(tempTargetRect.width(), tempTargetRect.height(), |
133 sourceSize.scale(tempTargetRect.width(), tempTargetRect.height(), |
134 Qt::KeepAspectRatioByExpanding); |
134 Qt::KeepAspectRatioByExpanding); |
135 imageReader.setScaledSize(sourceSize); |
135 imageReader.setScaledSize(sourceSize); |
136 |
136 |
137 if (mCenterTarget) { |
137 if (mCenterTarget) { |
138 tempTargetRect.moveCenter(QPoint(sourceSize.width() / 2, sourceSize.height() / 2)); |
138 tempTargetRect.moveCenter(QPoint(sourceSize.width() / 2, sourceSize.height() / 2)); |