mirror of
https://github.com/love2d/love-android.git
synced 2026-08-21 21:15:34 +02:00
added dependencies and build files (loosely inspired by Sebastian Dorda's love-native-android)
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
# Microsoft Developer Studio Project File - Name="MNGView" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** NICHT BEARBEITEN **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=MNGView - Win32 Debug
|
||||
!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
|
||||
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MNGView.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
|
||||
!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MNGView.mak" CFG="MNGView - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Für die Konfiguration stehen zur Auswahl:
|
||||
!MESSAGE
|
||||
!MESSAGE "MNGView - Win32 Release" (basierend auf "Win32 (x86) Application")
|
||||
!MESSAGE "MNGView - Win32 Debug" (basierend auf "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "MNGView - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0xc07 /d "NDEBUG"
|
||||
# ADD RSC /l 0xc07 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"MNGView.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MNGView - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0xc07 /d "_DEBUG"
|
||||
# ADD RSC /l 0xc07 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "MNGView - Win32 Release"
|
||||
# Name "MNGView - Win32 Debug"
|
||||
# Begin Group "Quellcodedateien"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Main.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Main.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mng.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header-Dateien"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Main.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Ressourcendateien"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Mng.ico
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "MNGView"=.\MNGView.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Microsoft C/C++ program database 2.00
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Erstellungsprotokoll</h1>
|
||||
<h3>
|
||||
--------------------Konfiguration: MNGView - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Befehlszeilen</h3>
|
||||
Erstellen der temporären Datei "C:\WINDOWS\TEMP\RSPF386.TMP" mit Inhalten
|
||||
[
|
||||
/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Release/MNGView.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c
|
||||
"F:\Nikgames\Libmng\contrib\MNGView\Main.cpp"
|
||||
]
|
||||
Creating command line "cl.exe @C:\WINDOWS\TEMP\RSPF386.TMP"
|
||||
Erstellen der temporären Datei "C:\WINDOWS\TEMP\RSPF387.TMP" mit Inhalten
|
||||
[
|
||||
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/MNGView.pdb" /machine:I386 /out:"MNGView.exe"
|
||||
.\Release\Main.obj
|
||||
.\Release\mng.obj
|
||||
.\Release\Main.res
|
||||
]
|
||||
Erstellen der Befehlzeile "link.exe @C:\WINDOWS\TEMP\RSPF387.TMP"
|
||||
<h3>Ausgabefenster</h3>
|
||||
Kompilierung läuft...
|
||||
Main.cpp
|
||||
Linker-Vorgang läuft...
|
||||
|
||||
|
||||
|
||||
<h3>Ergebnisse</h3>
|
||||
MNGView.exe - 0 Fehler, 0 Warnung(en)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
@@ -0,0 +1,334 @@
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//
|
||||
// MNGView Sample Application for VC6:
|
||||
// Loads all MNG/JNG/PNG Files LibMNG can do
|
||||
// Can save a single Frame to PNG Format.
|
||||
//
|
||||
// This code is public domain.
|
||||
// Created by Nikolaus Brennig, November 14th, 2000.
|
||||
// virtualnik@nol.at
|
||||
// http://cust.nol.at/ppee
|
||||
//
|
||||
// Tab: 4
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include "Main.h"
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Libs (its up to you to make VC find the libs; set the paths in the options):
|
||||
//---------------------------------------------------------------------------------------------
|
||||
#pragma comment(lib,"comctl32.lib")
|
||||
#pragma comment(lib,"libmng.lib")
|
||||
#pragma comment(lib,"libjpeg.lib")
|
||||
#pragma comment(lib,"libz.lib")
|
||||
#pragma comment(lib,"lcmsstat.lib")
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Vars:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
HWND hPicWin;
|
||||
HINSTANCE hinst;
|
||||
HMENU hMenu;
|
||||
HDC MemDC, hdc;
|
||||
HBITMAP MemImage, DefaultMemImage;
|
||||
ANIMFILE AnimFile;
|
||||
RECT rcRect;
|
||||
OPENFILENAME ofn, sfn;
|
||||
int W, H, Bits;
|
||||
int dx, dy;
|
||||
char OFNFile[1024];
|
||||
char CurDir[1024];
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Loads a file:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
VOID LoadOFN( HWND hwnd )
|
||||
{
|
||||
GetCurrentDirectory( sizeof(CurDir), CurDir );
|
||||
|
||||
ofn.lStructSize = sizeof(OPENFILENAME);
|
||||
ofn.hwndOwner = hwnd;
|
||||
ofn.lpstrFile = OFNFile;
|
||||
ofn.nMaxFile = sizeof(OFNFile);
|
||||
ofn.lpstrFilter = "Network Graphics (*.mng;*.jng:*.png)\0*.mng;*.jng;*.png\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = NULL;
|
||||
ofn.lpstrInitialDir = CurDir;
|
||||
ofn.lpstrTitle = "Load:";
|
||||
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST |
|
||||
OFN_HIDEREADONLY | OFN_NONETWORKBUTTON;
|
||||
|
||||
// Display the Open dialog box.
|
||||
if( GetOpenFileName(&ofn) )
|
||||
{
|
||||
dx = dy = W = H = 0;
|
||||
if( AnimFile.isAnimation == 1 ) CleanUpMNG();
|
||||
LoadMNG( OFNFile, hwnd, hdc );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Saves a file:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
VOID SaveSFN( HWND hwnd )
|
||||
{
|
||||
GetCurrentDirectory( sizeof(CurDir), CurDir );
|
||||
|
||||
// Initialize OPENFILENAME
|
||||
sfn.lStructSize = sizeof(OPENFILENAME);
|
||||
sfn.hwndOwner = hwnd;
|
||||
sfn.lpstrFile = OFNFile;
|
||||
sfn.nMaxFile = sizeof(OFNFile);
|
||||
sfn.lpstrFilter = "PNG\0*.png\0";
|
||||
sfn.nFilterIndex = 1;
|
||||
sfn.lpstrFileTitle = 0;
|
||||
sfn.nMaxFileTitle = 0;
|
||||
sfn.lpstrInitialDir = CurDir;
|
||||
sfn.lpstrTitle = "Save an Image";
|
||||
sfn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_NONETWORKBUTTON;
|
||||
|
||||
// Display the Open dialog box.
|
||||
if( GetSaveFileName(&sfn) )
|
||||
{
|
||||
SaveMNG( OFNFile, MemDC, MemImage );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// For stringhandling...
|
||||
//---------------------------------------------------------------------------------------------
|
||||
VOID catpath( char *dst, const char *src )
|
||||
{
|
||||
int len = lstrlen(dst);
|
||||
if( len > 0 && (dst[len-1] != '\\' && dst[len-1] != '/') ) lstrcat( dst, "\\" );
|
||||
lstrcat( dst, src );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// MainWindow WindowProc
|
||||
//---------------------------------------------------------------------------------------------
|
||||
long WINAPI WindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch( message )
|
||||
{
|
||||
case WM_TIMER:
|
||||
{
|
||||
int wTimerID = wParam;
|
||||
if( AnimFile.isAnimation == 1 && wTimerID == 2 )
|
||||
{
|
||||
UpdateMNG();
|
||||
SendMessage( hPicWin, WM_PAINT, 0, 0 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch( LOWORD(wParam) )
|
||||
{
|
||||
case FILE_OPEN:
|
||||
LoadOFN(hwnd);
|
||||
break;
|
||||
|
||||
case FILE_SAVE:
|
||||
SaveSFN(hwnd);
|
||||
break;
|
||||
|
||||
case FILE_EXIT:
|
||||
DestroyWindow( hPicWin );
|
||||
break;
|
||||
|
||||
case HELP_ABOUT:
|
||||
Warning(
|
||||
"MNGView Sample Application for VC6.\n" \
|
||||
"This Code is Public Domain.\n" \
|
||||
"Created by Nikolaus Brennig."
|
||||
);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
return 0L;
|
||||
|
||||
case WM_PAINT:
|
||||
// GetDC:
|
||||
GetClientRect( hPicWin, &rcRect );
|
||||
hdc = GetDC( hPicWin );
|
||||
|
||||
if( MemDC == 0 )
|
||||
{
|
||||
BitBlt( hdc, 0, 0, rcRect.right, rcRect.bottom, MemDC, 0, 0, BLACKNESS );
|
||||
ReleaseDC( hPicWin, hdc );
|
||||
break;
|
||||
}
|
||||
|
||||
// Erase:
|
||||
// Upper area...
|
||||
BitBlt( hdc, 0, 0, rcRect.right, (0+dy), MemDC, 0, 0, BLACKNESS );
|
||||
// Lower area...
|
||||
BitBlt( hdc, 0, (0+dy)+H, rcRect.right, rcRect.bottom - ((0+dy)+H), MemDC, 0, 0, BLACKNESS );
|
||||
// Left area...
|
||||
BitBlt( hdc, 0, 0, (0+dx), rcRect.bottom, MemDC, 0, 0, BLACKNESS );
|
||||
// Right area...
|
||||
BitBlt( hdc, (0+dx)+W, 0, rcRect.right, rcRect.bottom, MemDC, 0, 0, BLACKNESS );
|
||||
|
||||
// Show Imageframe:
|
||||
BitBlt( hdc, dx, dy, W, H, MemDC, 0, 0, SRCCOPY );
|
||||
|
||||
// Release DC...
|
||||
ReleaseDC( hPicWin, hdc );
|
||||
break;
|
||||
|
||||
case WM_HSCROLL:
|
||||
{
|
||||
int nScrollCode = (int) LOWORD(wParam); // scroll bar value
|
||||
if( nScrollCode == SB_LINELEFT ) dx += 10;
|
||||
if( nScrollCode == SB_LINERIGHT ) dx -= 10;
|
||||
SendMessage( hwnd, WM_PAINT, 0, 0 );
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
int nScrollCode = (int) LOWORD(wParam); // scroll bar value
|
||||
if( nScrollCode == SB_LINEUP ) dy += 10;
|
||||
if( nScrollCode == SB_LINEDOWN ) dy -= 10;
|
||||
SendMessage( hwnd, WM_PAINT, 0, 0 );
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_GETMINMAXINFO:
|
||||
((MINMAXINFO*)lParam)->ptMinTrackSize.x = 550;
|
||||
((MINMAXINFO*)lParam)->ptMinTrackSize.y = 450;
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
if( AnimFile.isAnimation == 1 )
|
||||
CleanUpMNG();
|
||||
if( hMenu ) DestroyMenu( hMenu );
|
||||
PostQuitMessage(0);
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return DefWindowProc( hwnd, message, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// ok, initen wir mal das Window mit den Styleparametern...
|
||||
//---------------------------------------------------------------------------------------------
|
||||
BOOL InitApplication( HINSTANCE hInstance, int nCmdShow, LPSTR lpCommandLine )
|
||||
{
|
||||
WNDCLASSEX wcex;
|
||||
|
||||
ZeroMemory( &wcex, sizeof(wcex) );
|
||||
wcex.cbSize = sizeof(wcex);
|
||||
wcex.style = 0;
|
||||
wcex.lpfnWndProc = WindowProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(APPICON));
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = HBRUSH(GetStockObject(BLACK_BRUSH));
|
||||
wcex.lpszMenuName = 0;
|
||||
wcex.lpszClassName = "MNGViewClass";
|
||||
wcex.hIconSm = 0;
|
||||
|
||||
if( !RegisterClassEx(&wcex) )
|
||||
return Error( "RegisterClass failed!" );
|
||||
|
||||
// Init:
|
||||
W = 0;
|
||||
H = 0;
|
||||
AnimFile.isAnimation = 0;
|
||||
MemDC = 0;
|
||||
MemImage = 0;
|
||||
DefaultMemImage = 0;
|
||||
|
||||
// Create the Window:
|
||||
hPicWin = CreateWindowEx(
|
||||
0,
|
||||
"MNGViewClass",
|
||||
TITLE,
|
||||
WS_OVERLAPPEDWINDOW|WS_SYSMENU|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_HSCROLL|WS_VSCROLL,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
NULL, NULL,
|
||||
hInstance,
|
||||
NULL
|
||||
);
|
||||
if( !hPicWin )
|
||||
return Error( "Couldn't create Window!" );
|
||||
|
||||
// Load our menu...
|
||||
hMenu = LoadMenu( GetModuleHandle(NULL), MAKEINTRESOURCE(THEMENU) );
|
||||
if( hMenu == 0 ) Warning( "Unable to load Menu!" );
|
||||
SetMenu( hPicWin, hMenu );
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
UpdateWindow(hPicWin);
|
||||
ShowWindow(hPicWin, SW_NORMAL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Ok. Das ist die Startfunktion, die wird als erstes von Windows augerufen...
|
||||
//---------------------------------------------------------------------------------------------
|
||||
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
hinst = hInstance;
|
||||
|
||||
if( !InitApplication(hInstance, nCmdShow, lpCmdLine) )
|
||||
return -1;
|
||||
|
||||
while( GetMessage(&msg, NULL, 0, 0) )
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Error
|
||||
//---------------------------------------------------------------------------------------------
|
||||
BOOL Error( const char *err )
|
||||
{
|
||||
MessageBox( hPicWin, err, TITLE, MB_ICONHAND+MB_OK );
|
||||
DestroyWindow( hPicWin );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Warning
|
||||
//---------------------------------------------------------------------------------------------
|
||||
BOOL Warning( const char *err )
|
||||
{
|
||||
MessageBox( hPicWin, err, TITLE, MB_ICONHAND+MB_OK );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//
|
||||
// MNGView Sample Application for VC6:
|
||||
// Loads all MNG/JNG/PNG Files LibMNG can do
|
||||
// Can save a single Frame to PNG Format.
|
||||
//
|
||||
// This code is public domain.
|
||||
// Created by Nikolaus Brennig, November 14th, 2000.
|
||||
// virtualnik@nol.at
|
||||
// http://cust.nol.at/ppee
|
||||
//
|
||||
// Tab: 4
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _MAIN_H
|
||||
#define _MAIN_H
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Includes:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commdlg.h>
|
||||
#include <commctrl.h>
|
||||
#include "Resource.h"
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Defines:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
#define TITLE "MNGView Sample Application 1.0"
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// global Vars:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
extern HWND hPicWin;
|
||||
extern HINSTANCE hinst;
|
||||
extern HDC MemDC, hdc;
|
||||
extern HBITMAP MemImage, DefaultMemImage;
|
||||
extern int W, H, Bits;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int MaxFrame;
|
||||
int CurFrame;
|
||||
int Delay;
|
||||
int isAnimation;
|
||||
} ANIMFILE;
|
||||
extern ANIMFILE AnimFile;
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Function prototypes:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
BOOL Error( const char *err );
|
||||
BOOL Warning( const char *err );
|
||||
VOID catpath( char *dst, const char *src );
|
||||
|
||||
|
||||
// MNG.cpp specific:
|
||||
VOID LoadMNG( LPSTR Filename, HWND hwnd, HDC hdc );
|
||||
VOID SaveMNG( LPSTR Filename, HDC hdc, HBITMAP hBmp );
|
||||
|
||||
VOID UpdateMNG();
|
||||
VOID CleanUpMNG();
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,105 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "Windows.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Englisch (USA) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
THEMENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "File"
|
||||
BEGIN
|
||||
MENUITEM "Open", FILE_OPEN
|
||||
MENUITEM "Save", FILE_SAVE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Exit", FILE_EXIT
|
||||
END
|
||||
POPUP "Help"
|
||||
BEGIN
|
||||
MENUITEM "About", HELP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
#endif // Englisch (USA) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Deutsch (Österreich) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEA)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
APPICON ICON DISCARDABLE "MNG.ico"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""Windows.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Deutsch (Österreich) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,615 @@
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//
|
||||
// MNGView Sample Application for VC6:
|
||||
// Loads all MNG/JNG/PNG Files LibMNG can do
|
||||
// Can save a single Frame to PNG Format.
|
||||
//
|
||||
// This code is public domain.
|
||||
// Created by Nikolaus Brennig, November 14th, 2000.
|
||||
// virtualnik@nol.at
|
||||
// http://cust.nol.at/ppee
|
||||
//
|
||||
// Tab: 4
|
||||
//
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include "Main.h"
|
||||
#include <libmng.h>
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// VARS:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
typedef struct
|
||||
{
|
||||
FILE *file;
|
||||
LPSTR filename;
|
||||
mng_uint32 delay;
|
||||
} mngstuff;
|
||||
|
||||
int lineWidth;
|
||||
BYTE *mngdestbuffer;
|
||||
mngstuff *mymngstuff;
|
||||
mng_handle Curmng;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// callbacks for the mng decoder:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// memory allocation; data must be zeroed
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_ptr mymngalloc( mng_uint32 size )
|
||||
{
|
||||
return (mng_ptr)calloc(1, size);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// memory deallocation
|
||||
//---------------------------------------------------------------------------------------------
|
||||
void mymngfree(mng_ptr p, mng_uint32 size)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Stream open:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_bool mymngopenstream(mng_handle mng)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
|
||||
// look up our stream struct
|
||||
mymng = (mngstuff*)mng_get_userdata(mng);
|
||||
|
||||
// open the file
|
||||
mymng->file = fopen( mymng->filename, "rb" );
|
||||
if( mymng->file == NULL )
|
||||
{
|
||||
char temp[100];
|
||||
sprintf( temp, "Unable to open File: %s", mymng->filename );
|
||||
Warning( temp );
|
||||
return MNG_FALSE;
|
||||
}
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Stream open for Writing:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_bool mymngopenstreamwrite(mng_handle mng)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
|
||||
// look up our stream struct
|
||||
mymng = (mngstuff*)mng_get_userdata(mng);
|
||||
|
||||
// open the file
|
||||
mymng->file = fopen( mymng->filename, "wb" );
|
||||
if( mymng->file == NULL )
|
||||
{
|
||||
Warning( "unable to open file!" );
|
||||
return MNG_FALSE;
|
||||
}
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Stream close:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_bool mymngclosestream(mng_handle mng)
|
||||
{
|
||||
return MNG_TRUE; // We close the file ourself, mng_cleanup doesnt seem to do it...
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// feed data to the decoder
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_bool mymngreadstream( mng_handle mng, mng_ptr buffer, mng_uint32 size, mng_uint32 *bytesread )
|
||||
{
|
||||
mngstuff *mymng;
|
||||
|
||||
// look up our stream struct
|
||||
mymng = (mngstuff*)mng_get_userdata(mng);
|
||||
|
||||
// read the requested amount of data from the file
|
||||
*bytesread = fread( buffer, sizeof(BYTE), size, mymng->file );
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// the header's been read. set up the display stuff
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_bool mymngprocessheader( mng_handle mng, mng_uint32 width, mng_uint32 height )
|
||||
{
|
||||
// Store values:
|
||||
W = width; H = height;
|
||||
Bits = 24;
|
||||
lineWidth = ((((W * Bits) + 31) >> 5) << 2);
|
||||
|
||||
// Create decoderbuffer:
|
||||
mngdestbuffer = new BYTE[lineWidth*H];
|
||||
if( mngdestbuffer == 0 ) Warning( "Out of Memory!" );
|
||||
|
||||
// Create the MemoryBitmap now, we store there the image...
|
||||
if( DefaultMemImage ) SelectObject( MemDC, DefaultMemImage );
|
||||
if( MemDC ) DeleteDC( MemDC );
|
||||
if( MemImage ) DeleteObject( MemImage );
|
||||
hdc = GetDC( hPicWin );
|
||||
MemDC = CreateCompatibleDC( 0 );
|
||||
MemImage = CreateCompatibleBitmap( hdc, W, H );
|
||||
DefaultMemImage = (HBITMAP)SelectObject( MemDC, MemImage );
|
||||
ReleaseDC( hPicWin, hdc );
|
||||
|
||||
// Set output style:
|
||||
mng_set_canvasstyle( mng, MNG_CANVAS_BGR8 );
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// return a row pointer for the decoder to fill
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_ptr mymnggetcanvasline( mng_handle mng, mng_uint32 line )
|
||||
{
|
||||
return (mng_ptr)(mngdestbuffer + (lineWidth*(H-1-line)));
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// timer
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_uint32 mymnggetticks(mng_handle mng)
|
||||
{
|
||||
return (mng_uint32)GetTickCount();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Refresh:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_bool mymngrefresh( mng_handle mng, mng_uint32 x, mng_uint32 y, mng_uint32 w, mng_uint32 h )
|
||||
{
|
||||
PBITMAPINFO bmpi = (PBITMAPINFO)LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER));
|
||||
bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmpi->bmiHeader.biWidth = W;
|
||||
bmpi->bmiHeader.biHeight = H;
|
||||
bmpi->bmiHeader.biPlanes = 1;
|
||||
bmpi->bmiHeader.biCompression = BI_RGB;
|
||||
bmpi->bmiHeader.biBitCount = Bits;
|
||||
bmpi->bmiHeader.biSizeImage = 0;
|
||||
bmpi->bmiHeader.biClrUsed = 0;
|
||||
bmpi->bmiHeader.biClrImportant = 0;
|
||||
|
||||
// Now blt the Image onto our MemDC...
|
||||
StretchDIBits( MemDC, 0, 0, W, H, 0, 0, W, H, mngdestbuffer, bmpi, 0, SRCCOPY );
|
||||
LocalFree((PBITMAPINFO)bmpi);
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// interframe delay callback
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_bool mymngsettimer(mng_handle mng, mng_uint32 msecs)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
|
||||
// look up our stream struct
|
||||
mymng = (mngstuff*)mng_get_userdata(mng);
|
||||
|
||||
// set the timer for when the decoder wants to be woken
|
||||
mymng->delay = msecs;
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Error Callback;
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_bool mymngerror(
|
||||
mng_handle mng, mng_int32 code, mng_int8 severity,
|
||||
mng_chunkid chunktype, mng_uint32 chunkseq,
|
||||
mng_int32 extra1, mng_int32 extra2, mng_pchar text
|
||||
)
|
||||
{
|
||||
char chunk[5];
|
||||
|
||||
// pull out the chuck type as a string
|
||||
// FIXME: does this assume unsigned char?
|
||||
chunk[0] = (char)((chunktype >> 24) & 0xFF);
|
||||
chunk[1] = (char)((chunktype >> 16) & 0xFF);
|
||||
chunk[2] = (char)((chunktype >> 8) & 0xFF);
|
||||
chunk[3] = (char)((chunktype ) & 0xFF);
|
||||
chunk[4] = '\0';
|
||||
|
||||
// output the error:
|
||||
char temp[1000];
|
||||
sprintf( temp, "error playing chunk %s (%d)", chunk, chunkseq );
|
||||
Warning( temp );
|
||||
|
||||
// No need for anymore decoding:
|
||||
KillTimer( hPicWin, 2 );
|
||||
|
||||
// error occured;
|
||||
return MNG_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Load a MNG/JNG/PNG file:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
VOID LoadMNG( LPSTR Filename, HWND hwnd, HDC hdc )
|
||||
{
|
||||
// allocate our stream data structure
|
||||
mymngstuff = (mngstuff*)calloc(1, sizeof(*mymngstuff));
|
||||
if( mymngstuff == NULL )
|
||||
{
|
||||
Warning( "Unable to allocate MNG struct!" );
|
||||
return;
|
||||
}
|
||||
|
||||
// pass the name of the file we want to play
|
||||
mymngstuff->filename = Filename;
|
||||
|
||||
// set up the mng decoder for our stream
|
||||
Curmng = mng_initialize(mymngstuff, mymngalloc, mymngfree, MNG_NULL);
|
||||
if(Curmng == MNG_NULL)
|
||||
{
|
||||
free(mymngstuff);
|
||||
Warning( "MNG Init Error!" );
|
||||
return;
|
||||
}
|
||||
|
||||
// No need to store chunks:
|
||||
mng_set_storechunks(Curmng, MNG_FALSE);
|
||||
|
||||
// Set the colorprofile, lcms uses this:
|
||||
mng_set_srgb( Curmng, MNG_TRUE );
|
||||
char DestDir[2048];
|
||||
SearchPath( NULL, "MNGVIEW.EXE", NULL, sizeof(DestDir), DestDir, NULL );
|
||||
lstrcpyn( DestDir, DestDir, lstrlen(DestDir)-lstrlen("MNGVIEW.EXE") );
|
||||
catpath( DestDir, "sRGB.icm" );
|
||||
FILE *RGBfile = fopen( DestDir, "rb" );
|
||||
if( RGBfile == 0 )
|
||||
{
|
||||
mng_cleanup(&Curmng);
|
||||
free(mymngstuff);
|
||||
Warning( "Need file \"sRGB.icm\" !" );
|
||||
return;
|
||||
}
|
||||
fclose(RGBfile);
|
||||
mng_set_outputprofile(Curmng, DestDir);
|
||||
|
||||
// Set white as background color:
|
||||
WORD Red = (255 << 8) + 255;
|
||||
WORD Green = (255 << 8) + 255;
|
||||
WORD Blue = (255 << 8) + 255;
|
||||
mng_set_bgcolor( Curmng, Red, Green, Blue );
|
||||
|
||||
// If PNG Background is available, use it:
|
||||
mng_set_usebkgd( Curmng, MNG_TRUE );
|
||||
|
||||
// set the callbacks
|
||||
mng_setcb_errorproc(Curmng, mymngerror);
|
||||
mng_setcb_openstream(Curmng, mymngopenstream);
|
||||
mng_setcb_closestream(Curmng, mymngclosestream);
|
||||
mng_setcb_readdata(Curmng, mymngreadstream);
|
||||
mng_setcb_gettickcount(Curmng, mymnggetticks);
|
||||
mng_setcb_settimer(Curmng, mymngsettimer);
|
||||
mng_setcb_processheader(Curmng, mymngprocessheader);
|
||||
mng_setcb_getcanvasline(Curmng, mymnggetcanvasline);
|
||||
mng_setcb_refresh(Curmng, mymngrefresh);
|
||||
|
||||
// Read the stuff:
|
||||
mng_readdisplay(Curmng);
|
||||
|
||||
AnimFile.CurFrame = mng_get_layercount( Curmng );
|
||||
AnimFile.MaxFrame = mng_get_framecount( Curmng );
|
||||
AnimFile.isAnimation = 1;
|
||||
AnimFile.Delay = mymngstuff->delay;
|
||||
|
||||
// Start the whole thing:
|
||||
SetTimer( hPicWin, 2, mymngstuff->delay, 0 );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Called when loading a new file or Appquit:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
void CleanUpMNG()
|
||||
{
|
||||
KillTimer( hPicWin, 2 );
|
||||
mng_cleanup(&Curmng);
|
||||
fclose( mymngstuff->file );
|
||||
free(mymngstuff);
|
||||
delete [] mngdestbuffer;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Called when timer says next frame/layer/update is needed:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
void UpdateMNG()
|
||||
{
|
||||
mymngstuff->delay = 0;
|
||||
if( MNG_NEEDTIMERWAIT == mng_display_resume(Curmng) )
|
||||
{
|
||||
KillTimer( hPicWin, 2 );
|
||||
SetTimer( hPicWin, 2, mymngstuff->delay, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
CleanUpMNG();
|
||||
AnimFile.CurFrame = -1;
|
||||
AnimFile.MaxFrame = -1;
|
||||
AnimFile.isAnimation = -1;
|
||||
AnimFile.Delay = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// MNG WRITING STUFF:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int OffsetX=0,OffsetY=0,OffsetW=0,OffsetH=0;
|
||||
BYTE *srcbuffer=0, *tmpbuffer;
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Callback for writing data:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
mng_bool mymngwritedata( mng_handle hMNG, mng_ptr pBuf, mng_uint32 iSize, mng_uint32 *iWritten )
|
||||
{
|
||||
mngstuff *pMydata = (mngstuff*)mng_get_userdata(hMNG);
|
||||
|
||||
*iWritten = fwrite( pBuf, sizeof(BYTE), iSize, pMydata->file );
|
||||
|
||||
if( *iWritten < iSize )
|
||||
{
|
||||
Warning( "write error" );
|
||||
return MNG_FALSE;
|
||||
}
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// swap Rs and Bs...
|
||||
//---------------------------------------------------------------------------------------------
|
||||
BOOL RGBFromBGR( BYTE *buf, UINT widthPix, UINT height )
|
||||
{
|
||||
UINT col, row;
|
||||
LPBYTE pRed, pBlu;
|
||||
BYTE tmp;
|
||||
|
||||
if (buf==NULL)return FALSE;
|
||||
|
||||
INT TmpRow = 0;
|
||||
INT WidthBytes = widthPix*3;
|
||||
if(WidthBytes & 0x003) WidthBytes = (WidthBytes | 3) + 1;
|
||||
INT OurCol = 0;
|
||||
for( row=0; row<height; row++ )
|
||||
{
|
||||
for( col=0; col<widthPix; col++ )
|
||||
{
|
||||
pRed = buf + TmpRow + OurCol;
|
||||
pBlu = pRed + 2;
|
||||
|
||||
// swap red and blue
|
||||
tmp = *pBlu;
|
||||
*pBlu = *pRed;
|
||||
*pRed = tmp;
|
||||
|
||||
OurCol += 3;
|
||||
}
|
||||
TmpRow += WidthBytes;
|
||||
OurCol = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Creates the srcuffer filled with data for saving:
|
||||
//---------------------------------------------------------------------------------------------
|
||||
VOID CreateSrcBuffer( int Frame, int FrameCount, HBITMAP hBmp2 )
|
||||
{
|
||||
PBITMAPINFO pbmi;
|
||||
BITMAP bmp;
|
||||
|
||||
srcbuffer=0;
|
||||
|
||||
// Get WidthBytes...
|
||||
INT WidthBytes = W*3;
|
||||
|
||||
INT LineWidth = W*3;
|
||||
if(LineWidth & 0x003) LineWidth = (LineWidth | 3) + 1;
|
||||
|
||||
// Bitmapstruct init...
|
||||
GetObject( hBmp2, sizeof(BITMAP), (LPSTR)&bmp );
|
||||
pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER));
|
||||
|
||||
// Initialize the fields in the BITMAPINFO structure.
|
||||
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
pbmi->bmiHeader.biWidth = bmp.bmWidth;
|
||||
pbmi->bmiHeader.biHeight = -bmp.bmHeight;
|
||||
pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
|
||||
pbmi->bmiHeader.biBitCount = 24;
|
||||
pbmi->bmiHeader.biCompression = BI_RGB;
|
||||
pbmi->bmiHeader.biSizeImage = LineWidth * H * FrameCount;
|
||||
pbmi->bmiHeader.biClrImportant = 0;
|
||||
|
||||
// Alloc Memory...
|
||||
srcbuffer = 0;
|
||||
srcbuffer = new BYTE[LineWidth*H*FrameCount];
|
||||
if( srcbuffer == 0 )
|
||||
Warning( "srcbuffer == 0!" );
|
||||
|
||||
// get the buffer and modify the format:
|
||||
if( 0 == GetDIBits( MemDC, hBmp2, 0, (WORD) (H*FrameCount), srcbuffer, pbmi, 0 ) )
|
||||
Warning( "no GetDIBits!!!" );
|
||||
RGBFromBGR( srcbuffer, W, H*FrameCount );
|
||||
if( srcbuffer == 0 )
|
||||
Warning( "srcbuffer == 0!" );
|
||||
|
||||
// Freee.
|
||||
LocalFree((PBITMAPINFO)pbmi);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Writes a single PNG datastream
|
||||
//---------------------------------------------------------------------------------------------
|
||||
VOID WritePNG( mng_handle hMNG, int Frame, int FrameCount )
|
||||
{
|
||||
BYTE *dstbuffer;
|
||||
INT LineWidth;
|
||||
INT WidthBytes;
|
||||
|
||||
OffsetX=0; OffsetY=0; OffsetW=W; OffsetH=H;
|
||||
|
||||
// Get WidthBytes...
|
||||
WidthBytes = W*3;
|
||||
LineWidth = W*3;
|
||||
if(LineWidth & 0x003) LineWidth = (LineWidth | 3) + 1;
|
||||
|
||||
tmpbuffer = new BYTE[(WidthBytes+1)*OffsetH];
|
||||
if( tmpbuffer == 0 ) Warning( "Out of Memory!" );
|
||||
|
||||
// Write DEFI chunk.
|
||||
mng_putchunk_defi( hMNG, 0, 0, 0, MNG_TRUE, OffsetX, OffsetY, MNG_FALSE, 0, 0, 0, 0 );
|
||||
|
||||
// Write Header:
|
||||
mng_putchunk_ihdr(
|
||||
hMNG,
|
||||
OffsetW, OffsetH,
|
||||
MNG_BITDEPTH_8/*iBitdepth*/,
|
||||
MNG_COLORTYPE_RGB/*iColortype*/,
|
||||
MNG_COMPRESSION_DEFLATE/*iCompression*/,
|
||||
MNG_FILTER_ADAPTIVE/*iFilter*/,
|
||||
MNG_INTERLACE_NONE /*iInterlace*/
|
||||
);
|
||||
|
||||
// transfer data, add Filterbyte:
|
||||
for( int Row=0; Row<OffsetH; Row++ )
|
||||
{
|
||||
// First Byte in each Scanline is Filterbyte: Currently 0 -> No Filter.
|
||||
tmpbuffer[Row*(WidthBytes+1)]=0;
|
||||
|
||||
// Copy the scanline:
|
||||
memcpy(
|
||||
tmpbuffer+Row*(WidthBytes+1)+1,
|
||||
srcbuffer+((OffsetY+Row)*(LineWidth))+OffsetX,
|
||||
WidthBytes
|
||||
);
|
||||
}
|
||||
|
||||
// Free srcbuffer if not animated GIF:
|
||||
delete [] srcbuffer;
|
||||
|
||||
// Compress data with ZLib (Deflate):
|
||||
dstbuffer = new BYTE[(WidthBytes+1)*OffsetH];
|
||||
if( dstbuffer == 0 ) Warning( "Out of Memory!" );
|
||||
DWORD dstbufferSize=(WidthBytes+1)*OffsetH;
|
||||
|
||||
// Compress data:
|
||||
if( Z_OK != compress2(
|
||||
(Bytef *)dstbuffer, (ULONG *)&dstbufferSize,
|
||||
(const Bytef*)tmpbuffer, (ULONG) (WidthBytes+1)*OffsetH,
|
||||
9
|
||||
)) Warning( "Unable to compress imagedata!" );
|
||||
|
||||
// Write Data into MNG File:
|
||||
mng_putchunk_idat( hMNG, dstbufferSize, (mng_ptr*)dstbuffer);
|
||||
mng_putchunk_iend(hMNG);
|
||||
|
||||
// Free the stuff:
|
||||
delete [] tmpbuffer;
|
||||
delete [] dstbuffer;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Writes a MNG (24bit)
|
||||
//---------------------------------------------------------------------------------------------
|
||||
VOID SaveMNG( LPSTR Filename, HDC hdc, HBITMAP hBmp )
|
||||
{
|
||||
mng_handle hMNG;
|
||||
|
||||
// check if currently a MNG file is loaded:
|
||||
if( AnimFile.isAnimation == 1 )
|
||||
CleanUpMNG();
|
||||
|
||||
// Creates the srcbuffer for imagedata:
|
||||
CreateSrcBuffer( 0, 1, hBmp );
|
||||
|
||||
// allocate our stream data structure
|
||||
mymngstuff = (mngstuff*)calloc(1, sizeof(*mymngstuff));
|
||||
if( mymngstuff == NULL )
|
||||
{
|
||||
Warning( "Cannot allocate data buffer." );
|
||||
return;
|
||||
}
|
||||
|
||||
// pass the name of the file we want to play
|
||||
mymngstuff->filename = Filename;
|
||||
|
||||
// init the lib:
|
||||
hMNG = mng_initialize((mng_ptr)mymngstuff, mymngalloc, mymngfree, MNG_NULL);
|
||||
if( !hMNG )
|
||||
{
|
||||
Warning( "Cannot initialize libmng." );
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
mng_setcb_openstream(hMNG, mymngopenstreamwrite );
|
||||
mng_setcb_closestream(hMNG, mymngclosestream);
|
||||
mng_setcb_writedata(hMNG, mymngwritedata);
|
||||
|
||||
// Write File:
|
||||
mng_create(hMNG);
|
||||
|
||||
// Just a single Frame (save a normal PNG):
|
||||
WritePNG( hMNG, 0, 1 );
|
||||
|
||||
// Now write file:
|
||||
mng_write(hMNG);
|
||||
|
||||
// Free the stuff:
|
||||
fclose( mymngstuff->file );
|
||||
mng_cleanup(&hMNG);
|
||||
}
|
||||
|
||||
free( mymngstuff );
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Main.rc
|
||||
//
|
||||
#define THEMENU 102
|
||||
#define APPICON 200
|
||||
#define FILE_OPEN 40002
|
||||
#define FILE_EXIT 40003
|
||||
#define HELP_ABOUT 40004
|
||||
#define FILE_SAVE 40005
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 104
|
||||
#define _APS_NEXT_COMMAND_VALUE 40006
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
Binary file not shown.
Reference in New Issue
Block a user