Skip to content

Commit

Permalink
Add animated GIF support to the image viewer
Browse files Browse the repository at this point in the history
Add WM_QUERYENDSESSION (OS shutdown and log off events) message handler to CWizardDlg
Enable MJPEG support in AvcodecFrameGrabber
Delete unused CPictureExWnd class
  • Loading branch information
zenden2k committed Jun 16, 2024
1 parent d011c14 commit 644e91a
Show file tree
Hide file tree
Showing 15 changed files with 269 additions and 1,675 deletions.
2 changes: 1 addition & 1 deletion COMPILING.MD
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Run on Windows:
git config --global core.autocrlf false
```

Allow creating symlinks (you can do it by turning on Developer Mode on Windows 11). Another ways is to run Visual Studio Developer Command Prompt as Administrator.
Allow creating symlinks (you can do it by turning on Developer Mode on Windows 11). Another way is to run Visual Studio Developer Command Prompt as Administrator.


## Prerequisites (on Windows)
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Network/NetworkClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ NetworkClient::NetworkClient()
curl_easy_setopt(curl_handle, CURLOPT_SOCKOPTFUNCTION, &set_sockopts);
curl_easy_setopt(curl_handle, CURLOPT_SOCKOPTDATA, this);

//curl_easy_setopt(curl_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2);

/*
TODO: use new progress callbacks
#if LIBCURL_VERSION_NUM >= 0x072000
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Network/Tests/CurlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ TEST_F(CurlTest, CurlTest) {
#endif
EXPECT_NE(data->features & CURL_VERSION_HTTPS_PROXY, 0);
EXPECT_TRUE(data->ssl_version != nullptr);
//EXPECT_NE(data->features & CURL_VERSION_HTTP2, 0);
}

17 changes: 17 additions & 0 deletions Source/Core/Utils/CoreUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ class defer {
}
};

struct freer
{
void operator()(void* p) const noexcept {
std::free(p);
}
};

template<class T>
using unique_c_ptr = std::unique_ptr<T, freer>;

template<class T>
[[nodiscard]] unique_c_ptr<T>
make_unique_malloc(std::size_t size) noexcept
{
static_assert(std::is_trivial_v<T>);
return unique_c_ptr<T>{static_cast<T*>(std::malloc(size))};
}
namespace IuCoreUtils
{
// A version of fopen() function which supports utf8 file names
Expand Down
2 changes: 0 additions & 2 deletions Source/Gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ set(SRC_LIST
Controls/IconButton.cpp
Controls/LogListBox.cpp
Controls/MyImage.cpp
Controls/PictureExWnd.cpp
Controls/ServerSelectorControl.cpp
Controls/MultiServerSelectorControl.cpp
Controls/TabListBox.cpp
Expand Down Expand Up @@ -270,7 +269,6 @@ set(HEADER_LIST
Controls/IconButton.h
Controls/LogListBox.h
Controls/MyImage.h
Controls/PictureExWnd.h
Controls/ServerSelectorControl.h
Controls/MultiServerSelectorControl.h
Controls/TabListBox.h
Expand Down
39 changes: 23 additions & 16 deletions Source/Gui/Controls/ImageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ CImageViewWindow::~CImageViewWindow()
LRESULT CImageViewWindow::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
RECT rc = {380, 37, 636, 240};
Img.Create(m_hWnd, rc, 0, WS_CHILD | WS_VISIBLE);
Img.HideParent = true;
imageControl_.Create(m_hWnd, rc, 0, WS_CHILD | WS_VISIBLE);
imageControl_.setHideParent(true);

SetFocus();
return 0; // Let the system set the focus
}
Expand All @@ -48,14 +49,15 @@ LRESULT CImageViewWindow::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOO

LRESULT CImageViewWindow::OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
return ShowWindow(SW_HIDE);
hide();
return 0;
}

LRESULT CImageViewWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
switch (wParam) {
case kDblClickTimer:
{
Img.HideParent = true;
imageControl_.setHideParent(true);
KillTimer(kDblClickTimer);
}
break;
Expand All @@ -70,11 +72,11 @@ LRESULT CImageViewWindow::OnKillFocus(HWND hwndNewFocus)

bool CImageViewWindow::ViewImage(const CImageViewItem& item, HWND Parent){
currentItem_ = item;
std::unique_ptr<GdiPlusImage> srcImg = ImageUtils::LoadImageFromFileExtended(item.fileName);
if (!srcImg) {
srcImg_ = ImageUtils::LoadImageFromFileExtended(item.fileName);
if (!srcImg_) {
return false;
}
Gdiplus::Bitmap* img = srcImg->getBitmap();
Gdiplus::Bitmap* img = srcImg_->getBitmap();

if (img) {
float width = static_cast<float>(GetSystemMetrics(SM_CXSCREEN) - 12);
Expand All @@ -101,16 +103,15 @@ bool CImageViewWindow::ViewImage(const CImageViewItem& item, HWND Parent){

if (realwidth < 200) realwidth = 200;
if (realheight < 180) realheight = 180;
//ShowWindow(SW_HIDE);

//MoveWindow(0, 0, realwidth, realheight);
Img.MoveWindow(0, 0, realwidth, realheight);
Img.loadImage(item.fileName, img);
imageControl_.MoveWindow(0, 0, realwidth, realheight);
imageControl_.loadImage(item.fileName, img);
imageControl_.ShowWindow(SW_SHOW);

currentParent_ = Parent;
MyCenterWindow(Parent, realwidth, realheight);
if (!IsWindowVisible()) {
Img.HideParent = false;
imageControl_.setHideParent(false);
SetTimer(kDblClickTimer, 300);
}
ShowWindow(SW_SHOW);
Expand All @@ -122,8 +123,9 @@ bool CImageViewWindow::ViewImage(const CImageViewItem& item, HWND Parent){

LRESULT CImageViewWindow::OnActivate(UINT state, BOOL fMinimized, HWND hwndActDeact)
{
if (state == WA_INACTIVE)
return ShowWindow(SW_HIDE);
if (state == WA_INACTIVE) {
hide();
}
return 0;
}

Expand Down Expand Up @@ -220,11 +222,16 @@ LRESULT CImageViewWindow::OnKeyDown(TCHAR vk, UINT cRepeat, UINT flags)
break;
case VK_RETURN:
case VK_ESCAPE:
ShowWindow(SW_HIDE);
hide();
}
return 0;
}

void CImageViewWindow::setCallback(CImageViewCallback* callback) {
callback_ = callback;
}

void CImageViewWindow::hide() {
ShowWindow(SW_HIDE);
imageControl_.reset();
}
9 changes: 8 additions & 1 deletion Source/Gui/Controls/ImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
*/

#pragma once
#include <memory.h>

#include "resource.h" // main symbols
#include "myimage.h"
#include <atlcrack.h>

// CImageView

class GdiPlusImage;
struct CImageViewItem {
CImageViewItem() {
index = -1;
Expand Down Expand Up @@ -66,17 +69,21 @@ class CImageViewWindow :
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
CMyImage Img;

LRESULT OnKillFocus(HWND hwndNewFocus);
LRESULT OnKeyDown(TCHAR vk, UINT cRepeat, UINT flags);
void setCallback(CImageViewCallback* callback);
bool ViewImage(const CImageViewItem&, HWND Parent = NULL);
LRESULT OnActivate(UINT state, BOOL fMinimized, HWND hwndActDeact);
void MyCenterWindow(HWND hWndCenter, int width, int height);
void hide();
protected:
CImageViewCallback* callback_;
CImageViewItem currentItem_;
std::unique_ptr<GdiPlusImage> srcImg_;
HWND currentParent_;
CMyImage imageControl_;
//CPictureExWnd animationControl_;
};


Loading

0 comments on commit 644e91a

Please sign in to comment.