Bug fixes.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5350 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -385,30 +385,32 @@ ShowImageView::AlignBitmap()
|
|||||||
{
|
{
|
||||||
BRect rect(fpBitmap->Bounds());
|
BRect rect(fpBitmap->Bounds());
|
||||||
float width, height;
|
float width, height;
|
||||||
width = Bounds().Width()-2*PEN_SIZE;
|
width = Bounds().Width()-2*PEN_SIZE+1;
|
||||||
height = Bounds().Height()-2*PEN_SIZE;
|
height = Bounds().Height()-2*PEN_SIZE+1;
|
||||||
if (width == 0 || height == 0) return rect;
|
if (width == 0 || height == 0) return rect;
|
||||||
if (fResizeToViewBounds) {
|
if (fResizeToViewBounds) {
|
||||||
float s;
|
float s;
|
||||||
s = width / rect.Width();
|
s = width / (rect.Width()+1);
|
||||||
|
|
||||||
if (s * rect.Height() <= height) {
|
if (s * rect.Height() <= height) {
|
||||||
|
// XXX temporary solution, fZoom should not be changed here
|
||||||
fZoom = s;
|
fZoom = s;
|
||||||
rect.right = width;
|
rect.right = width-1;
|
||||||
rect.bottom = s * rect.Height();
|
rect.bottom = static_cast<int>(s * (rect.Height()+1))-1;
|
||||||
// center vertically
|
// center vertically
|
||||||
rect.OffsetBy(0, (height - rect.Height()) / 2);
|
rect.OffsetBy(0, (height - rect.Height()) / 2);
|
||||||
} else {
|
} else {
|
||||||
fZoom = height / rect.Height();
|
// XXX temporary solution, fZoom should not be changed here
|
||||||
rect.right = fZoom * rect.Width();
|
fZoom = height / (rect.Height()+1);
|
||||||
rect.bottom = height;
|
rect.right = static_cast<int>(fZoom * (rect.Width()+1))-1;
|
||||||
|
rect.bottom = height-1;
|
||||||
// center horizontally
|
// center horizontally
|
||||||
rect.OffsetBy((width - rect.Width()) / 2, 0);
|
rect.OffsetBy((width - rect.Width()) / 2, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// zoom image
|
// zoom image
|
||||||
rect.right = ((int)(rect.right+1)*fZoom)-1;
|
rect.right = static_cast<int>((rect.right+1)*fZoom)-1;
|
||||||
rect.bottom = ((int)(rect.bottom+1)*fZoom)-1;
|
rect.bottom = static_cast<int>((rect.bottom+1)*fZoom)-1;
|
||||||
// align
|
// align
|
||||||
switch (fHAlignment) {
|
switch (fHAlignment) {
|
||||||
case B_ALIGN_CENTER:
|
case B_ALIGN_CENTER:
|
||||||
|
|||||||
Reference in New Issue
Block a user