#ifndef __ImageViewerImageWindow__ #define __ImageViewerImageWindow__ /** @file Subclass of ImageWindow, which is generated by wxFormBuilder. */ #include "ImageViewer.h" //// end generated include #include #include #include "../res/app_icon.h" #include "../utils.h" /** Implementing ImageWindow */ class ImageViewerImageWindow : public ImageWindow { protected: // Handlers for ImageWindow events. void OnDropFile(wxDropFilesEvent &event); void OnWindowKeyUp(wxKeyEvent &event); void OnWindowMouseWheel(wxMouseEvent &event); void WindowOnSize(wxSizeEvent &event); void OnBitmapDoubleLeftClick(wxMouseEvent &event); void OnListItemSelected(wxListEvent &event); void OnRotateLeftClicked(wxCommandEvent &event); void OnRotateRightClicked(wxCommandEvent &event); void OnZoomInClicked(wxCommandEvent &event); void OnZoomResetClicked(wxCommandEvent &event); void OnZoomOutClicked(wxCommandEvent &event); void OnShowFullScreenClick(wxCommandEvent &event); public: /** Constructor */ ImageViewerImageWindow(wxWindow *parent); //// end generated class members private: wxString windowTitle; /// @brief int imagelist id, wxImage the image std::map images; wxImage currentVisibleImage; wxImage currentOriginalImage; wxImageList *imgList; int currentZoom = 100; void ShowImage(wxImage img); wxImage FitImage(wxImage img, int targetWidth, int targetHeight); wxImage RotateImage(ImageUtils::ROTATE_DIRECTION dir, wxImage img); void ZoomImage(int factor); inline wxImage cropResizeImage(const wxImage &originalImage, int targetWidth, int targetHeight) { int originalWidth = originalImage.GetWidth(); int originalHeight = originalImage.GetHeight(); double aspectRatio = static_cast(originalWidth) / static_cast(originalHeight); int newWidth = targetWidth; int newHeight = targetHeight; // Kiszámítjuk az új méreteket, hogy megtartsuk a képarányt if (originalWidth > targetWidth || originalHeight > targetHeight) { if (aspectRatio > 1.0) { // Szélesség alapján skálázzuk az új méretet newWidth = targetWidth; newHeight = static_cast(targetWidth / aspectRatio); } else { // Magasság alapján skálázzuk az új méretet newHeight = targetHeight; newWidth = static_cast(targetHeight * aspectRatio); } } // Méretezzük az eredeti képet az új méretekre wxImage resizedImage = originalImage.Scale(newWidth, newHeight); // Üres terület hozzáadása és transzparens töltése if (newWidth < targetWidth || newHeight < targetHeight) { wxImage finalImage(targetWidth, targetHeight); finalImage.SetAlpha(); finalImage.Paste(resizedImage, (targetWidth - newWidth) / 2, (targetHeight - newHeight) / 2); return finalImage; } return resizedImage; } }; #endif // __ImageViewerImageWindow__