mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 05:00:27 +00:00
[SHIMGVW]
- Add Save button functionality. Patch by Ricardo Hanke. CORE-7702 svn path=/trunk/; revision=61301
This commit is contained in:
parent
b72d77fce3
commit
4d6844c0b2
2 changed files with 76 additions and 3 deletions
|
@ -17,6 +17,7 @@ add_importlibs(shimgvw
|
||||||
user32
|
user32
|
||||||
gdi32
|
gdi32
|
||||||
gdiplus
|
gdiplus
|
||||||
|
comdlg32
|
||||||
msvcrt
|
msvcrt
|
||||||
kernel32
|
kernel32
|
||||||
ntdll)
|
ntdll)
|
||||||
|
|
|
@ -22,8 +22,10 @@
|
||||||
#include <wingdi.h>
|
#include <wingdi.h>
|
||||||
#include <objbase.h>
|
#include <objbase.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
#include <commdlg.h>
|
||||||
#include <gdiplus.h>
|
#include <gdiplus.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
@ -69,6 +71,75 @@ static void pLoadImage(LPWSTR szOpenFileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pSaveImageAs(HWND hwnd)
|
||||||
|
{
|
||||||
|
OPENFILENAMEW sfn;
|
||||||
|
ImageCodecInfo *codecInfo;
|
||||||
|
WCHAR szSaveFileName[MAX_PATH];
|
||||||
|
WCHAR szFilterMask[2048];
|
||||||
|
GUID rawFormat;
|
||||||
|
UINT num;
|
||||||
|
UINT size;
|
||||||
|
UINT sizeRemain;
|
||||||
|
UINT j;
|
||||||
|
WCHAR *c;
|
||||||
|
|
||||||
|
ZeroMemory(szSaveFileName, sizeof(szSaveFileName));
|
||||||
|
ZeroMemory(szFilterMask, sizeof(szFilterMask));
|
||||||
|
ZeroMemory(&sfn, sizeof(sfn));
|
||||||
|
sfn.lStructSize = sizeof(sfn);
|
||||||
|
sfn.hwndOwner = hwnd;
|
||||||
|
sfn.hInstance = hInstance;
|
||||||
|
sfn.lpstrFile = szSaveFileName;
|
||||||
|
sfn.lpstrFilter = szFilterMask;
|
||||||
|
sfn.nMaxFile = MAX_PATH;
|
||||||
|
sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
|
||||||
|
|
||||||
|
GdipGetImageEncodersSize(&num, &size);
|
||||||
|
codecInfo = malloc(size);
|
||||||
|
if (!codecInfo)
|
||||||
|
{
|
||||||
|
DPRINT1("malloc() failed in pSaveImageAs()\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GdipGetImageEncoders(num, size, codecInfo);
|
||||||
|
GdipGetImageRawFormat(image, &rawFormat);
|
||||||
|
|
||||||
|
sizeRemain = sizeof(szFilterMask);
|
||||||
|
c = szFilterMask;
|
||||||
|
|
||||||
|
for (j = 0; j < num; ++j)
|
||||||
|
{
|
||||||
|
StringCbPrintfExW(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", codecInfo[j].FormatDescription, codecInfo[j].FilenameExtension);
|
||||||
|
|
||||||
|
/* Skip the NULL character */
|
||||||
|
c++;
|
||||||
|
sizeRemain -= sizeof(*c);
|
||||||
|
|
||||||
|
StringCbPrintfExW(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", codecInfo[j].FilenameExtension);
|
||||||
|
|
||||||
|
/* Skip the NULL character */
|
||||||
|
c++;
|
||||||
|
sizeRemain -= sizeof(*c);
|
||||||
|
|
||||||
|
if (IsEqualGUID(&rawFormat, &codecInfo[j].FormatID) == TRUE)
|
||||||
|
{
|
||||||
|
sfn.nFilterIndex = j + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetSaveFileNameW(&sfn))
|
||||||
|
{
|
||||||
|
if (GdipSaveImageToFile(image, szSaveFileName, &codecInfo[sfn.nFilterIndex - 1].Clsid, NULL) != Ok)
|
||||||
|
{
|
||||||
|
DPRINT1("GdipSaveImageToFile() failed\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(codecInfo);
|
||||||
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
ImageView_DrawImage(HWND hwnd)
|
ImageView_DrawImage(HWND hwnd)
|
||||||
{
|
{
|
||||||
|
@ -332,6 +403,7 @@ ImageView_WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IDC_SAVE:
|
case IDC_SAVE:
|
||||||
|
pSaveImageAs(hwnd);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IDC_PRINT:
|
case IDC_PRINT:
|
||||||
|
@ -453,7 +525,7 @@ ImageView_CreateWindow(HWND hwnd, LPWSTR szFileName)
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
WndClass.lpszClassName = _T("shimgvw_window");
|
WndClass.lpszClassName = _T("shimgvw_window");
|
||||||
WndClass.lpfnWndProc = (WNDPROC)ImageView_WndProc;
|
WndClass.lpfnWndProc = ImageView_WndProc;
|
||||||
WndClass.hInstance = hInstance;
|
WndClass.hInstance = hInstance;
|
||||||
WndClass.style = CS_HREDRAW | CS_VREDRAW;
|
WndClass.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
WndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON));
|
WndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||||
|
|
Loading…
Reference in a new issue