mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[0.4.10][MSPAINT] Revert LoadDIBFromFile for workaround (#2186) CORE-16566
This fixes the regression of mspaint not being able any longer to overwrite an existing file. The regression was once introduced by 0.4.7-dev-118-g44fc547ffa
when trying to determine the resolution on load. Our new fix does cover both issues and even reduces imports: win-win. fix cherry picked from commit 0.4.14-dev-691-gbe40a0e296
This commit is contained in:
parent
f38baae9e7
commit
46518043cb
2 changed files with 8 additions and 8 deletions
|
@ -34,6 +34,6 @@ add_rc_deps(rsrc.rc ${mspaint_rc_deps})
|
||||||
add_executable(mspaint ${SOURCE} rsrc.rc)
|
add_executable(mspaint ${SOURCE} rsrc.rc)
|
||||||
set_module_type(mspaint win32gui UNICODE)
|
set_module_type(mspaint win32gui UNICODE)
|
||||||
target_link_libraries(mspaint atlnew uuid)
|
target_link_libraries(mspaint atlnew uuid)
|
||||||
add_importlibs(mspaint hhctrl comdlg32 shell32 user32 gdi32 gdiplus advapi32 comctl32 msvcrt kernel32 rpcrt4 shlwapi)
|
add_importlibs(mspaint hhctrl comdlg32 shell32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 rpcrt4 shlwapi)
|
||||||
add_pch(mspaint precomp.h SOURCE)
|
add_pch(mspaint precomp.h SOURCE)
|
||||||
add_cd_file(TARGET mspaint DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET mspaint DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -83,8 +83,9 @@ void ShowFileLoadError(LPCTSTR name)
|
||||||
void
|
void
|
||||||
LoadDIBFromFile(HBITMAP * hBitmap, LPCTSTR name, LPSYSTEMTIME time, int *size, int *hRes, int *vRes)
|
LoadDIBFromFile(HBITMAP * hBitmap, LPCTSTR name, LPSYSTEMTIME time, int *size, int *hRes, int *vRes)
|
||||||
{
|
{
|
||||||
using namespace Gdiplus;
|
CImage img;
|
||||||
Bitmap img(CStringW(name), FALSE); // always use WCHAR string
|
img.Load(name);
|
||||||
|
*hBitmap = img.Detach();
|
||||||
|
|
||||||
if (!hBitmap)
|
if (!hBitmap)
|
||||||
{
|
{
|
||||||
|
@ -92,8 +93,6 @@ LoadDIBFromFile(HBITMAP * hBitmap, LPCTSTR name, LPSYSTEMTIME time, int *size, i
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
img.GetHBITMAP(Color(255, 255, 255), hBitmap);
|
|
||||||
|
|
||||||
// update time and size
|
// update time and size
|
||||||
HANDLE hFile =
|
HANDLE hFile =
|
||||||
CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
|
@ -112,9 +111,10 @@ LoadDIBFromFile(HBITMAP * hBitmap, LPCTSTR name, LPSYSTEMTIME time, int *size, i
|
||||||
if (size)
|
if (size)
|
||||||
*size = GetFileSize(hFile, NULL);
|
*size = GetFileSize(hFile, NULL);
|
||||||
|
|
||||||
// update hRes and vRes
|
HDC hScreenDC = GetDC(NULL);
|
||||||
*hRes = (int) (img.GetHorizontalResolution() * 1000 / 25.4);
|
*hRes = (int)(GetDeviceCaps(hScreenDC, LOGPIXELSX) * 1000 / 25.4);
|
||||||
*vRes = (int) (img.GetVerticalResolution() * 1000 / 25.4);
|
*vRes = (int)(GetDeviceCaps(hScreenDC, LOGPIXELSY) * 1000 / 25.4);
|
||||||
|
ReleaseDC(NULL, hScreenDC);
|
||||||
|
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue