View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0016070 | Scribus | Graphics / Image Frames | public | 2020-03-21 16:02 | 2020-04-05 19:37 |
| Reporter | Pontobart | Assigned To | jghali | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | 1.5.6.svn | ||||
| Fixed in Version | 1.5.6.svn | ||||
| Summary | 0016070: Improve AdjustFrameToImageSize | ||||
| Description | AdjustFrameToImageSize currently fails for ImageFrames that are rotated or that have inner rotations of the images. I expect that AdjustFrameToImageSize does not move the image at all. The attached patch should fix this. | ||||
| Steps To Reproduce | Take an image frame where the frame does not match the image. Rotate it. Try to adjust the frame to the image. | ||||
| Tags | No tags attached. | ||||
| Attached Files | adjust_image_to_frame.diff (2,977 bytes)
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp (Revision 23522)
+++ scribus/scribusdoc.cpp (Arbeitskopie)
@@ -15919,18 +15919,41 @@
{
if (currItem->asImageFrame() && currItem->imageIsAvailable)
{
- double w, h, x, y;
- w = currItem->OrigW * currItem->imageXScale();
- h = currItem->OrigH * currItem->imageYScale();
- x = currItem->imageXOffset() * currItem->imageXScale();
- y = currItem->imageYOffset() * currItem->imageYScale();
- if ((x != 0.0) || (y != 0.0)) // if the image frame has an offset, its assumed that the user wants the image to stay where it is
- {
- sizeItem(w, h, currItem);
- moveItem(x, y, currItem);
+ double w = currItem->OrigW * currItem->imageXScale();
+ double h = currItem->OrigH * currItem->imageYScale();
+ double x = currItem->imageXOffset() * currItem->imageXScale();
+ double y = currItem->imageYOffset() * currItem->imageYScale();
+
+ // m determines the position of the upper left corner of the image relative to
+ // the current position of the item.
+ QTransform m = QTransform().rotate(currItem->rotation());
+ double newRotation = currItem->rotation();
+ if (currItem->imageFlippedH() && currItem->imageFlippedV()) {
+ newRotation += currItem->imageRotation();
+ // Inner rotation happens around the lower right corner. m already contains the item rotation.
+ // Next we have to translate to the rotation point. For flipped images the offsets are subtracted from
+ // the opposite edge. Then we have to adjust for the inner rotation. Finally, we can translate to
+ // to the upper left corner of the image. The transformations in the other cases happen analogously.
+ m.translate(currItem->width() - x, currItem->height() - y).rotate(currItem->imageRotation()).translate(-w, -h);
+ } else if (currItem->imageFlippedH() && !currItem->imageFlippedV()) {
+ newRotation -= currItem->imageRotation();
+ // Inner rotation happens around the upper right corner.
+ m.translate(currItem->width() - x, y).rotate(-currItem->imageRotation()).translate(-w, 0);
+ } else if (!currItem->imageFlippedH() && currItem->imageFlippedV()) {
+ newRotation -= currItem->imageRotation();
+ // Inner rotation happens around the lower left corner.
+ m.translate(x, currItem->height() - y).rotate(-currItem->imageRotation()).translate(0, -h);
+ } else { /* !FlippedH and !FlippedV */
+ newRotation += currItem->imageRotation();
+ // Inner rotation happens already around the upper left corner.
+ m.translate(x, y);
}
- else
- sizeItem(w, h, currItem, true);
+ currItem->setRotation(newRotation);
+ currItem->setImageRotation(0);
+
+ sizeItem(w, h, currItem);
+ QPointF imageUpperLeft = m.map(QPointF(0, 0));
+ moveItem(imageUpperLeft.x(), imageUpperLeft.y(), currItem);
currItem->setImageXYOffset(0.0, 0.0);
}
}
| ||||
| Patch | Yes | ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2020-03-21 16:02 | Pontobart | New Issue | |
| 2020-03-21 16:02 | Pontobart | File Added: adjust_image_to_frame.diff | |
| 2020-03-22 14:36 | jghali | Assigned To | => jghali |
| 2020-03-22 14:36 | jghali | Status | new => resolved |
| 2020-03-22 14:36 | jghali | Resolution | open => fixed |
| 2020-03-22 14:36 | jghali | Fixed in Version | => 1.5.6.svn |
| 2020-03-22 14:36 | jghali | Note Added: 0047449 | |
| 2020-04-05 19:37 | cbradney | Status | resolved => closed |