mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +00:00
[PAINT]
- opening files via command line - file date, time, size and paper resolution (pix. per meter) in attributes dialog - loading/saving PpM resolution from/to file - zoom tool shows and zooms to target rectangle - implemented missing scroll bar functionality - hiding status bar via menu item prepared svn path=/trunk/; revision=43567
This commit is contained in:
parent
9c62b2152a
commit
df983244a3
27 changed files with 281 additions and 48 deletions
|
@ -165,3 +165,5 @@
|
|||
|
||||
#define IDS_OPENFILTER 926
|
||||
#define IDS_SAVEFILTER 927
|
||||
#define IDS_FILESIZE 928
|
||||
#define IDS_PRINTRES 929
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
/* INCLUDES *********************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include "definitions.h"
|
||||
#include "globalvar.h"
|
||||
|
||||
|
@ -76,6 +77,25 @@ LRESULT CALLBACK ATTDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l
|
|||
CheckDlgButton(hwnd, IDD_ATTRIBUTESRB5, BST_CHECKED);
|
||||
SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT1, imgXRes, FALSE);
|
||||
SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT2, imgYRes, FALSE);
|
||||
TCHAR strrc[100];
|
||||
if (isAFile)
|
||||
{
|
||||
TCHAR date[100];
|
||||
TCHAR size[100];
|
||||
TCHAR temp[100];
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, date, sizeof(date));
|
||||
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, temp, sizeof(temp));
|
||||
_tcscat(date, _T(" "));
|
||||
_tcscat(date, temp);
|
||||
LoadString(hProgInstance, IDS_FILESIZE, strrc, sizeof(strrc));
|
||||
_stprintf(size, strrc, fileSize);
|
||||
SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT6, date);
|
||||
SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT7, size);
|
||||
}
|
||||
TCHAR res[100];
|
||||
LoadString(hProgInstance, IDS_PRINTRES, strrc, sizeof(strrc));
|
||||
_stprintf(res, strrc, fileHPPM, fileVPPM);
|
||||
SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT8, res);
|
||||
return TRUE;
|
||||
case WM_CLOSE:
|
||||
EndDialog(hwnd, 0);
|
||||
|
|
|
@ -39,7 +39,7 @@ int GetDIBHeight(HBITMAP hBitmap)
|
|||
return bm.bmHeight;
|
||||
}
|
||||
|
||||
void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC)
|
||||
void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, int *size, int hRes, int vRes)
|
||||
{
|
||||
BITMAP bm;
|
||||
HANDLE hFile;
|
||||
|
@ -64,6 +64,8 @@ void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC)
|
|||
bi.biPlanes = bm.bmPlanes;
|
||||
bi.biBitCount = bm.bmBitsPixel;
|
||||
bi.biCompression = BI_RGB;
|
||||
bi.biXPelsPerMeter = hRes;
|
||||
bi.biYPelsPerMeter = vRes;
|
||||
|
||||
buffer = HeapAlloc(GetProcessHeap(), 0, imgDataSize);
|
||||
GetDIBits(hDC, hBitmap, 0, bm.bmHeight, buffer, (LPBITMAPINFO)&bi, DIB_RGB_COLORS);
|
||||
|
@ -76,39 +78,64 @@ void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC)
|
|||
WriteFile(hFile, &bi, sizeof(BITMAPINFOHEADER), &dwBytesWritten, NULL);
|
||||
WriteFile(hFile, buffer, imgDataSize, &dwBytesWritten, NULL);
|
||||
|
||||
if (time)
|
||||
{
|
||||
FILETIME ft;
|
||||
GetFileTime(hFile, NULL, NULL, &ft);
|
||||
FileTimeToSystemTime(&ft, time);
|
||||
}
|
||||
if (size)
|
||||
*size = GetFileSize(hFile, NULL);
|
||||
|
||||
CloseHandle(hFile);
|
||||
HeapFree(GetProcessHeap(), 0, buffer);
|
||||
}
|
||||
|
||||
HBITMAP LoadDIBFromFile(LPTSTR name)
|
||||
void LoadDIBFromFile(HBITMAP *hBitmap, LPTSTR name, LPSYSTEMTIME time, int *size, int *hRes, int *vRes)
|
||||
{
|
||||
HBITMAP hBitmap;
|
||||
BITMAPFILEHEADER bfh;
|
||||
BITMAPINFO *bi;
|
||||
PVOID pvBits;
|
||||
DWORD dwBytesRead;
|
||||
HANDLE hFile;
|
||||
|
||||
if (!hBitmap)
|
||||
return;
|
||||
|
||||
hFile = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
return;
|
||||
|
||||
/* read header and check for 'BM' magic */
|
||||
ReadFile(hFile, &bfh, sizeof(BITMAPFILEHEADER), &dwBytesRead, NULL);
|
||||
if (bfh.bfType != 0x4d42)
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (time)
|
||||
{
|
||||
FILETIME ft;
|
||||
GetFileTime(hFile, NULL, NULL, &ft);
|
||||
FileTimeToSystemTime(&ft, time);
|
||||
}
|
||||
if (size)
|
||||
*size = GetFileSize(hFile, NULL);
|
||||
|
||||
bi = HeapAlloc(GetProcessHeap(), 0, bfh.bfOffBits - sizeof(BITMAPFILEHEADER));
|
||||
if (!bi)
|
||||
return NULL;
|
||||
return;
|
||||
|
||||
ReadFile(hFile, bi, bfh.bfOffBits - sizeof(BITMAPFILEHEADER), &dwBytesRead, NULL);
|
||||
hBitmap = CreateDIBSection(NULL, bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
|
||||
*hBitmap = CreateDIBSection(NULL, bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
|
||||
ReadFile(hFile, pvBits, bfh.bfSize - bfh.bfOffBits, &dwBytesRead, NULL);
|
||||
|
||||
if (hRes)
|
||||
*hRes = (*bi).bmiHeader.biXPelsPerMeter;
|
||||
if (vRes)
|
||||
*vRes = (*bi).bmiHeader.biYPelsPerMeter;
|
||||
|
||||
CloseHandle(hFile);
|
||||
HeapFree(GetProcessHeap(), 0, bi);
|
||||
return hBitmap;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,6 @@ int GetDIBWidth(HBITMAP hbm);
|
|||
|
||||
int GetDIBHeight(HBITMAP hbm);
|
||||
|
||||
void SaveDIBToFile(HBITMAP hbm, LPTSTR name, HDC hdc);
|
||||
void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, int *size, int hRes, int vRes);
|
||||
|
||||
HBITMAP LoadDIBFromFile(LPTSTR name);
|
||||
void LoadDIBFromFile(HBITMAP *hBitmap, LPTSTR name, LPSYSTEMTIME time, int *size, int *hRes, int *vRes);
|
||||
|
|
|
@ -73,6 +73,10 @@ extern HINSTANCE hProgInstance;
|
|||
extern TCHAR filename[256];
|
||||
extern TCHAR filepathname[1000];
|
||||
extern BOOL isAFile;
|
||||
extern int fileSize;
|
||||
extern int fileHPPM;
|
||||
extern int fileVPPM;
|
||||
extern SYSTEMTIME fileTime;
|
||||
|
||||
extern BOOL showGrid;
|
||||
extern BOOL showMiniature;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* US-English Language resource file
|
||||
* Translated by: first times touched from en-GB.rc file by Mario Kacmar
|
||||
* Bulgarian Language resource file
|
||||
* Translated by:
|
||||
*/
|
||||
|
||||
LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT
|
||||
|
@ -198,4 +198,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Çàîáëåí ïðàâîúãúëíèê"
|
||||
IDS_OPENFILTER, "Ôàéëîâå bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1Âñè÷êè ôàéëîâå (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24 ðàçðÿäíè ôàéëîâå bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -197,4 +197,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Zaoblený obdélník"
|
||||
IDS_OPENFILTER, "Soubory bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1Všechny soubory (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24bitová bitmapa (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -134,12 +134,12 @@ BEGIN
|
|||
EDITTEXT IDD_ATTRIBUTESEDIT2, 110, 40, 35, 12
|
||||
LTEXT "Breite:", IDD_ATTRIBUTESTEXT1, 10, 40, 30, 10
|
||||
LTEXT "Höhe:", IDD_ATTRIBUTESTEXT2, 80, 40, 30, 10
|
||||
LTEXT "Dateidatum:", IDD_ATTRIBUTESTEXT3, 10, 5, 60, 10
|
||||
LTEXT "Dateigröße:", IDD_ATTRIBUTESTEXT4, 10, 15, 60, 10
|
||||
LTEXT "Auflösung:", IDD_ATTRIBUTESTEXT5, 10, 25, 60, 10
|
||||
LTEXT "Nicht verfügbar", IDD_ATTRIBUTESTEXT6, 70, 5, 60, 10
|
||||
LTEXT "Nicht verfügbar", IDD_ATTRIBUTESTEXT7, 70, 15, 60, 10
|
||||
LTEXT "Nicht verfügbar", IDD_ATTRIBUTESTEXT8, 70, 25, 60, 10
|
||||
LTEXT "Dateidatum:", IDD_ATTRIBUTESTEXT3, 10, 5, 50, 10
|
||||
LTEXT "Dateigröße:", IDD_ATTRIBUTESTEXT4, 10, 15, 50, 10
|
||||
LTEXT "Auflösung:", IDD_ATTRIBUTESTEXT5, 10, 25, 50, 10
|
||||
LTEXT "Nicht verfügbar", IDD_ATTRIBUTESTEXT6, 60, 5, 90, 10
|
||||
LTEXT "Nicht verfügbar", IDD_ATTRIBUTESTEXT7, 60, 15, 90, 10
|
||||
LTEXT "Nicht verfügbar", IDD_ATTRIBUTESTEXT8, 60, 25, 90, 10
|
||||
GROUPBOX "Maßeinheit", IDD_ATTRIBUTESGROUP1, 6, 57, 139, 27
|
||||
AUTORADIOBUTTON "Zoll", IDD_ATTRIBUTESRB1, 12, 69, 35, 10, WS_GROUP
|
||||
AUTORADIOBUTTON "cm", IDD_ATTRIBUTESRB2, 52, 69, 35, 10
|
||||
|
@ -197,4 +197,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Abgerundetes Rechteck"
|
||||
IDS_OPENFILTER, "Bitmapdateien (*.bmp;*.dib)\1*.bmp;*.dib\1Alle Dateien (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24-Bit-Bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d Bytes"
|
||||
IDS_PRINTRES, "%d x %d Pixel pro Meter"
|
||||
END
|
||||
|
|
|
@ -198,4 +198,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Rounded rectangle"
|
||||
IDS_OPENFILTER, "Bitmap files (*.bmp;*.dib)\1*.bmp;*.dib\1All files (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24 bit bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -198,4 +198,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Rounded rectangle"
|
||||
IDS_OPENFILTER, "Bitmap files (*.bmp;*.dib)\1*.bmp;*.dib\1All files (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24 bit bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -198,4 +198,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Rectángulo redondeado"
|
||||
IDS_OPENFILTER, "Archivos de mapa de bits (*.bmp;*.dib)\1*.bmp;*.dib\1Todos los archivos (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "Mapa de bits de 24 bits (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -195,4 +195,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Laukizuzen biribildua"
|
||||
IDS_OPENFILTER, "Bit-mapa fitxategiak(*.bmp;*.dib)\1*.bmp;*.dib\1Fitxategi gustiak (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24 Biteko bit-mapa (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -197,4 +197,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Rectangle arrondi"
|
||||
IDS_OPENFILTER, "Bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1Tous les fichiers (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "Bitmap 24 bit (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -197,4 +197,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Rettangolo arrotondato"
|
||||
IDS_OPENFILTER, "Bitmap files (*.bmp;*.dib)\1*.bmp;*.dib\1All files (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24 bit bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -198,4 +198,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "角丸四角形"
|
||||
IDS_OPENFILTER, "ビットマップ ファイル (*.bmp;*.dib)\1*.bmp;*.dib\1すべてのファイル (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24 ビット ビットマップ (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -197,4 +197,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Afgeronde rechthoek"
|
||||
IDS_OPENFILTER, "Bitmapbestanden (*.bmp;*.dib)\1*.bmp;*.dib\1Alle bestanden (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24 bit bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -197,4 +197,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Avrundet rektangel"
|
||||
IDS_OPENFILTER, "Bitmap filer (*.bmp;*.dib)\1*.bmp;*.dib\1Alle filer (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24 bit bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -200,4 +200,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Zaokr¹glony Prostok¹t"
|
||||
IDS_OPENFILTER, "Pliki Bitmapy (*.bmp;*.dib)\1*.bmp;*.dib\1Wszystkie pliki (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "Bitmapa 24 bit (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -197,4 +197,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Retângulo arredondado"
|
||||
IDS_OPENFILTER, "Arquivos de bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1Todos os arquivos (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "Bitmaps de 24 bits (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -197,4 +197,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Retângulo arredondado"
|
||||
IDS_OPENFILTER, "Ficheiros de mapa de bits (*.bmp;*.dib)\1*.bmp;*.dib\1Todos os arquivos (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "Mapa de bits de 24 bits (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -200,6 +200,8 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Dreptunghi rotunjit"
|
||||
IDS_OPENFILTER, "Fișiere bitmap (*.bmp;*.dib)\1*.bmp;*.dib\1All files (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "Bitmap pe 24 biți (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
||||
#pragma code_page(default)
|
||||
|
|
|
@ -192,4 +192,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Ñêðóãëåííûé ïðÿìîóãîëüíèê"
|
||||
IDS_OPENFILTER, "Òî÷å÷íûå ðèñóíêè (*.bmp;*.dib)\1*.bmp;*.dib\1Âñå ôàéëû (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24-ðàçðÿäíûé ðèñóíîê (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -199,4 +199,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Zaoblený obdåžnik"
|
||||
IDS_OPENFILTER, "Súbory bitových máp (*.bmp;*.dib)\1*.bmp;*.dib\1Všetky súbory (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24-bitová mapa (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -200,4 +200,6 @@ BEGIN
|
|||
IDS_TOOLTIP16, "Ïðÿìîêóòíèê ç îêðóãëåíèìè êóòàìè"
|
||||
IDS_OPENFILTER, "Òî÷êîâ³ ðèñóíêè (*.bmp;*.dib)\1*.bmp;*.dib\1Óñ³ ôàéëè (*.*)\1*.*\1"
|
||||
IDS_SAVEFILTER, "24-ðîçðÿäíèé ðèñóíîê (*.bmp;*.dib)\1*.bmp;*.dib\1"
|
||||
IDS_FILESIZE, "%d bytes"
|
||||
IDS_PRINTRES, "%d x %d pixels per meter"
|
||||
END
|
||||
|
|
|
@ -103,6 +103,10 @@ HINSTANCE hProgInstance;
|
|||
TCHAR filename[256];
|
||||
TCHAR filepathname[1000];
|
||||
BOOL isAFile = FALSE;
|
||||
int fileSize;
|
||||
int fileHPPM = 2834;
|
||||
int fileVPPM = 2834;
|
||||
SYSTEMTIME fileTime;
|
||||
|
||||
BOOL showGrid = FALSE;
|
||||
BOOL showMiniature = FALSE;
|
||||
|
@ -339,6 +343,26 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR l
|
|||
SelectObject(hDrawingDC, hBms[0]);
|
||||
Rectangle(hDrawingDC, 0-1, 0-1, imgXRes+1, imgYRes+1);
|
||||
|
||||
if (lpszArgument[0] != 0)
|
||||
{
|
||||
HBITMAP bmNew = NULL;
|
||||
LoadDIBFromFile(&bmNew, lpszArgument, &fileTime, &fileSize, &fileHPPM, &fileVPPM);
|
||||
if (bmNew!=NULL)
|
||||
{
|
||||
TCHAR tempstr[1000];
|
||||
TCHAR resstr[100];
|
||||
insertReversible(bmNew);
|
||||
TCHAR *temp;
|
||||
GetFullPathName(lpszArgument, sizeof(filepathname), filepathname, &temp);
|
||||
_tcscpy(filename, temp);
|
||||
LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
|
||||
_stprintf(tempstr, resstr, filename);
|
||||
SetWindowText(hMainWnd, tempstr);
|
||||
clearHistory();
|
||||
isAFile = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* initializing the CHOOSECOLOR structure for use with ChooseColor */
|
||||
choosecolor.lStructSize = sizeof(CHOOSECOLOR);
|
||||
choosecolor.hwndOwner = hwnd;
|
||||
|
|
|
@ -22,7 +22,7 @@ LRESULT CALLBACK SettingsWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
{
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
ZoomTo(125<<SendMessage(hTrackbarZoom, TBM_GETPOS, 0, 0));
|
||||
zoomTo(125<<SendMessage(hTrackbarZoom, TBM_GETPOS, 0, 0), 0, 0);
|
||||
}
|
||||
break;
|
||||
case WM_PAINT:
|
||||
|
|
|
@ -48,10 +48,28 @@ void updateCanvasAndScrollbars()
|
|||
SetScrollPos(hScrollbox, SB_VERT, 0, TRUE);
|
||||
}
|
||||
|
||||
void ZoomTo(int newZoom)
|
||||
void zoomTo(int newZoom, int mouseX, int mouseY)
|
||||
{
|
||||
long clientRectScrollbox[4];
|
||||
long clientRectImageArea[4];
|
||||
GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox);
|
||||
GetClientRect(hImageArea, (LPRECT)&clientRectImageArea);
|
||||
int x, y, w, h;
|
||||
w = clientRectImageArea[2] * clientRectScrollbox[2] / (clientRectImageArea[2] * newZoom / zoom);
|
||||
h = clientRectImageArea[3] * clientRectScrollbox[3] / (clientRectImageArea[3] * newZoom / zoom);
|
||||
x = max(0, min(clientRectImageArea[2] - w, mouseX - w / 2)) * newZoom / zoom;
|
||||
y = max(0, min(clientRectImageArea[3] - h, mouseY - h / 2)) * newZoom / zoom;
|
||||
|
||||
zoom = newZoom;
|
||||
updateCanvasAndScrollbars();
|
||||
|
||||
ShowWindow(hSelection, SW_HIDE);
|
||||
MoveWindow(hImageArea, 3, 3, imgXRes*zoom/1000, imgYRes*zoom/1000, FALSE);
|
||||
InvalidateRect(hScrollbox, NULL, TRUE);
|
||||
InvalidateRect(hImageArea, NULL, FALSE);
|
||||
|
||||
SendMessage(hScrollbox, WM_HSCROLL, SB_THUMBPOSITION | (x << 16), 0);
|
||||
SendMessage(hScrollbox, WM_VSCROLL, SB_THUMBPOSITION | (y << 16), 0);
|
||||
|
||||
int tbPos = 0;
|
||||
int tempZoom = newZoom;
|
||||
while (tempZoom>125)
|
||||
|
@ -62,6 +80,34 @@ void ZoomTo(int newZoom)
|
|||
SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)tbPos);
|
||||
}
|
||||
|
||||
void drawZoomFrame(int mouseX, int mouseY)
|
||||
{
|
||||
long clientRectScrollbox[4];
|
||||
long clientRectImageArea[4];
|
||||
GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox);
|
||||
GetClientRect(hImageArea, (LPRECT)&clientRectImageArea);
|
||||
int x, y, w, h;
|
||||
w = clientRectImageArea[2] * clientRectScrollbox[2] / (clientRectImageArea[2] * 2);
|
||||
h = clientRectImageArea[3] * clientRectScrollbox[3] / (clientRectImageArea[3] * 2);
|
||||
x = max(0, min(clientRectImageArea[2] - w, mouseX - w / 2));
|
||||
y = max(0, min(clientRectImageArea[3] - h, mouseY - h / 2));
|
||||
HDC hdc;
|
||||
hdc = GetDC(hImageArea);
|
||||
HPEN oldPen;
|
||||
oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 0, 0));
|
||||
HBRUSH oldBrush;
|
||||
LOGBRUSH logbrush;
|
||||
logbrush.lbStyle = BS_HOLLOW;
|
||||
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
|
||||
int rop;
|
||||
rop = SetROP2(hdc, R2_NOT);
|
||||
Rectangle(hdc, x, y, x + w, y + h);
|
||||
SetROP2(hdc, rop);
|
||||
DeleteObject(SelectObject(hdc, oldBrush));
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
ReleaseDC(hImageArea, hdc);
|
||||
}
|
||||
|
||||
HDC hdc;
|
||||
BOOL drawing;
|
||||
|
||||
|
@ -163,6 +209,11 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
CheckMenuItem(GetMenu(hMainWnd), IDM_IMAGEDRAWOPAQUE, MF_UNCHECKED | MF_BYCOMMAND);
|
||||
break;
|
||||
}
|
||||
if (IsWindowVisible(hStatusBar))
|
||||
CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSTATUSBAR, MF_CHECKED | MF_BYCOMMAND);
|
||||
else
|
||||
CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSTATUSBAR, MF_UNCHECKED | MF_BYCOMMAND);
|
||||
|
||||
if (showGrid)
|
||||
CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSHOWGRID, MF_CHECKED | MF_BYCOMMAND);
|
||||
else
|
||||
|
@ -246,46 +297,88 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
SCROLLINFO vertScroll;
|
||||
GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox);
|
||||
GetClientRect(hImageArea, (LPRECT)&clientRectImageArea);
|
||||
MoveWindow(hScrlClient, 0, 0, max(clientRectImageArea[2]+6, clientRectScrollbox[2]), max(clientRectImageArea[3]+6, clientRectScrollbox[3]), TRUE);
|
||||
horzScroll.cbSize = sizeof(SCROLLINFO);
|
||||
horzScroll.fMask = SIF_PAGE | SIF_RANGE;
|
||||
horzScroll.nMax = 10000;
|
||||
horzScroll.nMax = clientRectImageArea[2]+6-1;
|
||||
horzScroll.nMin = 0;
|
||||
horzScroll.nPage = clientRectScrollbox[2]*10000/(clientRectImageArea[2]+6);
|
||||
horzScroll.nPage = clientRectScrollbox[2];
|
||||
horzScroll.nPos = 0;
|
||||
horzScroll.nTrackPos = 0;
|
||||
SetScrollInfo(hScrollbox, SB_HORZ, &horzScroll, TRUE);
|
||||
GetClientRect(hScrollbox, (LPRECT)clientRectScrollbox);
|
||||
vertScroll.cbSize = sizeof(SCROLLINFO);
|
||||
vertScroll.fMask = SIF_PAGE | SIF_RANGE;
|
||||
vertScroll.nMax = 10000;
|
||||
vertScroll.nMax = clientRectImageArea[3]+6-1;
|
||||
vertScroll.nMin = 0;
|
||||
vertScroll.nPage = clientRectScrollbox[3]*10000/(clientRectImageArea[3]+6);
|
||||
vertScroll.nPage = clientRectScrollbox[3];
|
||||
vertScroll.nPos = 0;
|
||||
vertScroll.nTrackPos = 0;
|
||||
SetScrollInfo(hScrollbox, SB_VERT, &vertScroll, TRUE);
|
||||
MoveWindow(hScrlClient,
|
||||
-GetScrollPos(hScrollbox, SB_HORZ), -GetScrollPos(hScrollbox, SB_VERT),
|
||||
max(clientRectImageArea[2]+6, clientRectScrollbox[2]), max(clientRectImageArea[3]+6, clientRectScrollbox[3]), TRUE);
|
||||
}
|
||||
break;
|
||||
case WM_HSCROLL:
|
||||
if (hwnd==hScrollbox)
|
||||
{
|
||||
if ((LOWORD(wParam)==SB_THUMBPOSITION)||(LOWORD(wParam)==SB_THUMBTRACK))
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_ALL;
|
||||
GetScrollInfo(hScrollbox, SB_HORZ, &si);
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
SetScrollPos(hScrollbox, SB_HORZ, HIWORD(wParam), TRUE);
|
||||
MoveWindow(hScrlClient, -(imgXRes*zoom/1000+6)*GetScrollPos(hScrollbox, SB_HORZ)/10000,
|
||||
-(imgYRes*zoom/1000+6)*GetScrollPos(hScrollbox, SB_VERT)/10000, imgXRes*zoom/1000+6, imgYRes*zoom/1000+6, TRUE);
|
||||
case SB_THUMBTRACK:
|
||||
case SB_THUMBPOSITION:
|
||||
si.nPos = HIWORD(wParam);
|
||||
break;
|
||||
case SB_LINELEFT:
|
||||
si.nPos -= 5;
|
||||
break;
|
||||
case SB_LINERIGHT:
|
||||
si.nPos += 5;
|
||||
break;
|
||||
case SB_PAGELEFT:
|
||||
si.nPos -= si.nPage;
|
||||
break;
|
||||
case SB_PAGERIGHT:
|
||||
si.nPos += si.nPage;
|
||||
break;
|
||||
}
|
||||
SetScrollInfo(hScrollbox, SB_HORZ, &si, TRUE);
|
||||
MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ),
|
||||
-GetScrollPos(hScrollbox, SB_VERT), imgXRes*zoom/1000+6, imgYRes*zoom/1000+6, TRUE);
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
if (hwnd==hScrollbox)
|
||||
{
|
||||
if ((LOWORD(wParam)==SB_THUMBPOSITION)||(LOWORD(wParam)==SB_THUMBTRACK))
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_ALL;
|
||||
GetScrollInfo(hScrollbox, SB_VERT, &si);
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
SetScrollPos(hScrollbox, SB_VERT, HIWORD(wParam), TRUE);
|
||||
MoveWindow(hScrlClient, -(imgXRes*zoom/1000+6)*GetScrollPos(hScrollbox, SB_HORZ)/10000,
|
||||
-(imgYRes*zoom/1000+6)*GetScrollPos(hScrollbox, SB_VERT)/10000, imgXRes*zoom/1000+6, imgYRes*zoom/1000+6, TRUE);
|
||||
case SB_THUMBTRACK:
|
||||
case SB_THUMBPOSITION:
|
||||
si.nPos = HIWORD(wParam);
|
||||
break;
|
||||
case SB_LINEUP:
|
||||
si.nPos -= 5;
|
||||
break;
|
||||
case SB_LINEDOWN:
|
||||
si.nPos += 5;
|
||||
break;
|
||||
case SB_PAGEUP:
|
||||
si.nPos -= si.nPage;
|
||||
break;
|
||||
case SB_PAGEDOWN:
|
||||
si.nPos += si.nPage;
|
||||
break;
|
||||
}
|
||||
SetScrollInfo(hScrollbox, SB_VERT, &si, TRUE);
|
||||
MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ),
|
||||
-GetScrollPos(hScrollbox, SB_VERT), imgXRes*zoom/1000+6, imgYRes*zoom/1000+6, TRUE);
|
||||
}
|
||||
break;
|
||||
case WM_GETMINMAXINFO:
|
||||
|
@ -375,7 +468,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
undo();
|
||||
}
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
if ((activeTool==6)&&(zoom<8000)) ZoomTo(zoom*2);
|
||||
if ((activeTool==6)&&(zoom<8000)) zoomTo(zoom*2, (short)LOWORD(lParam), (short)HIWORD(lParam));
|
||||
}
|
||||
break;
|
||||
case WM_RBUTTONDOWN:
|
||||
|
@ -392,7 +485,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
undo();
|
||||
}
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
if ((activeTool==6)&&(zoom>125)) ZoomTo(zoom/2);
|
||||
if ((activeTool==6)&&(zoom>125)) zoomTo(zoom/2, (short)LOWORD(lParam), (short)HIWORD(lParam));
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
|
@ -435,6 +528,19 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
TCHAR coordStr[100];
|
||||
_stprintf(coordStr, _T("%d, %d"), (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)coordStr);
|
||||
|
||||
if (activeTool == 6)
|
||||
{
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
drawZoomFrame((short)LOWORD(lParam), (short)HIWORD(lParam));
|
||||
}
|
||||
|
||||
TRACKMOUSEEVENT tme;
|
||||
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
||||
tme.dwFlags = TME_LEAVE;
|
||||
tme.hwndTrack = hImageArea;
|
||||
tme.dwHoverTime = 0;
|
||||
TrackMouseEvent(&tme);
|
||||
}
|
||||
if (drawing)
|
||||
{
|
||||
|
@ -461,9 +567,13 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
}
|
||||
break;
|
||||
case WM_MOUSELEAVE:
|
||||
{
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)_T(""));
|
||||
if (activeTool == 6)
|
||||
SendMessage(hImageArea, WM_PAINT, 0, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -496,7 +606,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
case IDM_FILEOPEN:
|
||||
if (GetOpenFileName(&ofn)!=0)
|
||||
{
|
||||
HBITMAP bmNew = (HBITMAP)LoadDIBFromFile(ofn.lpstrFile);
|
||||
HBITMAP bmNew = NULL;
|
||||
LoadDIBFromFile(&bmNew, ofn.lpstrFile, &fileTime, &fileSize, &fileHPPM, &fileVPPM);
|
||||
if (bmNew!=NULL)
|
||||
{
|
||||
TCHAR tempstr[1000];
|
||||
|
@ -516,7 +627,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
case IDM_FILESAVE:
|
||||
if (isAFile)
|
||||
{
|
||||
SaveDIBToFile(hBms[currInd], filepathname, hDrawingDC);
|
||||
SaveDIBToFile(hBms[currInd], filepathname, hDrawingDC, &fileTime, &fileSize, fileHPPM, fileVPPM);
|
||||
imageSaved = TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -527,7 +638,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
{
|
||||
TCHAR tempstr[1000];
|
||||
TCHAR resstr[100];
|
||||
SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC);
|
||||
SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC, &fileTime, &fileSize, fileHPPM, fileVPPM);
|
||||
CopyMemory(filename, sfn.lpstrFileTitle, sizeof(filename));
|
||||
CopyMemory(filepathname, sfn.lpstrFile, sizeof(filepathname));
|
||||
LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
|
||||
|
@ -588,7 +699,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
}
|
||||
break;
|
||||
case IDM_EDITCOPYTO:
|
||||
if (GetSaveFileName(&ofn)!=0) SaveDIBToFile(hSelBm, ofn.lpstrFile, hDrawingDC);
|
||||
if (GetSaveFileName(&ofn)!=0) SaveDIBToFile(hSelBm, ofn.lpstrFile, hDrawingDC, NULL, NULL, fileHPPM, fileVPPM);
|
||||
break;
|
||||
case IDM_COLORSEDITPALETTE:
|
||||
if (ChooseColor(&choosecolor))
|
||||
|
@ -659,6 +770,13 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
insertReversible(CopyImage(hSelBm, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
|
||||
updateCanvasAndScrollbars();
|
||||
break;
|
||||
|
||||
case IDM_VIEWSTATUSBAR:
|
||||
if (IsWindowVisible(hStatusBar))
|
||||
ShowWindow(hStatusBar, SW_HIDE);
|
||||
else
|
||||
ShowWindow(hStatusBar, SW_SHOW);
|
||||
break;
|
||||
|
||||
case IDM_VIEWSHOWGRID:
|
||||
showGrid = !showGrid;
|
||||
|
@ -672,25 +790,25 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
break;
|
||||
|
||||
case IDM_VIEWZOOM125:
|
||||
ZoomTo(125);
|
||||
zoomTo(125, 0, 0);
|
||||
break;
|
||||
case IDM_VIEWZOOM25:
|
||||
ZoomTo(250);
|
||||
zoomTo(250, 0, 0);
|
||||
break;
|
||||
case IDM_VIEWZOOM50:
|
||||
ZoomTo(500);
|
||||
zoomTo(500, 0, 0);
|
||||
break;
|
||||
case IDM_VIEWZOOM100:
|
||||
ZoomTo(1000);
|
||||
zoomTo(1000, 0, 0);
|
||||
break;
|
||||
case IDM_VIEWZOOM200:
|
||||
ZoomTo(2000);
|
||||
zoomTo(2000, 0, 0);
|
||||
break;
|
||||
case IDM_VIEWZOOM400:
|
||||
ZoomTo(4000);
|
||||
zoomTo(4000, 0, 0);
|
||||
break;
|
||||
case IDM_VIEWZOOM800:
|
||||
ZoomTo(8000);
|
||||
zoomTo(8000, 0, 0);
|
||||
break;
|
||||
case ID_FREESEL:
|
||||
selectTool(1);
|
||||
|
|
Loading…
Reference in a new issue