Fixes to ShowImage:

1. Renamed the Image menu items "Mirror Vertical" and "Mirror Horizontal" to "Flip Sideways" and "Flip Upside Down", respectively. This also involved changing the code to match the new names, for consistency.
2. Fixed a bug where zooming in and out would result in the image moving off center. This was due to the bitmap width and height not being recalculated after applying the zoom factor and therefore throwing off the calculations to find the rect for the center.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17182 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood 2006-04-21 04:24:07 +00:00
parent 48688dcd5f
commit 61ddc257d2
6 changed files with 26 additions and 22 deletions

View File

@ -1068,7 +1068,7 @@ ImageProcessor::Run(int32 i, int32 n)
}
}
break;
case kMirrorHorizontal:
case kFlipUpsideDown:
for (y = from; y <= to; y ++) {
for (x = 0; x <= fWidth; x ++) {
destX = x;
@ -1077,7 +1077,7 @@ ImageProcessor::Run(int32 i, int32 n)
}
}
break;
case kMirrorVertical:
case kFlipSideways:
for (y = from; y <= to; y ++) {
for (x = 0; x <= fWidth; x ++) {
destX = fWidth - x;

View File

@ -189,8 +189,8 @@ public:
enum operation {
kRotateClockwise,
kRotateAntiClockwise,
kMirrorVertical,
kMirrorHorizontal,
kFlipSideways,
kFlipUpsideDown,
kInvert,
kNumberOfAffineTransformations = 4
};

View File

@ -40,8 +40,8 @@ const uint32 MSG_SHRINK_TO_WINDOW = 'mSTW';
const uint32 MSG_ZOOM_TO_WINDOW = 'mZTW';
const uint32 MSG_ROTATE_90 = 'mR90';
const uint32 MSG_ROTATE_270 = 'mR27';
const uint32 MSG_MIRROR_VERTICAL = 'mMIV';
const uint32 MSG_MIRROR_HORIZONTAL = 'mMIH';
const uint32 MSG_FLIP_SIDEWAYS = 'mFSW';
const uint32 MSG_FLIP_UPSIDE_DOWN = 'mFUD';
const uint32 MSG_INVERT = 'mINV';
const uint32 MSG_SLIDE_SHOW = 'mSSW';
const uint32 MSG_SLIDE_SHOW_DELAY = 'mSSD';

View File

@ -497,18 +497,18 @@ ShowImageView::SetImage(const entry_ref *ref)
DoImageOperation(ImageProcessor::kRotateAntiClockwise, true);
break;
case k0V:
DoImageOperation(ImageProcessor::ImageProcessor::kMirrorHorizontal, true);
DoImageOperation(ImageProcessor::ImageProcessor::kFlipUpsideDown, true);
break;
case k90V:
DoImageOperation(ImageProcessor::kRotateClockwise, true);
DoImageOperation(ImageProcessor::ImageProcessor::kMirrorHorizontal, true);
DoImageOperation(ImageProcessor::ImageProcessor::kFlipUpsideDown, true);
break;
case k0H:
DoImageOperation(ImageProcessor::ImageProcessor::kMirrorVertical, true);
DoImageOperation(ImageProcessor::ImageProcessor::kFlipSideways, true);
break;
case k270V:
DoImageOperation(ImageProcessor::kRotateAntiClockwise, true);
DoImageOperation(ImageProcessor::ImageProcessor::kMirrorHorizontal, true);
DoImageOperation(ImageProcessor::ImageProcessor::kFlipUpsideDown, true);
break;
}
}
@ -741,6 +741,10 @@ ShowImageView::AlignBitmap()
rect.right = floorf(bitmapWidth * zoom) - 1;
rect.bottom = floorf(bitmapHeight * zoom) - 1;
// update the bitmap size after the zoom
bitmapWidth = rect.Width() + 1.0;
bitmapHeight = rect.Height() + 1.0;
// align
switch (fHAlignment) {
case B_ALIGN_CENTER:
@ -2388,8 +2392,8 @@ ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet)
// Note: If one of these fails, check its definition in class ImageProcessor.
ASSERT(ImageProcessor::kRotateClockwise < ImageProcessor::kNumberOfAffineTransformations);
ASSERT(ImageProcessor::kRotateAntiClockwise < ImageProcessor::kNumberOfAffineTransformations);
ASSERT(ImageProcessor::kMirrorVertical < ImageProcessor::kNumberOfAffineTransformations);
ASSERT(ImageProcessor::kMirrorHorizontal < ImageProcessor::kNumberOfAffineTransformations);
ASSERT(ImageProcessor::kFlipSideways < ImageProcessor::kNumberOfAffineTransformations);
ASSERT(ImageProcessor::kFlipUpsideDown < ImageProcessor::kNumberOfAffineTransformations);
fImageOrientation = fTransformation[op][fImageOrientation];
} else {
fInverted = !fInverted;
@ -2440,12 +2444,12 @@ ShowImageView::Rotate(int degree)
void
ShowImageView::Mirror(bool vertical)
ShowImageView::Flip(bool vertical)
{
if (vertical) {
UserDoImageOperation(ImageProcessor::kMirrorVertical);
UserDoImageOperation(ImageProcessor::kFlipSideways);
} else {
UserDoImageOperation(ImageProcessor::kMirrorHorizontal);
UserDoImageOperation(ImageProcessor::kFlipUpsideDown);
}
}

View File

@ -101,7 +101,7 @@ class ShowImageView : public BView {
// Image manipulation
void Rotate(int degree); // 90 and 270 only
void Mirror(bool vertical);
void Flip(bool vertical);
void Invert();
void SetIcon(bool clear);

View File

@ -329,8 +329,8 @@ ShowImageWindow::AddMenus(BMenuBar *bar)
AddItemMenu(menu, "Rotate -90°", MSG_ROTATE_270, '[', 0, 'W', true);
AddItemMenu(menu, "Rotate +90°", MSG_ROTATE_90, ']', 0, 'W', true);
menu->AddSeparatorItem();
AddItemMenu(menu, "Mirror Vertical", MSG_MIRROR_VERTICAL, 0, 0, 'W', true);
AddItemMenu(menu, "Mirror Horizontal", MSG_MIRROR_HORIZONTAL, 0, 0, 'W', true);
AddItemMenu(menu, "Flip Sideways", MSG_FLIP_SIDEWAYS, 0, 0, 'W', true);
AddItemMenu(menu, "Flip Upside Down", MSG_FLIP_UPSIDE_DOWN, 0, 0, 'W', true);
menu->AddSeparatorItem();
AddItemMenu(menu, "Invert", MSG_INVERT, 0, 0, 'W', true);
bar->AddItem(menu);
@ -717,11 +717,11 @@ ShowImageWindow::MessageReceived(BMessage *message)
case MSG_ROTATE_270:
fImageView->Rotate(270);
break;
case MSG_MIRROR_VERTICAL:
fImageView->Mirror(true);
case MSG_FLIP_SIDEWAYS:
fImageView->Flip(true);
break;
case MSG_MIRROR_HORIZONTAL:
fImageView->Mirror(false);
case MSG_FLIP_UPSIDE_DOWN:
fImageView->Flip(false);
break;
case MSG_INVERT:
fImageView->Invert();