1
//--------------------------------------------------------------------------------
3
// ImageLib Windows (GDI) Test Source
4
// Copyright (C) 2000-2002 by Denton Woods
5
// Last modified: 05/29/2002 <--Y2K Compliant! =]
7
// Filename: testil/windowstest/windowstest.c
9
// Description: Full GDI test application for DevIL.
11
// Note: This requires FluidStudio's Colour Picker library to compile
12
// properly (available at http://www.fluidstudios.com/publications.html).
14
//--------------------------------------------------------------------------------
27
//#pragma comment(lib, "sdl.lib")
28
//#pragma comment(lib, "sdlmain.lib")
29
#pragma comment(lib, "colorpicker.lib")
35
BITMAPINFOHEADER BmpInfo;
36
HDC hDC = 0, hMemDC = 0;
42
#define MIN_W 205 // Accomodate the menu bar.
45
#define TITLE "DevIL Windows Test"
46
ILuint NumUndosAllowed = 4, UndoSize = 0;
47
ILuint Undos[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
48
ILuint Width, Height, Depth; // Main image
49
char CurFileName[2048];
53
ILdouble last_elapsed, cur_elapsed, elapsed;
56
ILuint FilterParamInt;
57
ILfloat FilterParamFloat;
58
char FilterEditString[255];
62
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
63
BOOL APIENTRY AboutDlgProc (HWND hDlg, UINT message, UINT wParam, LONG lParam);
64
BOOL APIENTRY PropertiesDlgProc (HWND hDlg, UINT message, UINT wParam, LONG lParam);
65
BOOL APIENTRY FilterDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam);
66
BOOL APIENTRY ResizeDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam);
67
BOOL APIENTRY BatchDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam);
68
void BatchConv(char *Directory, char *ExtList, char *ConvExt, bool Recurse);
69
void GenFilterString(char *Out, char **Strings);
72
bool IsOpenable(char *FileName);
75
// Colour picker export
76
__declspec( dllexport ) bool WINAPI FSColorPickerDoModal(unsigned int * currentColor, unsigned int * originalColor, const int initialExpansionState);
80
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
88
BackBrush = CreateSolidBrush(RGB(128,128,128));
90
wcex.cbSize = sizeof(WNDCLASSEX);
91
wcex.style = CS_HREDRAW | CS_VREDRAW;
92
wcex.lpfnWndProc = (WNDPROC)WndProc;
95
wcex.hInstance = hInstance;
96
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
97
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
98
wcex.hbrBackground = BackBrush;
99
wcex.lpszMenuName = (LPCSTR)IDR_MENU1;
100
wcex.lpszClassName = TITLE;
101
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_ICON1);
103
RegisterClassEx(&wcex);
105
HWnd = CreateWindow(TITLE, TITLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
106
50, 50, 400, 300, NULL, NULL, hInstance, NULL);
110
//if (SDL_Init(SDL_INIT_TIMER) < 0)
114
// Display the window
115
ShowWindow(HWnd, nCmdShow);
121
ilutRenderer(ILUT_WIN32);
123
// Is there a file to load from the command-line?
125
ilGenImages(1, Undos);
126
ilBindImage(Undos[0]);
127
if (ilLoadImage(__argv[1])) {
128
//ilConvertImage(IL_BGRA);
129
ilutRenderer(ILUT_WIN32);
132
sprintf(NewTitle, "%s - %s", TITLE, __argv[1]);
133
SetWindowText(HWnd, NewTitle);
137
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDR_MENU1);
139
while (GetMessage(&msg, NULL, 0, 0)) {
140
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
141
TranslateMessage(&msg);
142
DispatchMessage(&msg);
146
return (int)msg.wParam;
152
ILuint CopyName, CurName, CurImg, CurMip;
155
hMemDC = CreateCompatibleDC(hDC);
156
CurName = ilGetInteger(IL_CUR_IMAGE);
157
CurImg = ilGetInteger(IL_ACTIVE_IMAGE);
158
CurMip = ilGetInteger(IL_ACTIVE_MIPMAP);
159
CopyName = ilCloneCurImage();
160
ilBindImage(CopyName);
161
ilConvertImage(IL_BGR, IL_UNSIGNED_BYTE);
162
hBitmap = ilutConvertToHBitmap(hDC);
163
ilutGetBmpInfo((BITMAPINFO*)&BmpInfo);
164
DeleteObject(SelectObject(hMemDC, hBitmap));
165
ilBindImage(CurName);
167
ilActiveImage(CurImg);
169
ilActiveMipmap(CurMip);
170
ilDeleteImages(1, &CopyName);
179
DeleteObject(hBitmap);
183
ReleaseDC(HWnd, hDC);
195
static RECT Rect1, Rect2;
196
static ILint NewW, NewH;
198
SystemParametersInfo(SPI_GETWORKAREA, 0, &Rect1, 0);
200
GetWindowRect(HWnd, &Rect2);
202
Width = ilGetInteger(IL_IMAGE_WIDTH);
203
Height = ilGetInteger(IL_IMAGE_HEIGHT);
204
Depth = ilGetInteger(IL_IMAGE_DEPTH);
206
NewW = Width < MIN_W ? MIN_W : Width + BORDER_W;
207
if (NewW + Rect2.left > Rect1.right)
208
NewW = Rect1.right - Rect2.left;
209
NewH = Height + MENU_H;
210
if (NewH + Rect2.top > Rect1.bottom)
211
NewH = Rect1.bottom - Rect2.top;
213
SetWindowPos(HWnd, HWND_TOP, Rect2.left, Rect2.top, NewW, NewH, SWP_SHOWWINDOW);
214
InvalidateRect(HWnd, NULL, FALSE);
220
// Window procedure, handles all messages for this program
221
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
224
static ILuint Colours;
226
static PAINTSTRUCT ps;
229
static char OpenFileName[2048];
230
static char OpenFilter[2048];
231
static char SaveFileName[2048];
232
static char SaveFilter[2048];
233
static char *OFilter[] = {
234
"All Files (*.*)", "*.*",
235
"Alias|Wavefront Files (*.pix)", "*.pix",
236
"Cut Files (*.cut)", "*.cut",
237
"Dcx Files (*.dcx)", "*.dcx",
238
"Graphics Interchange Format (*.gif)", "*.gif",
239
"Half-Life Model Files (*.mdl)", "*.mdl",
240
"Homeworld Image Files (*.lif)", "*.lif",
241
"Image Files (All Supported Types)", "*.jpe;*.jpg;*.jpeg;*.lif;*.bmp;*.ico;*.pbm;*.pgm;*.pnm;*.ppm;*.png;*.bw;*.rgb;*.rgba;*.sgi;*.tga;*.tif;*.tiff;*.pcx;*.xpm;*.psp;*.psd;*.pix;*.pxr;*.cut;*.dcx",
242
"Jpeg Files (*.jpe, *.jpg, *.jpeg)", "*.jpe;*.jpg;*.jpeg",
243
"Kodak Photo CD Files (*.pcd)", "*.pcd",
244
"Microsoft Bitmap Files (*.bmp)", "*.bmp",
245
"Microsoft DirectDraw Surface (*.dds)", "*.dds",
246
"Microsoft Icon Files (*.ico, *.cur)", "*.ico, *.cur",
247
"Multiple Network Graphics Files (*.mng)", "*.mng",
248
"Paint Shop Pro Files (*.psp)", "*.psp",
249
"PhotoShop Files (*.psd)", "*.psd",
250
"Pic Files (*.pic)", "*.pic",
251
"Pixar Files (*.pix)", "*.pix",
252
"Portable AnyMap Files (*.pbm, *.pgm, *.pnm, *.ppm)", "*.pbm;*.pgm;*.pnm;*.ppm",
253
"Portable Network Graphics Files (*.png)", "*.png",
254
"Sgi Files (*.sgi)", "*.bw;*.rgb;*.rgba;*.sgi",
255
"Targa Files (*.tga, *.vda, *.icb, *.vst)", "*.tga;*.vda;*.icb;*.vst",
256
"Tiff Files (*.tif)", "*.tif;*.tiff",
257
"Quake Wal Files (*.wal)", "*.wal",
258
"X PixelMap (*.xpm)", "*.xpm",
259
"ZSoft Pcx Files (*.pcx)", "*.pcx",
262
static char *SFilter[] = {
263
"All Files (*.*)", "*.*",
264
"C-Style Header (*.h)", "*.h",
265
"Jpeg Files (*.jpe, *.jpg, *.jpeg)", "*.jpe;*.jpg;*.jpeg",
266
"Microsoft Bitmap Files (*.bmp)", "*.bmp",
267
"Microsoft DirectDraw Surface (*.dds)", "*.dds",
268
"PhotoShop Files (*.psd)", "*.psd",
269
"Portable AnyMap Files (*.pbm, *.pgm, *.ppm)", "*.pbm;*.pgm;*.ppm",
270
"Portable Network Graphics Files (*.png)", "*.png",
271
"Sgi Files (*.sgi)", "*.bw;*.rgb;*.rgba;*.sgi",
272
"Targa Files (*.tga)", "*.tga",
273
"Tiff Files (*.tif)", "*.tif",
274
"ZSoft Pcx Files (*.pcx)", "*.pcx",
278
static OPENFILENAME Ofn = {
279
sizeof(OPENFILENAME),
292
OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST,
302
static POINT PrevMouse;
303
static ILboolean MouseDown = IL_FALSE;
307
unsigned int currentColor = 0x80000000;
308
unsigned int originalColor = 0x80000000;
310
ILclampf Red, Green, Blue;
311
ILubyte *AlphaChannel;
317
GenFilterString(OpenFilter, OFilter);
318
GenFilterString(SaveFilter, SFilter);
321
DragAcceptFiles(hWnd, TRUE);
323
ReleaseDC(hWnd, hDC);
329
UnregisterClass(TITLE, hInstance);
337
GetWindowRect(HWnd, &WinSize); // Shouldn't be here!
338
hDC = BeginPaint(hWnd, &ps);
339
//StretchBlt(hDC, 0, 0, WinSize.right - WinSize.left,
340
// WinSize.bottom - WinSize.top, BackHDC, 0, 0, 1, 1, SRCCOPY);
341
WinSize.right -= WinSize.left;
342
WinSize.bottom -= WinSize.top;
345
FillRect(hDC, &WinSize, BackBrush);
347
BitBlt(hDC, XOff, YOff, (WORD)BmpInfo.biWidth, (WORD)BmpInfo.biHeight,
348
hMemDC, 0, 0, SRCCOPY);
350
ValidateRect(hWnd, NULL);
354
if (wParam == VK_ESCAPE)
357
InvalidateRect(hWnd, NULL, FALSE);
360
// Moves the "viewport"
364
GetCursorPos(&CurMouse);
366
XOff += CurMouse.x - PrevMouse.x;
367
YOff += CurMouse.y - PrevMouse.y;
369
PrevMouse.x = CurMouse.x;
370
PrevMouse.y = CurMouse.y;
371
InvalidateRect(hWnd, NULL, FALSE);
376
GetCursorPos(&PrevMouse);
380
MouseDown = IL_FALSE;
384
hDrop = (HDROP)wParam;
385
DragQueryFile(hDrop, 0, OpenFileName, 512);
388
ilDeleteImages(UndoSize, Undos);
391
ilGenImages(1, Undos);
392
ilBindImage(Undos[0]);
393
ilLoadImage(OpenFileName);
395
ilutRenderer(ILUT_WIN32);
399
sprintf(CurFileName, "%s", OpenFileName);
400
sprintf(NewTitle, "%s - %s", TITLE, OpenFileName);
401
SetWindowText(hWnd, NewTitle);
407
FilterType = LOWORD(wParam);
409
switch (LOWORD(wParam))
412
PostMessage(hWnd, WM_CLOSE, 0, 0);
416
DialogBox (hInstance,
417
MAKEINTRESOURCE(IDD_DIALOG_ABOUT),
422
case ID_FILE_PROPERTIES:
423
DialogBox (hInstance,
424
MAKEINTRESOURCE(IDD_DIALOG_PROPERTIES),
429
case ID_BATCHCONVERT:
430
DialogBox (hInstance,
431
MAKEINTRESOURCE(IDD_DIALOG_BATCHCONV),
436
case ID_EFFECTS_COUNTCOLORS:
437
Colours = iluColoursUsed();
438
char ColourString[255];
439
sprintf(ColourString, "The number of colours in this image is: %d", Colours);
440
MessageBox(NULL, ColourString, "Colour Count", MB_OK);
443
case ID_EFFECTSTOOLS_BACKGROUNDCOLOUR:
444
userClickedOK = FSColorPickerDoModal(¤tColor, &originalColor, 0);
447
Red = (ILfloat)((currentColor & 0xff0000) >> 16) / 255.0f;
448
Green = (ILfloat)((currentColor & 0xff00) >> 8) / 255.0f;
449
Blue = (ILfloat)(currentColor & 0xff) / 255.0f;
451
ilClearColour(Red, Green, Blue, 1.0f);
457
ilutSetWinClipboard();
462
ilGenImages(1, &Test);
465
// Check if there's anything in the clipboard.
466
if (!ilutGetWinClipboard()) {
467
ilDeleteImages(1, &Test);
470
ilDeleteImages(1, &Test);
473
ilDeleteImages(UndoSize, Undos);
478
ilGenImages(1, Undos);
479
ilBindImage(Undos[0]);
480
ilutGetWinClipboard();
482
sprintf(CurFileName, "Clipboard Paste");
483
sprintf(NewTitle, "%s - Pasted from the Clipboard", TITLE);
484
SetWindowText(hWnd, NewTitle);
486
//ilConvertImage(IL_BGRA);
487
ilutRenderer(ILUT_WIN32);
492
// @TODO: Will probably fail if no image loaded!
497
//HBITMAP PrintReplace;
499
memset(&Pd, 0, sizeof(PRINTDLG));
500
Pd.lStructSize = sizeof(PRINTDLG);
502
Pd.Flags = PD_RETURNDC;
504
Pd.nFromPage = 0xFFFF;
507
Pd.nMaxPage = 0xFFFF;
512
Di.cbSize = sizeof(DOCINFO);
513
Di.lpszDocName = "DevIL Printing Test";
514
Di.lpszOutput = NULL;
515
Di.lpszDatatype = NULL;
518
StartDoc(Pd.hDC, &Di);
521
//PrintDC = CreateCompatibleDC(Pd.hDC);
522
//PrintReplace = (HBITMAP)SelectObject(PrintDC, hBitmap);
523
StretchBlt(Pd.hDC, 0, 0, Width * 2, Height * 2, hMemDC, 0, 0, Width, Height, SRCCOPY);
527
//DeleteObject(PrintReplace);
531
ilutWinPrint(0, 0, ilGetInteger(IL_IMAGE_WIDTH) * 2, ilGetInteger(IL_IMAGE_HEIGHT) * 2, hDC);
536
sprintf(OpenFileName, "*.*");
537
Ofn.lpstrFilter = OpenFilter;
538
Ofn.lpstrFile = OpenFileName;
539
Ofn.lpstrTitle = "Open File";
540
Ofn.nFilterIndex = 1;
541
Ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
543
if (!GetOpenFileName(&Ofn))
547
ilDeleteImages(UndoSize, Undos);
552
ilGenImages(1, Undos);
553
ilBindImage(Undos[0]);
555
//last_elapsed = SDL_GetTicks();
556
ilLoadImage(OpenFileName);
557
//cur_elapsed = SDL_GetTicks();
558
//elapsed = cur_elapsed - last_elapsed;
559
//last_elapsed = cur_elapsed;
562
ilutRenderer(ILUT_WIN32);
566
sprintf(CurFileName, "%s", OpenFileName);
567
sprintf(NewTitle, "%s - %s: %g ms", TITLE, OpenFileName, elapsed);
568
SetWindowText(hWnd, NewTitle);
572
case ID_FILE_OPENURL:
573
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
574
hWnd, FilterDlgProc) != TRUE) {
579
ilDeleteImages(UndoSize, Undos);
584
ilGenImages(1, Undos);
585
ilBindImage(Undos[0]);
586
if (!ilutWinLoadUrl(FilterEditString))
589
ilutRenderer(ILUT_WIN32);
593
sprintf(NewTitle, "%s - %s", TITLE, FilterEditString);
594
SetWindowText(hWnd, NewTitle);
599
sprintf(SaveFileName, "monkey.tga");
600
Ofn.lpstrFilter = SaveFilter;
601
Ofn.lpstrFile = SaveFileName;
602
Ofn.lpstrTitle = "Save File";
603
Ofn.nFilterIndex = 1;
604
Ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
606
if (!GetSaveFileName(&Ofn))
609
ilEnable(IL_FILE_OVERWRITE);
610
ilSaveImage(SaveFileName);
612
sprintf(CurFileName, "%s", SaveFileName);
613
sprintf(NewTitle, "%s - %s", TITLE, SaveFileName);
614
SetWindowText(hWnd, NewTitle);
618
case ID_EDIT_UNDOLEVEL:
619
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
620
hWnd, FilterDlgProc) == TRUE) {
621
NumUndosAllowed = FilterParamInt <= 10 ? FilterParamInt : 10;
626
if (UndoSize && NumUndosAllowed) {
627
ilDeleteImages(1, &Undos[UndoSize]);
628
ilBindImage(Undos[--UndoSize]);
634
case ID_EDIT_VIEWIMAGENUM:
635
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
636
hWnd, FilterDlgProc) == TRUE) {
637
ilActiveImage(FilterParamInt);
638
ilutRenderer(ILUT_WIN32);
644
case ID_EDIT_VIEWMIPMAP:
645
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
646
hWnd, FilterDlgProc) == TRUE) {
647
ilActiveMipmap(FilterParamInt);
648
ilutRenderer(ILUT_WIN32);
657
if (++UndoSize > NumUndosAllowed) {
658
if (NumUndosAllowed > 0) {
659
UndoSize = NumUndosAllowed;
660
ilDeleteImages(1, &Undos[0]);
661
memcpy(Undos, Undos+1, NumUndosAllowed * sizeof(ILuint));
662
ilBindImage(Undos[UndoSize]);
666
if (NumUndosAllowed > 0) {
667
ilGetIntegerv(IL_ACTIVE_IMAGE, (ILint*)&Undos[UndoSize]);
668
/*ilGenImages(1, &Undos[UndoSize]);
669
ilBindImage(Undos[UndoSize]);
670
ilCopyImage(Undos[UndoSize-1]);*/
671
Undos[UndoSize] = ilCloneCurImage();
672
ilBindImage(Undos[UndoSize]);
676
switch (LOWORD(wParam))
678
case ID_CONVERT_PALETTE:
679
ilConvertImage(IL_COLOUR_INDEX, IL_UNSIGNED_BYTE);
683
ilConvertImage(IL_RGB, ilGetInteger(IL_IMAGE_TYPE));
686
case ID_CONVERT_RGBA:
687
ilConvertImage(IL_RGBA, ilGetInteger(IL_IMAGE_TYPE));
691
ilConvertImage(IL_BGR, ilGetInteger(IL_IMAGE_TYPE));
694
case ID_CONVERT_BGRA:
695
ilConvertImage(IL_BGRA, ilGetInteger(IL_IMAGE_TYPE));
698
case ID_CONVERT_LUMINANCE:
699
ilConvertImage(IL_LUMINANCE, ilGetInteger(IL_IMAGE_TYPE));
702
case ID_CONVERT_LUMINANCEALPHA:
703
ilConvertImage(IL_LUMINANCE_ALPHA, ilGetInteger(IL_IMAGE_TYPE));
706
case ID_EDIT_VIEWALPHA:
707
Origin = ilGetInteger(IL_ORIGIN_MODE);
708
AlphaChannel = ilGetAlpha(IL_UNSIGNED_BYTE);
709
ilTexImage(ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT),
710
ilGetInteger(IL_IMAGE_DEPTH), 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, AlphaChannel);
712
ilRegisterOrigin(Origin);
715
case ID_EFFECTS_FLIP:
719
case ID_EFFECTS_MIRROR:
723
case ID_FILTER_EMBOSS:
727
case ID_FILTER_EQUALIZE:
731
case ID_FILTER_ALIENIFY:
735
case ID_FILTER_NEGATIVE:
739
case ID_EFFECTS_FILTERS_EDGEDETECT_EMBOSS:
743
case ID_EFFECTS_FILTERS_EDGEDETECT_SOBEL:
747
case ID_EFFECTS_FILTERS_EDGEDETECT_PREWITT:
751
case ID_FILTER_NOISE:
752
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
753
hWnd, FilterDlgProc) == TRUE) {
754
iluNoisify(FilterParamFloat);
758
case ID_EFFECTS_FILTERS_WAVE:
759
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
760
hWnd, FilterDlgProc) == TRUE) {
761
iluWave(FilterParamFloat);
765
case ID_FILTER_PIXELIZE:
766
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
767
hWnd, FilterDlgProc) == TRUE) {
768
iluPixelize(FilterParamInt);
772
case ID_FILTERS_BLUR_AVERAGE:
773
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
774
hWnd, FilterDlgProc) == TRUE) {
775
iluBlurAvg(FilterParamInt);
779
case ID_FILTERS_BLUR_GAUSSIAN:
780
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
781
hWnd, FilterDlgProc) == TRUE) {
782
iluBlurGaussian(FilterParamInt);
783
/*iluMatrixMode(ILU_CONVOLUTION_MATRIX);
784
iluLoadFilter(ILU_FILTER_GAUSSIAN_5X5);
789
case ID_FILTER_GAMMACORRECT:
790
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
791
hWnd, FilterDlgProc) == TRUE) {
792
iluGammaCorrect(FilterParamFloat);
796
case ID_FILTER_SHARPEN:
797
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
798
hWnd, FilterDlgProc) == TRUE) {
799
iluSharpen(FilterParamFloat, 1);
803
case ID_EFFECTS_FILTERS_ROTATE:
804
if (DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_FILTER),
805
hWnd, FilterDlgProc) == TRUE) {
806
iluRotate(FilterParamFloat);
811
case ID_EFFECTS_FILTERS_SCALE:
813
iluImageParameter(ILU_FILTER, ILU_BILINEAR);
814
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_RESIZE), hWnd, ResizeDlgProc);
820
InvalidateRect(hWnd, NULL, FALSE);
824
return (DefWindowProc(hWnd, message, wParam, lParam));
831
void GenFilterString(char *Out, char **Strings)
833
int OutPos = 0, StringPos = 0;
835
while (Strings[StringPos][0] != 0) {
836
sprintf(Out + OutPos, Strings[StringPos]);
837
OutPos += (int)strlen(Strings[StringPos++]) + 1;
847
BOOL APIENTRY AboutDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
855
char VersionNum[256];
857
sprintf(VersionNum, "Num: %d", ilGetInteger(IL_VERSION_NUM));
859
SetDlgItemText(hDlg, IDC_ABOUT_VENDOR, ilGetString(IL_VENDOR));
860
SetDlgItemText(hDlg, IDC_ABOUT_VER_STRING, ilGetString(IL_VERSION));
861
SetDlgItemText(hDlg, IDC_ABOUT_VER_NUM, VersionNum);
863
for (i = 0; i < 6; i++) {
864
ilError = ilGetError();
865
if (ilError == IL_NO_ERROR)
867
SetDlgItemText(hDlg, IDC_ERROR1+i, iluErrorString(ilError));
876
if (LOWORD(wParam) == IDOK)
877
EndDialog(hDlg, TRUE);
878
if (LOWORD(wParam) == IDCANCEL)
879
EndDialog(hDlg, FALSE);
884
EndDialog(hDlg, TRUE);
892
BOOL APIENTRY PropertiesDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
900
SetDlgItemText(hDlg, IDC_PROP_FILENAME, CurFileName);
901
sprintf(Temp, "%d", ilGetInteger(IL_IMAGE_WIDTH));
902
SetDlgItemText(hDlg, IDC_PROP_WIDTH, Temp);
903
sprintf(Temp, "%d", ilGetInteger(IL_IMAGE_HEIGHT));
904
SetDlgItemText(hDlg, IDC_PROP_HEIGHT, Temp);
905
sprintf(Temp, "%d", ilGetInteger(IL_IMAGE_DEPTH));
906
SetDlgItemText(hDlg, IDC_PROP_DEPTH, Temp);
907
sprintf(Temp, "%d", ilGetInteger(IL_IMAGE_SIZE_OF_DATA));
908
SetDlgItemText(hDlg, IDC_PROP_SIZE, Temp);
916
if (LOWORD(wParam) == IDOK)
917
EndDialog(hDlg, TRUE);
918
if (LOWORD(wParam) == IDCANCEL)
919
EndDialog(hDlg, FALSE);
924
EndDialog(hDlg, TRUE);
932
BOOL APIENTRY FilterDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
940
case ID_FILTER_PIXELIZE:
941
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Width of pixelized block:");
942
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "1");
944
case ID_FILTER_NOISE:
945
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Amount of noise threshold:");
946
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "1.0");
948
case ID_EFFECTS_FILTERS_WAVE:
949
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Angle of wave to apply:");
950
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "0.0");
952
case ID_FILTERS_BLUR_AVERAGE:
953
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Number of iterations:");
954
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "1");
956
case ID_FILTERS_BLUR_GAUSSIAN:
957
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Number of iterations:");
958
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "1");
960
case ID_FILTER_GAMMACORRECT:
961
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Amount of gamma correction:");
962
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "1.0");
964
case ID_FILTER_SHARPEN:
965
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Sharpening factor:");
966
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "1.0");
968
case ID_EFFECTS_FILTERS_ROTATE:
969
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Number of degress to rotate:");
970
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "0.0");
973
case ID_EDIT_UNDOLEVEL:
974
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Set level of undo:");
975
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "4");
977
case ID_EDIT_VIEWIMAGENUM:
978
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Enter image number:");
979
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "0");
981
case ID_EDIT_VIEWMIPMAP:
982
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Enter mipmap number:");
983
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "0");
985
case ID_FILE_OPENURL:
986
SetDlgItemText(hDlg, IDC_FILTER_DESC_TEXT, "Enter url of image:");
987
SetDlgItemText(hDlg, IDC_FILTER_EDIT, "");
997
if (LOWORD(wParam) == IDOK) {
998
GetDlgItemText(hDlg, IDC_FILTER_EDIT, FilterEditString, 255);
999
FilterParamInt = atoi(FilterEditString);
1000
FilterParamFloat = (float)atof(FilterEditString);
1001
EndDialog(hDlg, TRUE);
1003
if (LOWORD(wParam) == IDCANCEL) {
1004
EndDialog(hDlg, FALSE);
1010
EndDialog(hDlg, TRUE);
1018
BOOL APIENTRY ResizeDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
1020
static char x[255], y[255], z[255];
1021
static ILuint xsize, ysize, zsize;
1028
sprintf(x, "%d", Width);
1029
sprintf(y, "%d", Height);
1030
sprintf(z, "%d", Depth);
1031
SetDlgItemText(hDlg, IDC_EDIT_RESIZE_X, x);
1032
SetDlgItemText(hDlg, IDC_EDIT_RESIZE_Y, y);
1033
SetDlgItemText(hDlg, IDC_EDIT_RESIZE_Z, z);
1040
if (LOWORD(wParam) == IDOK) {
1041
GetDlgItemText(hDlg, IDC_EDIT_RESIZE_X, x, 255);
1042
GetDlgItemText(hDlg, IDC_EDIT_RESIZE_Y, y, 255);
1043
GetDlgItemText(hDlg, IDC_EDIT_RESIZE_Z, z, 255);
1047
if (xsize && ysize && zsize) {
1048
iluScale(xsize, ysize, zsize);
1050
Width = ilGetInteger(IL_IMAGE_WIDTH);
1051
Height = ilGetInteger(IL_IMAGE_HEIGHT);
1052
Depth = ilGetInteger(IL_IMAGE_DEPTH);
1054
GetWindowRect(HWnd, &Rect);
1055
SetWindowPos(HWnd, HWND_TOP, Rect.left, Rect.top,
1056
Width < MIN_W ? MIN_W + BORDER_W : Width + BORDER_W,
1057
Height + MENU_H, SWP_SHOWWINDOW);
1059
InvalidateRect(HWnd, NULL, FALSE);
1061
EndDialog(hDlg, TRUE);
1063
if (LOWORD(wParam) == IDCANCEL) {
1064
EndDialog(hDlg, FALSE);
1070
EndDialog(hDlg, TRUE);
1078
BOOL APIENTRY BatchDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
1080
static char Dir[255], NewExt[255];
1081
static bool Recurse;
1089
sprintf(NewExt, "tga");
1090
SetDlgItemText(hDlg, IDC_BATCH_DIR, Dir);
1091
SetDlgItemText(hDlg, IDC_BATCH_NEWEXT, NewExt);
1098
if (LOWORD(wParam) == IDOK) {
1099
GetDlgItemText(hDlg, IDC_BATCH_DIR, Dir, 255);
1100
GetDlgItemText(hDlg, IDC_BATCH_NEWEXT, NewExt, 255);
1101
Recurse = IsDlgButtonChecked(hDlg, IDC_BATCH_CHECK1) == BST_CHECKED;
1105
BatchConv(Dir, NULL, NewExt, Recurse);
1107
EndDialog(hDlg, TRUE);
1109
if (LOWORD(wParam) == IDCANCEL) {
1110
EndDialog(hDlg, FALSE);
1116
EndDialog(hDlg, TRUE);