From e62a6973498c3cf4861d411da9948beb72bb6ade Mon Sep 17 00:00:00 2001 From: Janus Date: Tue, 21 Apr 2015 08:42:05 +0000 Subject: [PATCH] ShowImage: Set width and height attributes of the showed image. * Fixes #8745. --- src/apps/showimage/ShowImageWindow.cpp | 26 ++++++++++++++++++++++++++ src/apps/showimage/ShowImageWindow.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index e5ca3aa73e..64ad09d77f 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -647,6 +647,9 @@ ShowImageWindow::MessageReceived(BMessage* message) Show(); } _UpdateRatingMenu(); + // Set width and height attributes of the currently showed file. + // This should only be a temporary solution. + _SaveWidthAndHeight(); break; } @@ -1510,6 +1513,29 @@ ShowImageWindow::_UpdateRatingMenu() } +void +ShowImageWindow::_SaveWidthAndHeight() +{ + if (fNavigator.CurrentPage() != 1) + return; + + if (fImageView->Bitmap() == NULL) + return; + + BRect bounds = fImageView->Bitmap()->Bounds(); + int32 width, height; + width = bounds.IntegerWidth() + 1; + height = bounds.IntegerHeight() + 1; + + BFile file(&fNavigator.CurrentRef(), B_WRITE_ONLY); + if (file.InitCheck() != B_OK) + return; + + file.WriteAttr("Media:Width", B_INT32_TYPE, 0, &width, sizeof(width)); + file.WriteAttr("Media:Height", B_INT32_TYPE, 0, &height, sizeof(height)); +} + + void ShowImageWindow::_SetToolBarVisible(bool visible, bool animate) { diff --git a/src/apps/showimage/ShowImageWindow.h b/src/apps/showimage/ShowImageWindow.h index 33a628a4f5..32fc6d174b 100644 --- a/src/apps/showimage/ShowImageWindow.h +++ b/src/apps/showimage/ShowImageWindow.h @@ -108,6 +108,8 @@ private: bool animate = false); void _SetToolBarBorder(bool visible); + void _SaveWidthAndHeight(); + private: ImageFileNavigator fNavigator; BFilePanel* fSavePanel;