Add DevIL 1.7.8.

This commit is contained in:
rude
2013-09-26 00:20:08 +02:00
parent 6e493fb605
commit c065120c58
487 changed files with 219483 additions and 0 deletions
@@ -0,0 +1,379 @@
//-----------------------------------------------------------------------------
//
// ImageLib Windows (GDI) Test Source
// Copyright (C) 2000 by Denton Woods
// Last modified: 08/26/2001 <--Y2K Compliant! =]
//
// Filename: testil/animtest/animtest.c
//
// Description: Animation test application for DevIL.
//
//-----------------------------------------------------------------------------
#include <windows.h>
#ifdef _DEBUG
#define IL_DEBUG
#endif
#include <il/il.h>
#include <il/ilu.h>
#include <il/ilut.h>
#include "resource.h"
// Evil globals!
HINSTANCE hInstance;
HDC hDC, hMemDC = NULL;
HWND HWnd;
#define BORDER_W 8
#define MENU_H 46
#define MIN_W 205 // Accomodate the menu bar.
#define MAX_W 400
#define MAX_H 400
#define TITLE "DevIL Animation Test"
ILuint FilterType;
ILuint FilterParamInt;
ILfloat FilterParamFloat;
char FilterEditString[255];
char NewTitle[512];
BITMAPINFOHEADER *BmpInfo = NULL;
HBITMAP *Bitmaps = NULL;
ILuint *Durations = NULL;
ILuint NumImages = 0, CurImage = 0;
__int64 StartTime, TimerFreq;
double TimerRes;
bool IsPaused = false;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void GenFilterString(char *Out, char **Strings);
void DisplayImage(void);
void LoadImages(char *FileName);
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
WNDCLASSEX wcex;
HACCEL hAccelTable;
hInstance = hInst;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDR_MENU1;
wcex.lpszClassName = TITLE;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_ICON1);
RegisterClassEx(&wcex);
HWnd = CreateWindow(TITLE, TITLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
50, 50, 400, 300, NULL, NULL, hInstance, NULL);
if (HWnd == NULL)
return FALSE;
// Display the window
ShowWindow(HWnd, nCmdShow);
UpdateWindow(HWnd);
ilInit();
ilEnable(IL_ORIGIN_SET);
ilEnable(IL_TYPE_SET);
ilEnable(IL_FORMAT_SET);
ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
ilTypeFunc(IL_UNSIGNED_BYTE);
ilFormatFunc(IL_BGR);
// Is there a file to load from the command-line?
if (__argc > 1) {
LoadImages(__argv[1]);
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDR_MENU1);
while (GetMessage(&msg, NULL, 0, 0)) {
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
void LoadImages(char *FileName)
{
ILuint Image, i;
hDC = GetDC(HWnd);
hMemDC = CreateCompatibleDC(hDC);
ilGenImages(1, &Image);
ilBindImage(Image);
if (!ilLoadImage(FileName)) {
ilDeleteImages(1, &Image);
return;
}
ilEnable(IL_ORIGIN_SET);
ilEnable(IL_FORMAT_SET);
ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
//ilFormatFunc(IL_BGRA);
ilConvertImage(IL_BGR, IL_UNSIGNED_BYTE);
ilutRenderer(ILUT_WIN32);
CurImage = 0;
NumImages = ilGetInteger(IL_NUM_IMAGES) + 1;
Bitmaps = new HBITMAP[NumImages];
BmpInfo = new BITMAPINFOHEADER[NumImages];
Durations = new ILuint[NumImages];
if (Bitmaps == NULL || BmpInfo == NULL || Durations == NULL) {
ilDeleteImages(1, &Image);
return;
}
for (i = 0; i < NumImages; i++) {
ilActiveImage(0);
ilActiveImage(i);
Durations[i] = ilGetInteger(IL_IMAGE_DURATION);
*(Bitmaps + i) = ilutConvertToHBitmap(hDC);
ilutGetBmpInfo((BITMAPINFO*)(BmpInfo + i));
}
SelectObject(hMemDC, Bitmaps[0]);
ilDeleteImages(1, &Image);
sprintf(NewTitle, "%s - %s", TITLE, FileName);
SetWindowText(HWnd, NewTitle);
QueryPerformanceFrequency((LARGE_INTEGER*)&TimerFreq);
TimerRes = 1.0 / TimerFreq;
QueryPerformanceCounter((LARGE_INTEGER*)&StartTime);
return;
}
void DestroyGDI()
{
ILuint i;
if (Bitmaps) {
for (i = 0; i < NumImages; i++) {
DeleteObject(*(Bitmaps + i));
}
}
if (hMemDC)
DeleteDC(hMemDC);
if (Bitmaps)
delete []Bitmaps;
if (BmpInfo)
delete []BmpInfo;
Bitmaps = NULL;
BmpInfo = NULL;
hMemDC = NULL;
return;
}
void DisplayImage()
{
static PAINTSTRUCT ps;
static __int64 CurTime;
static double TimeElapsed;
// Not created yet.
if (Durations == NULL || BmpInfo == NULL || Bitmaps == NULL)
return;
if (!IsPaused) {
QueryPerformanceCounter((LARGE_INTEGER*)&CurTime);
TimeElapsed = (CurTime - StartTime) * TimerRes;
if (TimeElapsed * 1000 > Durations[CurImage]) {
StartTime = CurTime;
CurImage++;
if (CurImage >= NumImages) {
CurImage = 0;
}
SelectObject(hMemDC, Bitmaps[CurImage]);
}
}
hDC = BeginPaint(HWnd, &ps);
BitBlt(hDC, 0, 0, (WORD)BmpInfo[CurImage].biWidth, (WORD)BmpInfo[CurImage].biHeight,
hMemDC, 0, 0, SRCCOPY);
EndPaint(HWnd, &ps);
return;
}
// Window procedure, handles all messages for this program
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HMENU hMenu;
static ILuint Colours;
static RECT Rect;
static HDROP hDrop;
static char OpenFileName[2048];
static char OpenFilter[2048];
static char *OFilter[] = {
"All Files (*.*)", "*.*",
"Half-Life Model Files (*.mdl)", "*.mdl",
"Homeworld Image Files (*.lif)", "*.lif",
"Image Files (All Supported Types)", "*.jpe;*.jpg;*.jpeg;*.lif;*.bmp;*.ico;*.pbm;*.pgm;*.pnm;*.ppm;*.png;*.bw;*.rgb;*.rgba;*.sgi;*.tga;*.tif;*.tiff;*.pcx",
"Jpeg Files (*.jpe, *.jpg, *.jpeg)", "*.jpe;*.jpg;*.jpeg",
"Microsoft Bitmap Files (*.bmp)", "*.bmp",
"Microsoft Icon Files (*.ico)", "*.ico",
"OpenIL Files (*.oil)", "*.oil",
"Portable AnyMap Files (*.pbm, *.pgm, *.pnm, *.ppm)", "*.pbm;*.pgm;*.pnm;*.ppm",
"Portable Network Graphics Files (*.png)", "*.png",
"Sgi Files (*.sgi)", "*.bw;*.rgb;*.rgba;*.sgi",
"Targa Files (*.tga)", "*.tga",
"Tiff Files (*.tif)", "*.tif;*.tiff",
"Quake Wal Files (*.wal)", "*.wal",
"ZSoft Pcx Files (*.pcx)", "*.pcx",
"\0\0"
};
static OPENFILENAME Ofn = {
sizeof(OPENFILENAME),
hWnd,
NULL,
OpenFilter,
NULL,
0,
0,
OpenFileName,
512,
NULL,
0,
NULL,
NULL,
OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST,
0,
0,
NULL,
NULL,
NULL,
NULL
};
switch (message)
{
case WM_CREATE:
GenFilterString(OpenFilter, OFilter);
hDC = GetDC(hWnd);
DragAcceptFiles(hWnd, TRUE);
break;
case WM_CLOSE:
DestroyGDI();
ReleaseDC(hWnd, hDC);
DestroyWindow(hWnd);
UnregisterClass(TITLE, hInstance);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_PAINT:
DisplayImage();
InvalidateRect(hWnd, NULL, FALSE);
break;
case WM_KEYDOWN:
if (wParam == VK_ESCAPE)
PostQuitMessage(0);
InvalidateRect(hWnd, NULL, FALSE);
break;
case WM_DROPFILES:
hDrop = (HDROP)wParam;
DragQueryFile(hDrop, 0, OpenFileName, 512);
DestroyGDI();
LoadImages(OpenFileName);
DragFinish (hDrop);
return 0;
case WM_COMMAND:
FilterType = LOWORD(wParam);
switch (LOWORD(wParam))
{
case ID_FILE_EXIT:
PostMessage(hWnd, WM_CLOSE, 0, 0);
return (0L);
case ID_FILE_LOAD:
sprintf(OpenFileName, "*.*");
Ofn.lpstrFilter = OpenFilter;
Ofn.lpstrFile = OpenFileName;
Ofn.lpstrTitle = "Open File";
Ofn.nFilterIndex = 1;
Ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
if (!GetOpenFileName(&Ofn))
return (0L);
DestroyGDI();
LoadImages(OpenFileName);
return (0L);
case ID_EDIT_PAUSE:
IsPaused = true;
return 0;
case ID_EDIT_RESUME:
IsPaused = false;
QueryPerformanceCounter((LARGE_INTEGER*)&StartTime);
return 0;
}
default:
return (DefWindowProc(hWnd, message, wParam, lParam));
}
return (0L);
}
void GenFilterString(char *Out, char **Strings)
{
int OutPos = 0, StringPos = 0;
while (Strings[StringPos][0] != 0) {
sprintf(Out + OutPos, Strings[StringPos]);
OutPos += strlen(Strings[StringPos++]) + 1;
}
Out[OutPos++] = 0;
Out[OutPos] = 0;
return;
}
@@ -0,0 +1,109 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""resource.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MENU1 MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Open...\tCtrl+O", ID_FILE_LOAD
MENUITEM "E&xit\tEsc", ID_FILE_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "&Pause", ID_EDIT_PAUSE
MENUITEM "&Resume", ID_EDIT_RESUME
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON DISCARDABLE "OpenIL.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MENU1 ACCELERATORS DISCARDABLE
BEGIN
"O", ID_FILE_LOAD, VIRTKEY, CONTROL, NOINVERT
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -0,0 +1,75 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by AnimTest.rc
//
#define IDC_MYICON 2
#define IDD_ABOUTBOX 103
#define IDS_APP_TITLE 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDC_OPENIL 109
#define IDR_MAINFRAME 128
#define IDI_ICON1 155
#define IDR_MENU1 167
#define IDD_DIALOG_ABOUT 168
#define IDC_ABOUT_VENDOR 1001
#define IDC_ABOUT_VER_STRING 1002
#define IDC_ABOUT_VER_NUM 1003
#define IDC_FILTER_EDIT 1004
#define IDC_FILTER_DESC_TEXT 1005
#define IDC_ERROR1 1014
#define IDC_ERROR2 1015
#define IDC_ERROR3 1016
#define IDC_ERROR4 1017
#define IDC_ERROR5 1018
#define IDC_ERROR6 1019
#define IDC_OPENIL_LINK 1020
#define ID_FILE_EXIT 32771
#define ID_HELP_ABOUT 32772
#define ID_CONVERT_RGB 32773
#define ID_CONVERT_RGBA 32774
#define ID_CONVERT_BGR 32775
#define ID_CONVERT_BGRA 32776
#define ID_CONVERT_LUMINANCE 32777
#define ID_FILE_LOAD 32778
#define ID_FILE_SAVE 32779
#define ID_FILTER_BITFILTER1 32780
#define ID_FILTER_BITFILTER2 32781
#define ID_FILTER_BITFILTER3 32782
#define ID_FILTER_EMBOSS 32783
#define ID_FILTER_NOISE 32784
#define ID_FILTER_PIXELIZE 32785
#define ID_EFFECTS_FILTERS_SCALE 32786
#define ID_EFFECTS_FILTERS_EDGEDETECT_SOBEL 32787
#define ID_EFFECTS_FILTERS_EDGEDETECT_PREWITT 32788
#define ID_EDIT_UNDO 32789
#define ID_EDIT_UNDOLEVEL 32790
#define ID_FILTERS_BLUR_AVERAGE 32791
#define ID_FILTERS_BLUR_GAUSSIAN 32792
#define ID_FILTER_GAMMACORRECT 32793
#define ID_FILTER_ALIENIFY 32794
#define ID_FILTER_SHARPEN 32795
#define ID_FILTER_NEGATIVE 32796
#define ID_EFFECTS_FLIP 32797
#define ID_EFFECTS_MIRROR 32798
#define ID_EFFECTS_COUNTCOLORS 32799
#define ID_EDIT_COPY 32800
#define ID_EDIT_PASTE 32801
#define ID_EFFECTS_FILTERS_ROTATE 32802
#define ID_EFFECTS_FILTERS_EDGEDETECT_EMBOSS 32804
#define ID_FILE_OPENURL 32808
#define ID_CONVERT_PALETTE 32809
#define ID_EDIT_PAUSE 32810
#define ID_EDIT_RESUME 32811
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 182
#define _APS_NEXT_COMMAND_VALUE 32812
#define _APS_NEXT_CONTROL_VALUE 1021
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif