Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
il_profiles.c
Package: devil-1.7.99.tar.gz [view]
Upload User: wmy0603
Upload Date: 2022-05-02
Package Size: 1808k
Code Size: 3k
Category:
Compress-Decompress algrithms
Development Platform:
Visual C++
- //-----------------------------------------------------------------------------
- //
- // ImageLib Sources
- // Copyright (C) 2000-2002 by Denton Woods
- // Last modified: 01/23/2001 <--Y2K Compliant! =]
- //
- // Filename: src-IL/src/il_profiles.c
- //
- // Description: Colour profile handler
- //
- //-----------------------------------------------------------------------------
- #include "il_internal.h"
- #ifndef IL_NO_LCMS
- #ifdef PACKAGE_NAME
- #define IL_PACKAGE_NAME PACKAGE_NAME;
- #undef PACKAGE_NAME
- #endif
- #if (!defined(_WIN32) && !defined(_WIN64))
- #define NON_WINDOWS 1
- #ifdef LCMS_NODIRINCLUDE
- #include <lcms.h>
- #else
- #include <lcms/lcms.h>
- #endif
- #else
- #if defined(IL_USE_PRAGMA_LIBS)
- #if defined(_MSC_VER) || defined(__BORLANDC__)
- #ifndef _DEBUG
- #pragma comment(lib, "lcms.lib")
- #else
- #pragma comment(lib, "lcms-d.lib")
- #endif
- #endif
- #endif
- #include <lcms.h>
- #endif//_WIN32
- #ifdef PACKAGE_NAME
- #undef PACKAGE_NAME
- #endif
- #ifdef IL_PACKAGE_NAME
- #define PACKAGE_NAME IL_PACKAGE_NAME
- #undef IL_PACKAGE_NAME
- #endif
- #endif//IL_NO_LCMS
- ILboolean ILAPIENTRY ilApplyProfile(ILstring InProfile, ILstring OutProfile)
- {
- #ifndef IL_NO_LCMS
- cmsHPROFILE hInProfile, hOutProfile;
- cmsHTRANSFORM hTransform;
- ILubyte *Temp;
- ILint Format=0;
- #ifdef _UNICODE
- char AnsiName[512];
- #endif//_UNICODE
- if (iCurImage == NULL) {
- ilSetError(IL_ILLEGAL_OPERATION);
- return IL_FALSE;
- }
- switch (iCurImage->Type)
- {
- case IL_BYTE:
- case IL_UNSIGNED_BYTE:
- switch (iCurImage->Format)
- {
- case IL_LUMINANCE:
- Format = TYPE_GRAY_8;
- break;
- case IL_RGB:
- Format = TYPE_RGB_8;
- break;
- case IL_BGR:
- Format = TYPE_BGR_8;
- break;
- case IL_RGBA:
- Format = TYPE_RGBA_8;
- break;
- case IL_BGRA:
- Format = TYPE_BGRA_8;
- break;
- default:
- ilSetError(IL_INTERNAL_ERROR);
- return IL_FALSE;
- }
- break;
- case IL_SHORT:
- case IL_UNSIGNED_SHORT:
- switch (iCurImage->Format)
- {
- case IL_LUMINANCE:
- Format = TYPE_GRAY_16;
- break;
- case IL_RGB:
- Format = TYPE_RGB_16;
- break;
- case IL_BGR:
- Format = TYPE_BGR_16;
- break;
- case IL_RGBA:
- Format = TYPE_RGBA_16;
- break;
- case IL_BGRA:
- Format = TYPE_BGRA_16;
- break;
- default:
- ilSetError(IL_INTERNAL_ERROR);
- return IL_FALSE;
- }
- break;
- // These aren't supported right now.
- case IL_INT:
- case IL_UNSIGNED_INT:
- case IL_FLOAT:
- case IL_DOUBLE:
- ilSetError(IL_ILLEGAL_OPERATION);
- return IL_FALSE;
- }
- if (InProfile == NULL) {
- if (!iCurImage->Profile || !iCurImage->ProfileSize) {
- ilSetError(IL_INVALID_PARAM);
- return IL_FALSE;
- }
- hInProfile = iCurImage->Profile;
- }
- else {
- #ifndef _UNICODE
- hInProfile = cmsOpenProfileFromFile(InProfile, "r");
- #else
- wcstombs(AnsiName, InProfile, 512);
- hInProfile = cmsOpenProfileFromFile(AnsiName, "r");
- #endif//_UNICODE
- }
- #ifndef _UNICODE
- hOutProfile = cmsOpenProfileFromFile(OutProfile, "r");
- #else
- wcstombs(AnsiName, OutProfile, 512);
- hOutProfile = cmsOpenProfileFromFile(AnsiName, "r");
- #endif//_UNICODE
- hTransform = cmsCreateTransform(hInProfile, Format, hOutProfile, Format, INTENT_PERCEPTUAL, 0);
- Temp = (ILubyte*)ialloc(iCurImage->SizeOfData);
- if (Temp == NULL) {
- return IL_FALSE;
- }
- cmsDoTransform(hTransform, iCurImage->Data, Temp, iCurImage->SizeOfData / 3);
- ifree(iCurImage->Data);
- iCurImage->Data = Temp;
- cmsDeleteTransform(hTransform);
- if (InProfile != NULL)
- cmsCloseProfile(hInProfile);
- cmsCloseProfile(hOutProfile);
- #endif//IL_NO_LCMS
- return IL_TRUE;
- }