mirror of
https://github.com/love2d/megasource.git
synced 2026-08-20 20:50:52 +02:00
Add DevIL 1.7.8.
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// DevIL GDI+ Sources
|
||||
// Copyright (C) 2000-2002 by Denton Woods
|
||||
// Last modified: 02/13/2002 <--Y2K Compliant! =]
|
||||
//
|
||||
// Filename: gdi+/devil-gdi+.cpp
|
||||
//
|
||||
// Description: GDI+ loading routines
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "DevIL-GDI+.h"
|
||||
|
||||
|
||||
// Basic Palette struct
|
||||
typedef struct ILpal
|
||||
{
|
||||
ILubyte *Palette; // the image palette (if any)
|
||||
ILuint PalSize; // size of the palette (in bytes)
|
||||
ILenum PalType; // the palette types below (0x0500 range)
|
||||
} ILpal;
|
||||
|
||||
|
||||
// The Fundamental Image struct
|
||||
typedef struct ILimage
|
||||
{
|
||||
ILuint Width; // the image's width
|
||||
ILuint Height; // the image's height
|
||||
ILuint Depth; // the image's depth
|
||||
ILubyte Bpp; // bytes per pixel (now number of channels)
|
||||
ILubyte Bpc; // bytes per channel
|
||||
ILuint Bps; // bytes per scanline (components for IL)
|
||||
ILubyte *Data; // the image data
|
||||
ILuint SizeOfData; // the total size of the data (in bytes)
|
||||
ILuint SizeOfPlane; // SizeOfData in a 2d image, size of each plane slice in a 3d image (in bytes)
|
||||
ILenum Format; // image format (in IL enum style)
|
||||
ILenum Type; // image type (in IL enum style)
|
||||
ILenum Origin; // origin of the image
|
||||
ILpal Pal; // palette details
|
||||
ILuint Duration; // length of the time to display this "frame"
|
||||
ILenum CubeFlags; // cube map flags for sides present in chain
|
||||
struct ILimage *Mipmaps; // mipmapped versions of this image terminated by a NULL - usu. NULL
|
||||
struct ILimage *Next; // next image in the chain - usu. NULL
|
||||
struct ILimage *Layers; // subsequent layers in the chain - usu. NULL
|
||||
ILuint NumNext; // number of images following this one (0 when not parent)
|
||||
ILuint NumMips; // number of mipmaps (0 when not parent)
|
||||
ILuint NumLayers; // number of layers (0 when not parent)
|
||||
ILuint *AnimList; // animation list
|
||||
ILuint AnimSize; // animation list size
|
||||
ILvoid *Profile; // colour profile
|
||||
ILuint ProfileSize; // colour profile size
|
||||
ILuint OffX, OffY; // offset of the image
|
||||
} ILimage;
|
||||
|
||||
ILAPI ILimage* ILAPIENTRY iConvertImage(ILenum DestFormat, ILenum DestType);
|
||||
ILAPI ILubyte* ILAPIENTRY iGetPaddedData(ILimage *Image);
|
||||
ILAPI ILimage* ILAPIENTRY ilGetCurImage(void);
|
||||
ILAPI ILvoid ILAPIENTRY ilCloseImage(ILimage *Image);
|
||||
ILAPI ILvoid ILAPIENTRY iBindImageTemp(void);
|
||||
|
||||
|
||||
// @TODO: Use 48-bit and 64-bit types.
|
||||
Bitmap *ilutConvertToBitmap()
|
||||
{
|
||||
Bitmap *Bmp = NULL;
|
||||
ILubyte *Data = NULL;
|
||||
ILimage *Image = NULL, *GdiCurImage = NULL;
|
||||
|
||||
GdiCurImage = ilGetCurImage();
|
||||
if (GdiCurImage == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (GdiCurImage->Format == IL_BGRA && GdiCurImage->Format == IL_UNSIGNED_BYTE) {
|
||||
Image = GdiCurImage;
|
||||
return new Bitmap(Image->Width, Image->Height, Image->Bps, PixelFormat32bppARGB, Image->Data);
|
||||
}
|
||||
else if (GdiCurImage->Format == IL_BGRA || GdiCurImage->Format == IL_RGBA) {
|
||||
Image = iConvertImage(IL_BGRA, IL_UNSIGNED_BYTE);
|
||||
if (Image == NULL)
|
||||
return NULL;
|
||||
Bmp = new Bitmap(Image->Width, Image->Height, Image->Bps, PixelFormat32bppARGB, Image->Data);
|
||||
ilCloseImage(Image);
|
||||
return Bmp;
|
||||
}
|
||||
else if (GdiCurImage->Format == IL_LUMINANCE &&
|
||||
(GdiCurImage->Type == IL_UNSIGNED_SHORT || GdiCurImage->Type == IL_SHORT)) {
|
||||
Image = GdiCurImage;
|
||||
return new Bitmap(Image->Width, Image->Height, Image->Bps, PixelFormat16bppGrayScale, Image->Data);
|
||||
}
|
||||
else if (GdiCurImage->Format == IL_LUMINANCE) {
|
||||
Image = iConvertImage(IL_LUMINANCE, IL_UNSIGNED_SHORT);
|
||||
if (Image == NULL)
|
||||
return NULL;
|
||||
Bmp = new Bitmap(Image->Width, Image->Height, Image->Bps, PixelFormat16bppGrayScale, Image->Data);
|
||||
ilCloseImage(Image);
|
||||
return Bmp;
|
||||
}
|
||||
else {
|
||||
Image = iConvertImage(IL_BGR, IL_UNSIGNED_BYTE);
|
||||
if (Image == NULL)
|
||||
return NULL;
|
||||
Bmp = new Bitmap(Image->Width, Image->Height, Image->Bps, PixelFormat24bppRGB, Image->Data);
|
||||
ilCloseImage(Image);
|
||||
return Bmp;
|
||||
}
|
||||
|
||||
return NULL; // Something really screwy has happened here...
|
||||
}
|
||||
|
||||
|
||||
Bitmap *ilutGDILoadImage(const ILstring FileName)
|
||||
{
|
||||
Bitmap *Bmp;
|
||||
|
||||
iBindImageTemp();
|
||||
if (!ilLoadImage(FileName))
|
||||
return NULL;
|
||||
|
||||
Bmp = ilutConvertToBitmap();
|
||||
|
||||
return Bmp;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// DevIL GDI+ Sources
|
||||
// Copyright (C) 2000-2002 by Denton Woods
|
||||
// Last modified: 02/13/2001 <--Y2K Compliant! =]
|
||||
//
|
||||
// Filename: gdi+/devil-gdi+.h
|
||||
//
|
||||
// Description: GDI+ CBitmap loading routines
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __gdi_il_h_
|
||||
#ifndef __GDI_IL_H__
|
||||
|
||||
#define __gdi_il_h_
|
||||
#define __GDI_IL_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <shlobj.h> // Needed to #include <Gdiplus.h>
|
||||
#include <Gdiplus.h>
|
||||
#include <IL/ilut.h>
|
||||
using namespace Gdiplus;
|
||||
|
||||
Bitmap *ilutConvertToBitmap();
|
||||
Bitmap *ilutGDILoadImage(const ILstring FileName);
|
||||
|
||||
#endif // __GDI_IL_H__
|
||||
#endif // __gdi_il_h__
|
||||
@@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 7.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GDI+", "GDI+.vcproj", "{3BE70721-42D4-42C3-A6C6-C01214CC2ABA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
ConfigName.0 = Debug
|
||||
ConfigName.1 = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectDependencies) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{3BE70721-42D4-42C3-A6C6-C01214CC2ABA}.Debug.ActiveCfg = Debug|Win32
|
||||
{3BE70721-42D4-42C3-A6C6-C01214CC2ABA}.Debug.Build.0 = Debug|Win32
|
||||
{3BE70721-42D4-42C3-A6C6-C01214CC2ABA}.Release.ActiveCfg = Release|Win32
|
||||
{3BE70721-42D4-42C3-A6C6-C01214CC2ABA}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding = "Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.00"
|
||||
Name="GDI+"
|
||||
ProjectGUID="{3BE70721-42D4-42C3-A6C6-C01214CC2ABA}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="3"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/GDI+.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="TRUE"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="3"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/GDI+.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
|
||||
<File
|
||||
RelativePath="DevIL-GDI+.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="stdafx.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc">
|
||||
<File
|
||||
RelativePath="DevIL-GDI+.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="stdafx.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="ReadMe.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// GDI+.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
@@ -0,0 +1,10 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
Reference in New Issue
Block a user