Changeset View
Changeset View
Standalone View
Standalone View
imagelib/transforms/kpTransformCrop_ImageSelection.cpp
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Line(s) | 109 | { | |||
---|---|---|---|---|---|
133 | // TODO: Do not introduce a mask if the result will not contain | 133 | // TODO: Do not introduce a mask if the result will not contain | ||
134 | // any transparent pixels. | 134 | // any transparent pixels. | ||
135 | // | 135 | // | ||
136 | 136 | | |||
137 | QImage newDocImage(document()->width(), document()->height(), QImage::Format_ARGB32_Premultiplied); | 137 | QImage newDocImage(document()->width(), document()->height(), QImage::Format_ARGB32_Premultiplied); | ||
138 | newDocImage.fill(m_backgroundColor.toQRgb()); | 138 | newDocImage.fill(m_backgroundColor.toQRgb()); | ||
139 | 139 | | |||
140 | qCDebug(kpLogImagelib) << "\tsel: rect=" << m_fromSelectionPtr->boundingRect () | 140 | qCDebug(kpLogImagelib) << "\tsel: rect=" << m_fromSelectionPtr->boundingRect () | ||
141 | << " pm=" << m_fromSelectionPtr->hasContent () | 141 | << " pm=" << m_fromSelectionPtr->hasContent (); | ||
142 | << endl; | | |||
143 | QImage setTransparentImage; | 142 | QImage setTransparentImage; | ||
144 | 143 | | |||
145 | if (m_fromSelectionPtr->hasContent ()) | 144 | if (m_fromSelectionPtr->hasContent ()) | ||
146 | { | 145 | { | ||
147 | setTransparentImage = m_fromSelectionPtr->transparentImage (); | 146 | setTransparentImage = m_fromSelectionPtr->transparentImage (); | ||
148 | 147 | | |||
149 | qCDebug(kpLogImagelib) << "\thave pixmap; rect=" | 148 | qCDebug(kpLogImagelib) << "\thave pixmap; rect=" | ||
150 | << setTransparentImage.rect () | 149 | << setTransparentImage.rect (); | ||
151 | << endl; | | |||
152 | } | 150 | } | ||
153 | else | 151 | else | ||
154 | { | 152 | { | ||
155 | setTransparentImage = m_imageIfFromSelectionDoesntHaveOne; | 153 | setTransparentImage = m_imageIfFromSelectionDoesntHaveOne; | ||
156 | qCDebug(kpLogImagelib) << "\tno pixmap in sel - get it; rect=" | 154 | qCDebug(kpLogImagelib) << "\tno pixmap in sel - get it; rect=" | ||
157 | << setTransparentImage.rect () | 155 | << setTransparentImage.rect (); | ||
158 | << endl; | | |||
159 | } | 156 | } | ||
160 | 157 | | |||
161 | kpPixmapFX::paintPixmapAt (&newDocImage, | 158 | kpPixmapFX::paintPixmapAt (&newDocImage, | ||
162 | QPoint (0, 0), | 159 | QPoint (0, 0), | ||
163 | setTransparentImage); | 160 | setTransparentImage); | ||
164 | 161 | | |||
165 | 162 | | |||
166 | document ()->setImageAt (newDocImage, QPoint (0, 0)); | 163 | document ()->setImageAt (newDocImage, QPoint (0, 0)); | ||
Show All 13 Lines | 176 | { | |||
180 | qCDebug(kpLogImagelib) << "SetDocumentToSelectionImageCommand::unexecute()"; | 177 | qCDebug(kpLogImagelib) << "SetDocumentToSelectionImageCommand::unexecute()"; | ||
181 | 178 | | |||
182 | viewManager ()->setQueueUpdates (); | 179 | viewManager ()->setQueueUpdates (); | ||
183 | { | 180 | { | ||
184 | document ()->setImageAt (m_oldImage, QPoint (0, 0)); | 181 | document ()->setImageAt (m_oldImage, QPoint (0, 0)); | ||
185 | m_oldImage = kpImage (); | 182 | m_oldImage = kpImage (); | ||
186 | 183 | | |||
187 | qCDebug(kpLogImagelib) << "\tsel: rect=" << m_fromSelectionPtr->boundingRect () | 184 | qCDebug(kpLogImagelib) << "\tsel: rect=" << m_fromSelectionPtr->boundingRect () | ||
188 | << " pm=" << m_fromSelectionPtr->hasContent () | 185 | << " pm=" << m_fromSelectionPtr->hasContent (); | ||
189 | << endl; | | |||
190 | document ()->setSelection (*m_fromSelectionPtr); | 186 | document ()->setSelection (*m_fromSelectionPtr); | ||
191 | 187 | | |||
192 | environ ()->somethingBelowTheCursorChanged (); | 188 | environ ()->somethingBelowTheCursorChanged (); | ||
193 | } | 189 | } | ||
194 | viewManager ()->restoreQueueUpdates (); | 190 | viewManager ()->restoreQueueUpdates (); | ||
195 | } | 191 | } | ||
196 | 192 | | |||
197 | //--------------------------------------------------------------------- | 193 | //--------------------------------------------------------------------- | ||
198 | 194 | | |||
199 | 195 | | |||
200 | void kpTransformCrop_ImageSelection (kpMainWindow *mainWindow, | 196 | void kpTransformCrop_ImageSelection (kpMainWindow *mainWindow, | ||
201 | const QString &commandName, kpCommand *resizeDocCommand) | 197 | const QString &commandName, kpCommand *resizeDocCommand) | ||
202 | { | 198 | { | ||
203 | // Save starting selection, minus the border. | 199 | // Save starting selection, minus the border. | ||
204 | kpAbstractImageSelection *borderImageSel = | 200 | auto *borderImageSel = dynamic_cast <kpAbstractImageSelection *> ( | ||
205 | dynamic_cast <kpAbstractImageSelection *> ( | | |||
206 | mainWindow->document ()->selection ()->clone ()); | 201 | mainWindow->document ()->selection ()->clone ()); | ||
202 | | ||||
207 | Q_ASSERT (borderImageSel); | 203 | Q_ASSERT (borderImageSel); | ||
208 | 204 | | |||
209 | if ( !borderImageSel ) // make coverity happy | 205 | if ( !borderImageSel ) { // make coverity happy | ||
210 | return; | 206 | return; | ||
207 | } | ||||
211 | 208 | | |||
212 | // (only interested in border) | 209 | // (only interested in border) | ||
213 | borderImageSel->deleteContent (); | 210 | borderImageSel->deleteContent (); | ||
214 | borderImageSel->moveTo (QPoint (0, 0)); | 211 | borderImageSel->moveTo (QPoint (0, 0)); | ||
215 | 212 | | |||
216 | kpCommandEnvironment *environ = mainWindow->commandEnvironment (); | 213 | auto *environ = mainWindow->commandEnvironment (); | ||
217 | kpMacroCommand *macroCmd = new kpMacroCommand (commandName, environ); | 214 | auto *macroCmd = new kpMacroCommand (commandName, environ); | ||
218 | 215 | | |||
219 | // (must resize doc _before_ SetDocumentToSelectionImageCommand in case | 216 | // (must resize doc _before_ SetDocumentToSelectionImageCommand in case | ||
220 | // doc needs to gets bigger - else selection image may not fit) | 217 | // doc needs to gets bigger - else selection image may not fit) | ||
221 | macroCmd->addCommand (resizeDocCommand); | 218 | macroCmd->addCommand (resizeDocCommand); | ||
222 | 219 | | |||
223 | qCDebug(kpLogImagelib) << "\tis pixmap sel"; | 220 | qCDebug(kpLogImagelib) << "\tis pixmap sel"; | ||
224 | qCDebug(kpLogImagelib) << "\tcreating SetImage cmd"; | 221 | qCDebug(kpLogImagelib) << "\tcreating SetImage cmd"; | ||
225 | macroCmd->addCommand (new SetDocumentToSelectionImageCommand (environ)); | 222 | macroCmd->addCommand (new SetDocumentToSelectionImageCommand (environ)); | ||
Show All 16 Lines |