├── .gitignore ├── CxImageDLL ├── CxImageCrtDll.cpp ├── CxImageCrtDll.dsp ├── CxImageCrtDll.rc ├── CxImageCrtDll.vcproj ├── CxImageCrtDll_wince.sln ├── CxImageCrtDll_wince.vcproj ├── CxImageDll.dsw ├── CxImageDll_wince.sln ├── CxImageMfcDll.aps ├── CxImageMfcDll.clw ├── CxImageMfcDll.cpp ├── CxImageMfcDll.h ├── CxImageMfcDll.rc ├── CxImageMfcDll_wince.sln ├── CxImageMfcDll_wince.vcproj ├── StdAfx.cpp ├── StdAfx.h ├── StdCrt.h ├── cximagemfcdll.dsp ├── cximagemfcdll.vcproj ├── resource.h └── resrc1.h ├── Doxyfile.txt ├── cximage.dev ├── cximage.dsp ├── cximage.dsw ├── cximage.vcproj ├── cximage_wince.sln ├── cximage_wince.vcproj ├── license.txt ├── stdint.h ├── tif_xfile.cpp ├── xfile.h ├── ximabmp.cpp ├── ximabmp.h ├── ximacfg.h ├── ximadef.h ├── ximadsp.cpp ├── ximaenc.cpp ├── ximaexif.cpp ├── ximage.cpp ├── ximage.h ├── ximagif.cpp ├── ximagif.h ├── ximahist.cpp ├── ximaico.cpp ├── ximaico.h ├── ximainfo.cpp ├── ximaint.cpp ├── ximaiter.h ├── ximajas.cpp ├── ximajas.h ├── ximajbg.cpp ├── ximajbg.h ├── ximajpg.cpp ├── ximajpg.h ├── ximalpha.cpp ├── ximalyr.cpp ├── ximamng.cpp ├── ximamng.h ├── ximapal.cpp ├── ximapcx.cpp ├── ximapcx.h ├── ximapng.cpp ├── ximapng.h ├── ximapsd.cpp ├── ximapsd.h ├── ximaraw.cpp ├── ximaraw.h ├── ximasel.cpp ├── ximaska.cpp ├── ximaska.h ├── ximatga.cpp ├── ximatga.h ├── ximath.cpp ├── ximath.h ├── ximatif.cpp ├── ximatif.h ├── ximatran.cpp ├── ximawbmp.cpp ├── ximawbmp.h ├── ximawmf.cpp ├── ximawmf.h ├── ximawnd.cpp ├── xiofile.h ├── xmemfile.cpp └── xmemfile.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | -------------------------------------------------------------------------------- /CxImageDLL/CxImageCrtDll.cpp: -------------------------------------------------------------------------------- 1 | // CxImageCrtDll.cpp : Defines the entry point for the CxImageCrtDll application. 2 | // 3 | 4 | #include "stdcrt.h" 5 | 6 | BOOL APIENTRY DllMain( HANDLE /*hModule*/, 7 | DWORD /*ul_reason_for_call*/, 8 | LPVOID /*lpReserved*/ 9 | ) 10 | { 11 | return TRUE; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /CxImageDLL/CxImageCrtDll.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/movableink/cximage/73a4518e7a3a7fbc2f27c91e5873a56769c8dbf7/CxImageDLL/CxImageCrtDll.rc -------------------------------------------------------------------------------- /CxImageDLL/CxImageCrtDll_wince.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CxImageCrtDll", "CxImageCrtDll_wince.vcproj", "{8B2AFC31-F380-42E5-8C10-F1B31271D5D0}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Pocket PC 2003 (ARMV4) = Debug|Pocket PC 2003 (ARMV4) 9 | Debug|Smartphone 2003 (ARMV4) = Debug|Smartphone 2003 (ARMV4) 10 | Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 11 | Release|Pocket PC 2003 (ARMV4) = Release|Pocket PC 2003 (ARMV4) 12 | Release|Smartphone 2003 (ARMV4) = Release|Smartphone 2003 (ARMV4) 13 | Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4) 17 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Debug|Pocket PC 2003 (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4) 18 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Debug|Pocket PC 2003 (ARMV4).Deploy.0 = Debug|Pocket PC 2003 (ARMV4) 19 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Debug|Smartphone 2003 (ARMV4).ActiveCfg = Debug|Smartphone 2003 (ARMV4) 20 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Debug|Smartphone 2003 (ARMV4).Build.0 = Debug|Smartphone 2003 (ARMV4) 21 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Debug|Smartphone 2003 (ARMV4).Deploy.0 = Debug|Smartphone 2003 (ARMV4) 22 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 23 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 24 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 25 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4) 26 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4) 27 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4) 28 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Release|Smartphone 2003 (ARMV4).ActiveCfg = Release|Smartphone 2003 (ARMV4) 29 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Release|Smartphone 2003 (ARMV4).Build.0 = Release|Smartphone 2003 (ARMV4) 30 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Release|Smartphone 2003 (ARMV4).Deploy.0 = Release|Smartphone 2003 (ARMV4) 31 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 32 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 33 | {8B2AFC31-F380-42E5-8C10-F1B31271D5D0}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /CxImageDLL/CxImageDll.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "CxImageCrtDll"=.\CxImageCrtDll.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | Begin Project Dependency 15 | Project_Dep_Name j2000 16 | End Project Dependency 17 | Begin Project Dependency 18 | Project_Dep_Name jbig 19 | End Project Dependency 20 | Begin Project Dependency 21 | Project_Dep_Name jpeg 22 | End Project Dependency 23 | Begin Project Dependency 24 | Project_Dep_Name png 25 | End Project Dependency 26 | Begin Project Dependency 27 | Project_Dep_Name tiff 28 | End Project Dependency 29 | Begin Project Dependency 30 | Project_Dep_Name zlib 31 | End Project Dependency 32 | Begin Project Dependency 33 | Project_Dep_Name j2k 34 | End Project Dependency 35 | }}} 36 | 37 | ############################################################################### 38 | 39 | Project: "CxImageMfcDll"=.\cximagemfcdll.dsp - Package Owner=<4> 40 | 41 | Package=<5> 42 | {{{ 43 | }}} 44 | 45 | Package=<4> 46 | {{{ 47 | Begin Project Dependency 48 | Project_Dep_Name j2k 49 | End Project Dependency 50 | Begin Project Dependency 51 | Project_Dep_Name jbig 52 | End Project Dependency 53 | Begin Project Dependency 54 | Project_Dep_Name jpeg 55 | End Project Dependency 56 | Begin Project Dependency 57 | Project_Dep_Name png 58 | End Project Dependency 59 | Begin Project Dependency 60 | Project_Dep_Name tiff 61 | End Project Dependency 62 | Begin Project Dependency 63 | Project_Dep_Name zlib 64 | End Project Dependency 65 | }}} 66 | 67 | ############################################################################### 68 | 69 | Project: "j2k"=..\..\j2k\j2k.dsp - Package Owner=<4> 70 | 71 | Package=<5> 72 | {{{ 73 | }}} 74 | 75 | Package=<4> 76 | {{{ 77 | }}} 78 | 79 | ############################################################################### 80 | 81 | Project: "jbig"=..\..\jbig\jbig.dsp - Package Owner=<4> 82 | 83 | Package=<5> 84 | {{{ 85 | }}} 86 | 87 | Package=<4> 88 | {{{ 89 | }}} 90 | 91 | ############################################################################### 92 | 93 | Project: "jpeg"=..\..\jpeg\Jpeg.dsp - Package Owner=<4> 94 | 95 | Package=<5> 96 | {{{ 97 | }}} 98 | 99 | Package=<4> 100 | {{{ 101 | }}} 102 | 103 | ############################################################################### 104 | 105 | Project: "png"=..\..\png\png.dsp - Package Owner=<4> 106 | 107 | Package=<5> 108 | {{{ 109 | }}} 110 | 111 | Package=<4> 112 | {{{ 113 | }}} 114 | 115 | ############################################################################### 116 | 117 | Project: "tiff"=..\..\tiff\Tiff.dsp - Package Owner=<4> 118 | 119 | Package=<5> 120 | {{{ 121 | }}} 122 | 123 | Package=<4> 124 | {{{ 125 | }}} 126 | 127 | ############################################################################### 128 | 129 | Project: "zlib"=..\..\zlib\zlib.dsp - Package Owner=<4> 130 | 131 | Package=<5> 132 | {{{ 133 | }}} 134 | 135 | Package=<4> 136 | {{{ 137 | }}} 138 | 139 | ############################################################################### 140 | 141 | Global: 142 | 143 | Package=<5> 144 | {{{ 145 | }}} 146 | 147 | Package=<3> 148 | {{{ 149 | }}} 150 | 151 | ############################################################################### 152 | 153 | -------------------------------------------------------------------------------- /CxImageDLL/CxImageMfcDll.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/movableink/cximage/73a4518e7a3a7fbc2f27c91e5873a56769c8dbf7/CxImageDLL/CxImageMfcDll.aps -------------------------------------------------------------------------------- /CxImageDLL/CxImageMfcDll.clw: -------------------------------------------------------------------------------- 1 | ; CLW file contains information for the MFC ClassWizard 2 | 3 | [General Info] 4 | Version=1 5 | ClassCount=1 6 | Class1=CcximagemfcdllApp 7 | LastClass=CcximagemfcdllApp 8 | NewFileInclude2=#include "cximagemfcdll.h" 9 | ResourceCount=0 10 | NewFileInclude1=#include "stdafx.h" 11 | 12 | [CLS:CcximagemfcdllApp] 13 | Type=0 14 | HeaderFile=cximagemfcdll.h 15 | ImplementationFile=cximagemfcdll.cpp 16 | Filter=N 17 | -------------------------------------------------------------------------------- /CxImageDLL/CxImageMfcDll.cpp: -------------------------------------------------------------------------------- 1 | // cximagemfcdll.cpp : Defines the initialization routines for the DLL. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "cximagemfcdll.h" 6 | 7 | #ifdef _DEBUG 8 | #define new DEBUG_NEW 9 | #undef THIS_FILE 10 | static char THIS_FILE[] = __FILE__; 11 | #endif 12 | 13 | // 14 | // Note! 15 | // 16 | // If this DLL is dynamically linked against the MFC 17 | // DLLs, any functions exported from this DLL which 18 | // call into MFC must have the AFX_MANAGE_STATE macro 19 | // added at the very beginning of the function. 20 | // 21 | // For example: 22 | // 23 | // extern "C" BOOL PASCAL EXPORT ExportedFunction() 24 | // { 25 | // AFX_MANAGE_STATE(AfxGetStaticModuleState()); 26 | // // normal function body here 27 | // } 28 | // 29 | // It is very important that this macro appear in each 30 | // function, prior to any calls into MFC. This means that 31 | // it must appear as the first statement within the 32 | // function, even before any object variable declarations 33 | // as their constructors may generate calls into the MFC 34 | // DLL. 35 | // 36 | // Please see MFC Technical Notes 33 and 58 for additional 37 | // details. 38 | // 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | // CcximagemfcdllApp 42 | 43 | BEGIN_MESSAGE_MAP(CcximagemfcdllApp, CWinApp) 44 | //{{AFX_MSG_MAP(CcximagemfcdllApp) 45 | // NOTE - the ClassWizard will add and remove mapping macros here. 46 | // DO NOT EDIT what you see in these blocks of generated code! 47 | //}}AFX_MSG_MAP 48 | END_MESSAGE_MAP() 49 | 50 | ///////////////////////////////////////////////////////////////////////////// 51 | // CcximagemfcdllApp construction 52 | 53 | CcximagemfcdllApp::CcximagemfcdllApp() 54 | { 55 | // TODO: add construction code here, 56 | // Place all significant initialization in InitInstance 57 | } 58 | 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // The one and only CcximagemfcdllApp object 61 | 62 | CcximagemfcdllApp theApp; 63 | -------------------------------------------------------------------------------- /CxImageDLL/CxImageMfcDll.h: -------------------------------------------------------------------------------- 1 | // cximagemfcdll.h : main header file for the cximagemfcdll DLL 2 | // 3 | 4 | #if !defined(AFX_cximagemfcdll_H__E98F71A6_B361_11D6_BB83_CAEE2E1CB77B__INCLUDED_) 5 | #define AFX_cximagemfcdll_H__E98F71A6_B361_11D6_BB83_CAEE2E1CB77B__INCLUDED_ 6 | 7 | #if _MSC_VER > 1000 8 | #pragma once 9 | #endif // _MSC_VER > 1000 10 | 11 | #ifndef __AFXWIN_H__ 12 | #error include 'stdafx.h' before including this file for PCH 13 | #endif 14 | 15 | #include "resource.h" // main symbols 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // CcximagemfcdllApp 19 | // See cximagemfcdll.cpp for the implementation of this class 20 | // 21 | 22 | class CcximagemfcdllApp : public CWinApp 23 | { 24 | public: 25 | CcximagemfcdllApp(); 26 | 27 | // Overrides 28 | // ClassWizard generated virtual function overrides 29 | //{{AFX_VIRTUAL(CcximagemfcdllApp) 30 | //}}AFX_VIRTUAL 31 | 32 | //{{AFX_MSG(CcximagemfcdllApp) 33 | // NOTE - the ClassWizard will add and remove member functions here. 34 | // DO NOT EDIT what you see in these blocks of generated code ! 35 | //}}AFX_MSG 36 | DECLARE_MESSAGE_MAP() 37 | }; 38 | 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | 42 | //{{AFX_INSERT_LOCATION}} 43 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 44 | 45 | #endif // !defined(AFX_cximagemfcdll_H__E98F71A6_B361_11D6_BB83_CAEE2E1CB77B__INCLUDED_) 46 | -------------------------------------------------------------------------------- /CxImageDLL/CxImageMfcDll.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/movableink/cximage/73a4518e7a3a7fbc2f27c91e5873a56769c8dbf7/CxImageDLL/CxImageMfcDll.rc -------------------------------------------------------------------------------- /CxImageDLL/CxImageMfcDll_wince.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cximagemfcdll", "CxImageMfcDll_wince.vcproj", "{82CE2B54-F77C-4B7F-890B-CC498A24B660}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Pocket PC 2003 (ARMV4) = Debug|Pocket PC 2003 (ARMV4) 9 | Debug|Smartphone 2003 (ARMV4) = Debug|Smartphone 2003 (ARMV4) 10 | Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 11 | Release|Pocket PC 2003 (ARMV4) = Release|Pocket PC 2003 (ARMV4) 12 | Release|Smartphone 2003 (ARMV4) = Release|Smartphone 2003 (ARMV4) 13 | Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4) 17 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Debug|Pocket PC 2003 (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4) 18 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Debug|Pocket PC 2003 (ARMV4).Deploy.0 = Debug|Pocket PC 2003 (ARMV4) 19 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Debug|Smartphone 2003 (ARMV4).ActiveCfg = Debug|Smartphone 2003 (ARMV4) 20 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Debug|Smartphone 2003 (ARMV4).Build.0 = Debug|Smartphone 2003 (ARMV4) 21 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Debug|Smartphone 2003 (ARMV4).Deploy.0 = Debug|Smartphone 2003 (ARMV4) 22 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 23 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 24 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 25 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4) 26 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4) 27 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4) 28 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Release|Smartphone 2003 (ARMV4).ActiveCfg = Release|Smartphone 2003 (ARMV4) 29 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Release|Smartphone 2003 (ARMV4).Build.0 = Release|Smartphone 2003 (ARMV4) 30 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Release|Smartphone 2003 (ARMV4).Deploy.0 = Release|Smartphone 2003 (ARMV4) 31 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 32 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 33 | {82CE2B54-F77C-4B7F-890B-CC498A24B660}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /CxImageDLL/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // cximagemfcdll.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CxImageDLL/StdAfx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #if !defined(AFX_STDAFX_H__E98F71A8_B361_11D6_BB83_CAEE2E1CB77B__INCLUDED_) 7 | #define AFX_STDAFX_H__E98F71A8_B361_11D6_BB83_CAEE2E1CB77B__INCLUDED_ 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif // _MSC_VER > 1000 12 | 13 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 14 | 15 | #ifndef WINVER 16 | #define WINVER 0x0400 17 | #endif 18 | 19 | #include // MFC core and standard components 20 | #include // MFC extensions 21 | 22 | #ifndef _AFX_NO_OLE_SUPPORT 23 | #include // MFC OLE classes 24 | #include // MFC OLE dialog classes 25 | #include // MFC Automation classes 26 | #endif // _AFX_NO_OLE_SUPPORT 27 | 28 | 29 | #ifndef _AFX_NO_DB_SUPPORT 30 | #include // MFC ODBC database classes 31 | #endif // _AFX_NO_DB_SUPPORT 32 | 33 | #ifndef _AFX_NO_DAO_SUPPORT 34 | #include // MFC DAO database classes 35 | #endif // _AFX_NO_DAO_SUPPORT 36 | 37 | #include // MFC support for Internet Explorer 4 Common Controls 38 | #ifndef _AFX_NO_AFXCMN_SUPPORT 39 | #include // MFC support for Windows Common Controls 40 | #endif // _AFX_NO_AFXCMN_SUPPORT 41 | 42 | #if defined(_WIN32_WCE) && (_WIN32_WCE < 0x501) 43 | #pragma comment(lib, "ccrtrtti.lib") 44 | #pragma comment(lib, "secchk.lib") 45 | #endif 46 | 47 | //{{AFX_INSERT_LOCATION}} 48 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 49 | 50 | #endif // !defined(AFX_STDAFX_H__E98F71A8_B361_11D6_BB83_CAEE2E1CB77B__INCLUDED_) 51 | -------------------------------------------------------------------------------- /CxImageDLL/StdCrt.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #if !defined(AFX_STDAFX_H__F30A8A60_284F_4DF6_9431_6283105686F6__INCLUDED_) 7 | #define AFX_STDAFX_H__F30A8A60_284F_4DF6_9431_6283105686F6__INCLUDED_ 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif // _MSC_VER > 1000 12 | 13 | 14 | // Insert your headers here 15 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 16 | 17 | #include 18 | 19 | // TODO: reference additional headers your program requires here 20 | #if defined(_WIN32_WCE) && (_WIN32_WCE < 0x501) 21 | #pragma comment(lib, "ccrtrtti.lib") 22 | #pragma comment(lib, "secchk.lib") 23 | #endif 24 | 25 | //{{AFX_INSERT_LOCATION}} 26 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 27 | 28 | #endif // !defined(AFX_STDAFX_H__F30A8A60_284F_4DF6_9431_6283105686F6__INCLUDED_) 29 | -------------------------------------------------------------------------------- /CxImageDLL/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by CxImageMFCdll.rc 4 | // 5 | 6 | // Next default values for new objects 7 | // 8 | #ifdef APSTUDIO_INVOKED 9 | #ifndef APSTUDIO_READONLY_SYMBOLS 10 | #define _APS_NEXT_RESOURCE_VALUE 6000 11 | #define _APS_NEXT_COMMAND_VALUE 32771 12 | #define _APS_NEXT_CONTROL_VALUE 6000 13 | #define _APS_NEXT_SYMED_VALUE 6000 14 | #endif 15 | #endif 16 | -------------------------------------------------------------------------------- /CxImageDLL/resrc1.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by CxImageCrtDll.rc 4 | // 5 | 6 | // Next default values for new objects 7 | // 8 | #ifdef APSTUDIO_INVOKED 9 | #ifndef APSTUDIO_READONLY_SYMBOLS 10 | #define _APS_NEXT_RESOURCE_VALUE 6000 11 | #define _APS_NEXT_COMMAND_VALUE 32771 12 | #define _APS_NEXT_CONTROL_VALUE 6000 13 | #define _APS_NEXT_SYMED_VALUE 6000 14 | #endif 15 | #endif 16 | -------------------------------------------------------------------------------- /Doxyfile.txt: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.5.4 2 | 3 | #--------------------------------------------------------------------------- 4 | # Project related configuration options 5 | #--------------------------------------------------------------------------- 6 | DOXYFILE_ENCODING = UTF-8 7 | PROJECT_NAME = CxImage 8 | PROJECT_NUMBER = 7.0.1.0 9 | OUTPUT_DIRECTORY = D:/dev2/work/cximage701_full/doc/doxy 10 | CREATE_SUBDIRS = NO 11 | OUTPUT_LANGUAGE = English 12 | BRIEF_MEMBER_DESC = YES 13 | REPEAT_BRIEF = YES 14 | ABBREVIATE_BRIEF = "The $name class " \ 15 | "The $name widget " \ 16 | "The $name file " \ 17 | is \ 18 | provides \ 19 | specifies \ 20 | contains \ 21 | represents \ 22 | a \ 23 | an \ 24 | the 25 | ALWAYS_DETAILED_SEC = NO 26 | INLINE_INHERITED_MEMB = NO 27 | FULL_PATH_NAMES = NO 28 | STRIP_FROM_PATH = "H:/Documents and Settings/Administrator/ " 29 | STRIP_FROM_INC_PATH = 30 | SHORT_NAMES = NO 31 | JAVADOC_AUTOBRIEF = NO 32 | QT_AUTOBRIEF = NO 33 | MULTILINE_CPP_IS_BRIEF = NO 34 | DETAILS_AT_TOP = NO 35 | INHERIT_DOCS = YES 36 | SEPARATE_MEMBER_PAGES = NO 37 | TAB_SIZE = 8 38 | ALIASES = 39 | OPTIMIZE_OUTPUT_FOR_C = NO 40 | OPTIMIZE_OUTPUT_JAVA = NO 41 | BUILTIN_STL_SUPPORT = NO 42 | CPP_CLI_SUPPORT = NO 43 | SIP_SUPPORT = NO 44 | DISTRIBUTE_GROUP_DOC = NO 45 | SUBGROUPING = YES 46 | TYPEDEF_HIDES_STRUCT = NO 47 | #--------------------------------------------------------------------------- 48 | # Build related configuration options 49 | #--------------------------------------------------------------------------- 50 | EXTRACT_ALL = YES 51 | EXTRACT_PRIVATE = YES 52 | EXTRACT_STATIC = YES 53 | EXTRACT_LOCAL_CLASSES = YES 54 | EXTRACT_LOCAL_METHODS = NO 55 | EXTRACT_ANON_NSPACES = NO 56 | HIDE_UNDOC_MEMBERS = NO 57 | HIDE_UNDOC_CLASSES = NO 58 | HIDE_FRIEND_COMPOUNDS = NO 59 | HIDE_IN_BODY_DOCS = NO 60 | INTERNAL_DOCS = NO 61 | CASE_SENSE_NAMES = NO 62 | HIDE_SCOPE_NAMES = NO 63 | SHOW_INCLUDE_FILES = YES 64 | INLINE_INFO = YES 65 | SORT_MEMBER_DOCS = YES 66 | SORT_BRIEF_DOCS = NO 67 | SORT_BY_SCOPE_NAME = NO 68 | GENERATE_TODOLIST = YES 69 | GENERATE_TESTLIST = YES 70 | GENERATE_BUGLIST = YES 71 | GENERATE_DEPRECATEDLIST= YES 72 | ENABLED_SECTIONS = 73 | MAX_INITIALIZER_LINES = 30 74 | SHOW_USED_FILES = NO 75 | SHOW_DIRECTORIES = NO 76 | FILE_VERSION_FILTER = 77 | #--------------------------------------------------------------------------- 78 | # configuration options related to warning and progress messages 79 | #--------------------------------------------------------------------------- 80 | QUIET = NO 81 | WARNINGS = YES 82 | WARN_IF_UNDOCUMENTED = YES 83 | WARN_IF_DOC_ERROR = YES 84 | WARN_NO_PARAMDOC = NO 85 | WARN_FORMAT = "$file:$line: $text " 86 | WARN_LOGFILE = 87 | #--------------------------------------------------------------------------- 88 | # configuration options related to the input files 89 | #--------------------------------------------------------------------------- 90 | INPUT = 91 | INPUT_ENCODING = UTF-8 92 | FILE_PATTERNS = *.cpp \ 93 | ximadef.h \ 94 | ximacfg.h \ 95 | ximage.h \ 96 | ximath.h \ 97 | xfile.h 98 | RECURSIVE = NO 99 | EXCLUDE = 100 | EXCLUDE_SYMLINKS = NO 101 | EXCLUDE_PATTERNS = 102 | EXCLUDE_SYMBOLS = 103 | EXAMPLE_PATH = 104 | EXAMPLE_PATTERNS = * 105 | EXAMPLE_RECURSIVE = NO 106 | IMAGE_PATH = 107 | INPUT_FILTER = 108 | FILTER_PATTERNS = 109 | FILTER_SOURCE_FILES = NO 110 | #--------------------------------------------------------------------------- 111 | # configuration options related to source browsing 112 | #--------------------------------------------------------------------------- 113 | SOURCE_BROWSER = NO 114 | INLINE_SOURCES = NO 115 | STRIP_CODE_COMMENTS = YES 116 | REFERENCED_BY_RELATION = NO 117 | REFERENCES_RELATION = NO 118 | REFERENCES_LINK_SOURCE = YES 119 | USE_HTAGS = NO 120 | VERBATIM_HEADERS = NO 121 | #--------------------------------------------------------------------------- 122 | # configuration options related to the alphabetical class index 123 | #--------------------------------------------------------------------------- 124 | ALPHABETICAL_INDEX = NO 125 | COLS_IN_ALPHA_INDEX = 5 126 | IGNORE_PREFIX = 127 | #--------------------------------------------------------------------------- 128 | # configuration options related to the HTML output 129 | #--------------------------------------------------------------------------- 130 | GENERATE_HTML = YES 131 | HTML_OUTPUT = html 132 | HTML_FILE_EXTENSION = .html 133 | HTML_HEADER = 134 | HTML_FOOTER = 135 | HTML_STYLESHEET = 136 | HTML_ALIGN_MEMBERS = YES 137 | GENERATE_HTMLHELP = NO 138 | HTML_DYNAMIC_SECTIONS = NO 139 | CHM_FILE = 140 | HHC_LOCATION = 141 | GENERATE_CHI = NO 142 | BINARY_TOC = NO 143 | TOC_EXPAND = NO 144 | DISABLE_INDEX = NO 145 | ENUM_VALUES_PER_LINE = 4 146 | GENERATE_TREEVIEW = YES 147 | TREEVIEW_WIDTH = 200 148 | #--------------------------------------------------------------------------- 149 | # configuration options related to the LaTeX output 150 | #--------------------------------------------------------------------------- 151 | GENERATE_LATEX = NO 152 | LATEX_OUTPUT = latex 153 | LATEX_CMD_NAME = latex 154 | MAKEINDEX_CMD_NAME = makeindex 155 | COMPACT_LATEX = NO 156 | PAPER_TYPE = a4wide 157 | EXTRA_PACKAGES = 158 | LATEX_HEADER = 159 | PDF_HYPERLINKS = NO 160 | USE_PDFLATEX = NO 161 | LATEX_BATCHMODE = NO 162 | LATEX_HIDE_INDICES = NO 163 | #--------------------------------------------------------------------------- 164 | # configuration options related to the RTF output 165 | #--------------------------------------------------------------------------- 166 | GENERATE_RTF = NO 167 | RTF_OUTPUT = rtf 168 | COMPACT_RTF = NO 169 | RTF_HYPERLINKS = NO 170 | RTF_STYLESHEET_FILE = 171 | RTF_EXTENSIONS_FILE = 172 | #--------------------------------------------------------------------------- 173 | # configuration options related to the man page output 174 | #--------------------------------------------------------------------------- 175 | GENERATE_MAN = NO 176 | MAN_OUTPUT = man 177 | MAN_EXTENSION = .3 178 | MAN_LINKS = NO 179 | #--------------------------------------------------------------------------- 180 | # configuration options related to the XML output 181 | #--------------------------------------------------------------------------- 182 | GENERATE_XML = NO 183 | XML_OUTPUT = xml 184 | XML_SCHEMA = 185 | XML_DTD = 186 | XML_PROGRAMLISTING = YES 187 | #--------------------------------------------------------------------------- 188 | # configuration options for the AutoGen Definitions output 189 | #--------------------------------------------------------------------------- 190 | GENERATE_AUTOGEN_DEF = NO 191 | #--------------------------------------------------------------------------- 192 | # configuration options related to the Perl module output 193 | #--------------------------------------------------------------------------- 194 | GENERATE_PERLMOD = NO 195 | PERLMOD_LATEX = NO 196 | PERLMOD_PRETTY = YES 197 | PERLMOD_MAKEVAR_PREFIX = 198 | #--------------------------------------------------------------------------- 199 | # Configuration options related to the preprocessor 200 | #--------------------------------------------------------------------------- 201 | ENABLE_PREPROCESSING = YES 202 | MACRO_EXPANSION = NO 203 | EXPAND_ONLY_PREDEF = NO 204 | SEARCH_INCLUDES = YES 205 | INCLUDE_PATH = 206 | INCLUDE_FILE_PATTERNS = 207 | PREDEFINED = WIN32 208 | EXPAND_AS_DEFINED = 209 | SKIP_FUNCTION_MACROS = YES 210 | #--------------------------------------------------------------------------- 211 | # Configuration::additions related to external references 212 | #--------------------------------------------------------------------------- 213 | TAGFILES = 214 | GENERATE_TAGFILE = 215 | ALLEXTERNALS = NO 216 | EXTERNAL_GROUPS = YES 217 | PERL_PATH = /usr/bin/perl 218 | #--------------------------------------------------------------------------- 219 | # Configuration options related to the dot tool 220 | #--------------------------------------------------------------------------- 221 | CLASS_DIAGRAMS = NO 222 | MSCGEN_PATH = 223 | HIDE_UNDOC_RELATIONS = YES 224 | HAVE_DOT = NO 225 | CLASS_GRAPH = YES 226 | COLLABORATION_GRAPH = YES 227 | GROUP_GRAPHS = YES 228 | UML_LOOK = NO 229 | TEMPLATE_RELATIONS = NO 230 | INCLUDE_GRAPH = YES 231 | INCLUDED_BY_GRAPH = YES 232 | CALL_GRAPH = NO 233 | CALLER_GRAPH = NO 234 | GRAPHICAL_HIERARCHY = YES 235 | DIRECTORY_GRAPH = YES 236 | DOT_IMAGE_FORMAT = png 237 | DOT_PATH = 238 | DOTFILE_DIRS = 239 | DOT_GRAPH_MAX_NODES = 50 240 | MAX_DOT_GRAPH_DEPTH = 1000 241 | DOT_TRANSPARENT = YES 242 | DOT_MULTI_TARGETS = NO 243 | GENERATE_LEGEND = YES 244 | DOT_CLEANUP = YES 245 | #--------------------------------------------------------------------------- 246 | # Configuration::additions related to the search engine 247 | #--------------------------------------------------------------------------- 248 | SEARCHENGINE = NO 249 | -------------------------------------------------------------------------------- /cximage.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=cximage.dev 3 | Name=cximage 4 | UnitCount=57 5 | PchHead=-1 6 | PchSource=-1 7 | Ver=3 8 | IsCpp=1 9 | ProfilesCount=2 10 | ProfileIndex=0 11 | Folders=headres 12 | 13 | [Unit1] 14 | FileName=xmemfile.cpp 15 | CompileCpp=1 16 | Folder=cximage 17 | Compile=1 18 | Link=1 19 | Priority=1000 20 | OverrideBuildCmd=0 21 | BuildCmd= 22 | 23 | [Unit2] 24 | FileName=tif_xfile.cpp 25 | CompileCpp=1 26 | Folder=cximage 27 | Compile=1 28 | Link=1 29 | Priority=1000 30 | OverrideBuildCmd=0 31 | BuildCmd= 32 | 33 | [Unit3] 34 | FileName=ximabmp.cpp 35 | CompileCpp=1 36 | Folder=cximage 37 | Compile=1 38 | Link=1 39 | Priority=1000 40 | OverrideBuildCmd=0 41 | BuildCmd= 42 | 43 | [Unit4] 44 | FileName=ximadsp.cpp 45 | CompileCpp=1 46 | Folder=cximage 47 | Compile=1 48 | Link=1 49 | Priority=1000 50 | OverrideBuildCmd=0 51 | BuildCmd= 52 | 53 | [Unit5] 54 | FileName=ximaenc.cpp 55 | CompileCpp=1 56 | Folder=cximage 57 | Compile=1 58 | Link=1 59 | Priority=1000 60 | OverrideBuildCmd=0 61 | BuildCmd= 62 | 63 | [Unit6] 64 | FileName=ximaexif.cpp 65 | CompileCpp=1 66 | Folder=cximage 67 | Compile=1 68 | Link=1 69 | Priority=1000 70 | OverrideBuildCmd=0 71 | BuildCmd= 72 | 73 | [Unit7] 74 | FileName=ximage.cpp 75 | CompileCpp=1 76 | Folder=cximage 77 | Compile=1 78 | Link=1 79 | Priority=1000 80 | OverrideBuildCmd=0 81 | BuildCmd= 82 | 83 | [Unit8] 84 | FileName=ximagif.cpp 85 | CompileCpp=1 86 | Folder=cximage 87 | Compile=1 88 | Link=1 89 | Priority=1000 90 | OverrideBuildCmd=0 91 | BuildCmd= 92 | 93 | [Unit9] 94 | FileName=ximahist.cpp 95 | CompileCpp=1 96 | Folder=cximage 97 | Compile=1 98 | Link=1 99 | Priority=1000 100 | OverrideBuildCmd=0 101 | BuildCmd= 102 | 103 | [Unit10] 104 | FileName=ximaico.cpp 105 | CompileCpp=1 106 | Folder=cximage 107 | Compile=1 108 | Link=1 109 | Priority=1000 110 | OverrideBuildCmd=0 111 | BuildCmd= 112 | 113 | [Unit11] 114 | FileName=ximainfo.cpp 115 | CompileCpp=1 116 | Folder=cximage 117 | Compile=1 118 | Link=1 119 | Priority=1000 120 | OverrideBuildCmd=0 121 | BuildCmd= 122 | 123 | [Unit12] 124 | FileName=ximaint.cpp 125 | CompileCpp=1 126 | Folder=cximage 127 | Compile=1 128 | Link=1 129 | Priority=1000 130 | OverrideBuildCmd=0 131 | BuildCmd= 132 | 133 | [Unit13] 134 | FileName=ximajas.cpp 135 | CompileCpp=1 136 | Folder=cximage 137 | Compile=1 138 | Link=1 139 | Priority=1000 140 | OverrideBuildCmd=0 141 | BuildCmd= 142 | 143 | [Unit14] 144 | FileName=ximajbg.cpp 145 | CompileCpp=1 146 | Folder=cximage 147 | Compile=1 148 | Link=1 149 | Priority=1000 150 | OverrideBuildCmd=0 151 | BuildCmd= 152 | 153 | [Unit15] 154 | FileName=ximajpg.cpp 155 | CompileCpp=1 156 | Folder=cximage 157 | Compile=1 158 | Link=1 159 | Priority=1000 160 | OverrideBuildCmd=0 161 | BuildCmd= 162 | 163 | [Unit16] 164 | FileName=ximalpha.cpp 165 | CompileCpp=1 166 | Folder=cximage 167 | Compile=1 168 | Link=1 169 | Priority=1000 170 | OverrideBuildCmd=0 171 | BuildCmd= 172 | 173 | [Unit17] 174 | FileName=ximalyr.cpp 175 | CompileCpp=1 176 | Folder=cximage 177 | Compile=1 178 | Link=1 179 | Priority=1000 180 | OverrideBuildCmd=0 181 | BuildCmd= 182 | 183 | [Unit18] 184 | FileName=ximamng.cpp 185 | CompileCpp=1 186 | Folder=cximage 187 | Compile=1 188 | Link=1 189 | Priority=1000 190 | OverrideBuildCmd=0 191 | BuildCmd= 192 | 193 | [Unit19] 194 | FileName=ximapal.cpp 195 | CompileCpp=1 196 | Folder=cximage 197 | Compile=1 198 | Link=1 199 | Priority=1000 200 | OverrideBuildCmd=0 201 | BuildCmd= 202 | 203 | [Unit20] 204 | FileName=ximapcx.cpp 205 | CompileCpp=1 206 | Folder=cximage 207 | Compile=1 208 | Link=1 209 | Priority=1000 210 | OverrideBuildCmd=0 211 | BuildCmd= 212 | 213 | [Unit21] 214 | FileName=ximapng.cpp 215 | CompileCpp=1 216 | Folder=cximage 217 | Compile=1 218 | Link=1 219 | Priority=1000 220 | OverrideBuildCmd=0 221 | BuildCmd= 222 | 223 | [Unit22] 224 | FileName=ximaraw.cpp 225 | CompileCpp=1 226 | Folder=cximage 227 | Compile=1 228 | Link=1 229 | Priority=1000 230 | OverrideBuildCmd=0 231 | BuildCmd= 232 | 233 | [Unit23] 234 | FileName=ximasel.cpp 235 | CompileCpp=1 236 | Folder=cximage 237 | Compile=1 238 | Link=1 239 | Priority=1000 240 | OverrideBuildCmd=0 241 | BuildCmd= 242 | 243 | [Unit24] 244 | FileName=ximaska.cpp 245 | CompileCpp=1 246 | Folder=cximage 247 | Compile=1 248 | Link=1 249 | Priority=1000 250 | OverrideBuildCmd=0 251 | BuildCmd= 252 | 253 | [Unit25] 254 | FileName=ximatga.cpp 255 | CompileCpp=1 256 | Folder=cximage 257 | Compile=1 258 | Link=1 259 | Priority=1000 260 | OverrideBuildCmd=0 261 | BuildCmd= 262 | 263 | [Unit26] 264 | FileName=ximath.cpp 265 | CompileCpp=1 266 | Folder=cximage 267 | Compile=1 268 | Link=1 269 | Priority=1000 270 | OverrideBuildCmd=0 271 | BuildCmd= 272 | 273 | [Unit27] 274 | FileName=ximatif.cpp 275 | CompileCpp=1 276 | Folder=cximage 277 | Compile=1 278 | Link=1 279 | Priority=1000 280 | OverrideBuildCmd=0 281 | BuildCmd= 282 | 283 | [Unit28] 284 | FileName=ximatran.cpp 285 | CompileCpp=1 286 | Folder=cximage 287 | Compile=1 288 | Link=1 289 | Priority=1000 290 | OverrideBuildCmd=0 291 | BuildCmd= 292 | 293 | [Unit29] 294 | FileName=ximawbmp.cpp 295 | CompileCpp=1 296 | Folder=cximage 297 | Compile=1 298 | Link=1 299 | Priority=1000 300 | OverrideBuildCmd=0 301 | BuildCmd= 302 | 303 | [Unit30] 304 | FileName=ximawmf.cpp 305 | CompileCpp=1 306 | Folder=cximage 307 | Compile=1 308 | Link=1 309 | Priority=1000 310 | OverrideBuildCmd=0 311 | BuildCmd= 312 | 313 | [Unit31] 314 | FileName=ximawnd.cpp 315 | CompileCpp=1 316 | Folder=cximage 317 | Compile=1 318 | Link=1 319 | Priority=1000 320 | OverrideBuildCmd=0 321 | BuildCmd= 322 | 323 | [Unit32] 324 | FileName=xfile.h 325 | CompileCpp=1 326 | Folder=headres 327 | Compile=1 328 | Link=1 329 | Priority=1000 330 | OverrideBuildCmd=0 331 | BuildCmd= 332 | 333 | [Unit33] 334 | FileName=ximabmp.h 335 | CompileCpp=1 336 | Folder=headres 337 | Compile=1 338 | Link=1 339 | Priority=1000 340 | OverrideBuildCmd=0 341 | BuildCmd= 342 | 343 | [Unit34] 344 | FileName=ximacfg.h 345 | CompileCpp=1 346 | Folder=headres 347 | Compile=1 348 | Link=1 349 | Priority=1000 350 | OverrideBuildCmd=0 351 | BuildCmd= 352 | 353 | [Unit35] 354 | FileName=ximadef.h 355 | CompileCpp=1 356 | Folder=headres 357 | Compile=1 358 | Link=1 359 | Priority=1000 360 | OverrideBuildCmd=0 361 | BuildCmd= 362 | 363 | [Unit36] 364 | FileName=ximage.h 365 | CompileCpp=1 366 | Folder=headres 367 | Compile=1 368 | Link=1 369 | Priority=1000 370 | OverrideBuildCmd=0 371 | BuildCmd= 372 | 373 | [Unit37] 374 | FileName=ximagif.h 375 | CompileCpp=1 376 | Folder=headres 377 | Compile=1 378 | Link=1 379 | Priority=1000 380 | OverrideBuildCmd=0 381 | BuildCmd= 382 | 383 | [Unit38] 384 | FileName=ximaico.h 385 | CompileCpp=1 386 | Folder=headres 387 | Compile=1 388 | Link=1 389 | Priority=1000 390 | OverrideBuildCmd=0 391 | BuildCmd= 392 | 393 | [Unit39] 394 | FileName=ximaiter.h 395 | CompileCpp=1 396 | Folder=headres 397 | Compile=1 398 | Link=1 399 | Priority=1000 400 | OverrideBuildCmd=0 401 | BuildCmd= 402 | 403 | [Unit40] 404 | FileName=ximajas.h 405 | CompileCpp=1 406 | Folder=headres 407 | Compile=1 408 | Link=1 409 | Priority=1000 410 | OverrideBuildCmd=0 411 | BuildCmd= 412 | 413 | [Unit41] 414 | FileName=ximajbg.h 415 | CompileCpp=1 416 | Folder=headres 417 | Compile=1 418 | Link=1 419 | Priority=1000 420 | OverrideBuildCmd=0 421 | BuildCmd= 422 | 423 | [Unit42] 424 | FileName=ximajpg.h 425 | CompileCpp=1 426 | Folder=headres 427 | Compile=1 428 | Link=1 429 | Priority=1000 430 | OverrideBuildCmd=0 431 | BuildCmd= 432 | 433 | [Unit43] 434 | FileName=ximamng.h 435 | CompileCpp=1 436 | Folder=headres 437 | Compile=1 438 | Link=1 439 | Priority=1000 440 | OverrideBuildCmd=0 441 | BuildCmd= 442 | 443 | [Unit44] 444 | FileName=ximapcx.h 445 | CompileCpp=1 446 | Folder=headres 447 | Compile=1 448 | Link=1 449 | Priority=1000 450 | OverrideBuildCmd=0 451 | BuildCmd= 452 | 453 | [Unit45] 454 | FileName=ximapng.h 455 | CompileCpp=1 456 | Folder=headres 457 | Compile=1 458 | Link=1 459 | Priority=1000 460 | OverrideBuildCmd=0 461 | BuildCmd= 462 | 463 | [Unit46] 464 | FileName=ximaraw.h 465 | CompileCpp=1 466 | Folder=headres 467 | Compile=1 468 | Link=1 469 | Priority=1000 470 | OverrideBuildCmd=0 471 | BuildCmd= 472 | 473 | [Unit47] 474 | FileName=ximaska.h 475 | CompileCpp=1 476 | Folder=headres 477 | Compile=1 478 | Link=1 479 | Priority=1000 480 | OverrideBuildCmd=0 481 | BuildCmd= 482 | 483 | [Unit48] 484 | FileName=ximatga.h 485 | CompileCpp=1 486 | Folder=headres 487 | Compile=1 488 | Link=1 489 | Priority=1000 490 | OverrideBuildCmd=0 491 | BuildCmd= 492 | 493 | [Unit49] 494 | FileName=ximath.h 495 | CompileCpp=1 496 | Folder=headres 497 | Compile=1 498 | Link=1 499 | Priority=1000 500 | OverrideBuildCmd=0 501 | BuildCmd= 502 | 503 | [Unit50] 504 | FileName=ximatif.h 505 | CompileCpp=1 506 | Folder=headres 507 | Compile=1 508 | Link=1 509 | Priority=1000 510 | OverrideBuildCmd=0 511 | BuildCmd= 512 | 513 | [Unit51] 514 | FileName=ximawbmp.h 515 | CompileCpp=1 516 | Folder=headres 517 | Compile=1 518 | Link=1 519 | Priority=1000 520 | OverrideBuildCmd=0 521 | BuildCmd= 522 | 523 | [Unit52] 524 | FileName=ximawmf.h 525 | CompileCpp=1 526 | Folder=headres 527 | Compile=1 528 | Link=1 529 | Priority=1000 530 | OverrideBuildCmd=0 531 | BuildCmd= 532 | 533 | [Unit53] 534 | FileName=xiofile.h 535 | CompileCpp=1 536 | Folder=headres 537 | Compile=1 538 | Link=1 539 | Priority=1000 540 | OverrideBuildCmd=0 541 | BuildCmd= 542 | 543 | [Unit54] 544 | FileName=xmemfile.h 545 | CompileCpp=1 546 | Folder=headres 547 | Compile=1 548 | Link=1 549 | Priority=1000 550 | OverrideBuildCmd=0 551 | BuildCmd= 552 | 553 | [Unit55] 554 | FileName=ximapsd.h 555 | CompileCpp=1 556 | Folder=headres 557 | Compile=1 558 | Link=1 559 | Priority=1000 560 | OverrideBuildCmd=0 561 | BuildCmd= 562 | 563 | [Unit56] 564 | FileName=ximapsd.cpp 565 | CompileCpp=1 566 | Folder=cximage 567 | Compile=1 568 | Link=1 569 | Priority=1000 570 | OverrideBuildCmd=0 571 | BuildCmd= 572 | 573 | [VersionInfo] 574 | Major=0 575 | Minor=1 576 | Release=1 577 | Build=1 578 | LanguageID=1033 579 | CharsetID=1252 580 | CompanyName= 581 | FileVersion= 582 | FileDescription= 583 | InternalName= 584 | LegalCopyright= 585 | LegalTrademarks= 586 | OriginalFilename= 587 | ProductName= 588 | ProductVersion= 589 | AutoIncBuildNrOnRebuild=0 590 | AutoIncBuildNrOnCompile=0 591 | 592 | [Profile1] 593 | ProfileName=Mingw 3.4.2 594 | Type=2 595 | ObjFiles= 596 | Includes= 597 | Libs= 598 | ResourceIncludes= 599 | MakeIncludes= 600 | Compiler= 601 | CppCompiler= 602 | Linker= 603 | PreprocDefines=_MSC_VER=1234_@@_ 604 | CompilerSettings=0000000000000000000000 605 | Icon= 606 | ExeOutput=Output\MingW 607 | ObjectOutput=Objects\MingW 608 | OverrideOutput=0 609 | OverrideOutputName=cximage.a 610 | HostApplication= 611 | CommandLine= 612 | UseCustomMakefile=0 613 | CustomMakefile= 614 | IncludeVersionInfo=0 615 | SupportXPThemes=0 616 | CompilerSet=0 617 | CompilerType=0 618 | 619 | [Profile2] 620 | ProfileName=MS VC++ 2005 621 | Type=2 622 | ObjFiles= 623 | Includes= 624 | Libs= 625 | ResourceIncludes= 626 | MakeIncludes= 627 | Compiler= 628 | CppCompiler= 629 | Linker= 630 | PreprocDefines= 631 | CompilerSettings=000000000000010000000000000000000000 632 | Icon= 633 | ExeOutput=Output\MSVC++2005 634 | ObjectOutput=Objects\MSVC++2005 635 | OverrideOutput=0 636 | OverrideOutputName= 637 | HostApplication= 638 | CommandLine= 639 | UseCustomMakefile=0 640 | CustomMakefile= 641 | IncludeVersionInfo=0 642 | SupportXPThemes=0 643 | CompilerSet=1 644 | CompilerType=1 645 | 646 | [Unit57] 647 | FileName=stdint.h 648 | CompileCpp=1 649 | Folder=headres 650 | Compile=1 651 | Link=1 652 | Priority=1000 653 | OverrideBuildCmd=0 654 | BuildCmd= 655 | 656 | -------------------------------------------------------------------------------- /cximage.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="CxImage" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=CxImage - Win32 Unicode Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "cximage.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "cximage.mak" CFG="CxImage - Win32 Unicode Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "CxImage - Win32 Debug" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "CxImage - Win32 Release" (based on "Win32 (x86) Static Library") 22 | !MESSAGE "CxImage - Win32 Unicode Debug" (based on "Win32 (x86) Static Library") 23 | !MESSAGE "CxImage - Win32 Unicode Release" (based on "Win32 (x86) Static Library") 24 | !MESSAGE 25 | 26 | # Begin Project 27 | # PROP AllowPerConfigDependencies 0 28 | # PROP Scc_ProjName "" 29 | # PROP Scc_LocalPath "" 30 | CPP=cl.exe 31 | RSC=rc.exe 32 | 33 | !IF "$(CFG)" == "CxImage - Win32 Debug" 34 | 35 | # PROP BASE Use_MFC 0 36 | # PROP BASE Use_Debug_Libraries 1 37 | # PROP BASE Output_Dir "Debug" 38 | # PROP BASE Intermediate_Dir "Debug" 39 | # PROP BASE Target_Dir "" 40 | # PROP Use_MFC 2 41 | # PROP Use_Debug_Libraries 1 42 | # PROP Output_Dir "Debug" 43 | # PROP Intermediate_Dir "Debug" 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 46 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "WIN32" /D "_DEBUG" /D "_LIB" /D "JAS_WIN_MSVC_BUILD" /D "_CRT_SECURE_NO_DEPRECATE" /FD /GZ /c 47 | # SUBTRACT CPP /Fr /YX 48 | # ADD BASE RSC /l 0x410 /d "_DEBUG" 49 | # ADD RSC /l 0x809 /d "_DEBUG" 50 | BSC32=bscmake.exe 51 | # ADD BASE BSC32 /nologo 52 | # ADD BSC32 /nologo 53 | LIB32=link.exe -lib 54 | # ADD BASE LIB32 /nologo 55 | # ADD LIB32 /nologo 56 | 57 | !ELSEIF "$(CFG)" == "CxImage - Win32 Release" 58 | 59 | # PROP BASE Use_MFC 0 60 | # PROP BASE Use_Debug_Libraries 0 61 | # PROP BASE Output_Dir "Release" 62 | # PROP BASE Intermediate_Dir "Release" 63 | # PROP BASE Target_Dir "" 64 | # PROP Use_MFC 2 65 | # PROP Use_Debug_Libraries 0 66 | # PROP Output_Dir "Release" 67 | # PROP Intermediate_Dir "Release" 68 | # PROP Target_Dir "" 69 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 70 | # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "WIN32" /D "NDEBUG" /D "_LIB" /D "JAS_WIN_MSVC_BUILD" /D "_CRT_SECURE_NO_DEPRECATE" /FD /c 71 | # SUBTRACT CPP /YX 72 | # ADD BASE RSC /l 0x410 /d "NDEBUG" 73 | # ADD RSC /l 0x809 /d "NDEBUG" 74 | BSC32=bscmake.exe 75 | # ADD BASE BSC32 /nologo 76 | # ADD BSC32 /nologo 77 | LIB32=link.exe -lib 78 | # ADD BASE LIB32 /nologo 79 | # ADD LIB32 /nologo 80 | 81 | !ELSEIF "$(CFG)" == "CxImage - Win32 Unicode Debug" 82 | 83 | # PROP BASE Use_MFC 2 84 | # PROP BASE Use_Debug_Libraries 1 85 | # PROP BASE Output_Dir "CxImage___Win32_Unicode_Debug" 86 | # PROP BASE Intermediate_Dir "CxImage___Win32_Unicode_Debug" 87 | # PROP BASE Target_Dir "" 88 | # PROP Use_MFC 2 89 | # PROP Use_Debug_Libraries 1 90 | # PROP Output_Dir "Unicode_Debug" 91 | # PROP Intermediate_Dir "Unicode_Debug" 92 | # PROP Target_Dir "" 93 | # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_AFXDLL" /D "JAS_WIN_MSVC_BUILD" /FD /GZ /c 94 | # SUBTRACT BASE CPP /Fr /YX 95 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "_LIB" /D "JAS_WIN_MSVC_BUILD" /D "WIN32" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NON_CONFORMING_SWPRINTFS" /FD /GZ /c 96 | # SUBTRACT CPP /Fr /YX 97 | # ADD BASE RSC /l 0x410 /d "_DEBUG" /d "_AFXDLL" 98 | # ADD RSC /l 0x809 /d "_DEBUG" 99 | BSC32=bscmake.exe 100 | # ADD BASE BSC32 /nologo 101 | # ADD BSC32 /nologo 102 | LIB32=link.exe -lib 103 | # ADD BASE LIB32 /nologo 104 | # ADD LIB32 /nologo 105 | 106 | !ELSEIF "$(CFG)" == "CxImage - Win32 Unicode Release" 107 | 108 | # PROP BASE Use_MFC 2 109 | # PROP BASE Use_Debug_Libraries 0 110 | # PROP BASE Output_Dir "CxImage___Win32_Unicode_Release" 111 | # PROP BASE Intermediate_Dir "CxImage___Win32_Unicode_Release" 112 | # PROP BASE Target_Dir "" 113 | # PROP Use_MFC 2 114 | # PROP Use_Debug_Libraries 0 115 | # PROP Output_Dir "Unicode_Release" 116 | # PROP Intermediate_Dir "Unicode_Release" 117 | # PROP Target_Dir "" 118 | # ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_AFXDLL" /D "JAS_WIN_MSVC_BUILD" /FD /c 119 | # SUBTRACT BASE CPP /YX 120 | # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\jpeg" /I "..\png" /I "..\zlib" /I "..\mng" /I "..\tiff" /I "..\j2k" /I "..\jasper\include" /D "_LIB" /D "JAS_WIN_MSVC_BUILD" /D "WIN32" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NON_CONFORMING_SWPRINTFS" /FD /c 121 | # SUBTRACT CPP /YX 122 | # ADD BASE RSC /l 0x410 /d "NDEBUG" /d "_AFXDLL" 123 | # ADD RSC /l 0x809 /d "NDEBUG" 124 | BSC32=bscmake.exe 125 | # ADD BASE BSC32 /nologo 126 | # ADD BSC32 /nologo 127 | LIB32=link.exe -lib 128 | # ADD BASE LIB32 /nologo 129 | # ADD LIB32 /nologo 130 | 131 | !ENDIF 132 | 133 | # Begin Target 134 | 135 | # Name "CxImage - Win32 Debug" 136 | # Name "CxImage - Win32 Release" 137 | # Name "CxImage - Win32 Unicode Debug" 138 | # Name "CxImage - Win32 Unicode Release" 139 | # Begin Group "Source Files" 140 | 141 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 142 | # Begin Source File 143 | 144 | SOURCE=.\tif_xfile.cpp 145 | # End Source File 146 | # Begin Source File 147 | 148 | SOURCE=.\ximabmp.cpp 149 | # End Source File 150 | # Begin Source File 151 | 152 | SOURCE=.\ximadsp.cpp 153 | # End Source File 154 | # Begin Source File 155 | 156 | SOURCE=.\ximaenc.cpp 157 | # End Source File 158 | # Begin Source File 159 | 160 | SOURCE=.\ximaexif.cpp 161 | # End Source File 162 | # Begin Source File 163 | 164 | SOURCE=.\xImage.cpp 165 | # End Source File 166 | # Begin Source File 167 | 168 | SOURCE=.\ximagif.cpp 169 | # End Source File 170 | # Begin Source File 171 | 172 | SOURCE=.\ximahist.cpp 173 | # End Source File 174 | # Begin Source File 175 | 176 | SOURCE=.\ximaico.cpp 177 | # End Source File 178 | # Begin Source File 179 | 180 | SOURCE=.\ximainfo.cpp 181 | # End Source File 182 | # Begin Source File 183 | 184 | SOURCE=.\ximaint.cpp 185 | # End Source File 186 | # Begin Source File 187 | 188 | SOURCE=.\ximajas.cpp 189 | # End Source File 190 | # Begin Source File 191 | 192 | SOURCE=.\ximajbg.cpp 193 | # End Source File 194 | # Begin Source File 195 | 196 | SOURCE=.\ximajpg.cpp 197 | # End Source File 198 | # Begin Source File 199 | 200 | SOURCE=.\ximalpha.cpp 201 | # End Source File 202 | # Begin Source File 203 | 204 | SOURCE=.\ximalyr.cpp 205 | # End Source File 206 | # Begin Source File 207 | 208 | SOURCE=.\ximamng.cpp 209 | # End Source File 210 | # Begin Source File 211 | 212 | SOURCE=.\ximapal.cpp 213 | # End Source File 214 | # Begin Source File 215 | 216 | SOURCE=.\ximapcx.cpp 217 | # End Source File 218 | # Begin Source File 219 | 220 | SOURCE=.\ximapng.cpp 221 | # End Source File 222 | # Begin Source File 223 | 224 | SOURCE=.\ximapsd.cpp 225 | # End Source File 226 | # Begin Source File 227 | 228 | SOURCE=.\ximaraw.cpp 229 | # End Source File 230 | # Begin Source File 231 | 232 | SOURCE=.\ximasel.cpp 233 | # End Source File 234 | # Begin Source File 235 | 236 | SOURCE=.\ximaska.cpp 237 | # End Source File 238 | # Begin Source File 239 | 240 | SOURCE=.\ximatga.cpp 241 | # End Source File 242 | # Begin Source File 243 | 244 | SOURCE=.\ximath.cpp 245 | # End Source File 246 | # Begin Source File 247 | 248 | SOURCE=.\ximatif.cpp 249 | # End Source File 250 | # Begin Source File 251 | 252 | SOURCE=.\ximatran.cpp 253 | # End Source File 254 | # Begin Source File 255 | 256 | SOURCE=.\ximawbmp.cpp 257 | # End Source File 258 | # Begin Source File 259 | 260 | SOURCE=.\ximawmf.cpp 261 | # End Source File 262 | # Begin Source File 263 | 264 | SOURCE=.\ximawnd.cpp 265 | # End Source File 266 | # Begin Source File 267 | 268 | SOURCE=.\xmemfile.cpp 269 | # End Source File 270 | # End Group 271 | # Begin Group "Header Files" 272 | 273 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 274 | # Begin Source File 275 | 276 | SOURCE=.\stdint.h 277 | # End Source File 278 | # Begin Source File 279 | 280 | SOURCE=.\xfile.h 281 | # End Source File 282 | # Begin Source File 283 | 284 | SOURCE=.\ximabmp.h 285 | # End Source File 286 | # Begin Source File 287 | 288 | SOURCE=.\ximacfg.h 289 | # End Source File 290 | # Begin Source File 291 | 292 | SOURCE=.\ximadef.h 293 | # End Source File 294 | # Begin Source File 295 | 296 | SOURCE=.\ximage.h 297 | # End Source File 298 | # Begin Source File 299 | 300 | SOURCE=.\ximagif.h 301 | # End Source File 302 | # Begin Source File 303 | 304 | SOURCE=.\ximaico.h 305 | # End Source File 306 | # Begin Source File 307 | 308 | SOURCE=.\ximaiter.h 309 | # End Source File 310 | # Begin Source File 311 | 312 | SOURCE=.\ximajas.h 313 | # End Source File 314 | # Begin Source File 315 | 316 | SOURCE=.\ximajbg.h 317 | # End Source File 318 | # Begin Source File 319 | 320 | SOURCE=.\ximajpg.h 321 | # End Source File 322 | # Begin Source File 323 | 324 | SOURCE=.\ximamng.h 325 | # End Source File 326 | # Begin Source File 327 | 328 | SOURCE=.\ximapcx.h 329 | # End Source File 330 | # Begin Source File 331 | 332 | SOURCE=.\ximapng.h 333 | # End Source File 334 | # Begin Source File 335 | 336 | SOURCE=.\ximapsd.h 337 | # End Source File 338 | # Begin Source File 339 | 340 | SOURCE=.\ximaraw.h 341 | # End Source File 342 | # Begin Source File 343 | 344 | SOURCE=.\ximaska.h 345 | # End Source File 346 | # Begin Source File 347 | 348 | SOURCE=.\ximatga.h 349 | # End Source File 350 | # Begin Source File 351 | 352 | SOURCE=.\ximath.h 353 | # End Source File 354 | # Begin Source File 355 | 356 | SOURCE=.\ximatif.h 357 | # End Source File 358 | # Begin Source File 359 | 360 | SOURCE=.\ximawbmp.h 361 | # End Source File 362 | # Begin Source File 363 | 364 | SOURCE=.\ximawmf.h 365 | # End Source File 366 | # Begin Source File 367 | 368 | SOURCE=.\xiofile.h 369 | # End Source File 370 | # Begin Source File 371 | 372 | SOURCE=.\xmemfile.h 373 | # End Source File 374 | # End Group 375 | # End Target 376 | # End Project 377 | -------------------------------------------------------------------------------- /cximage.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "CxImage"=.\CxImage.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /cximage_wince.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cximage", "cximage_wince.vcproj", "{6885D5CD-7353-45A3-BC16-0F94F68B6F76}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Pocket PC 2003 (ARMV4) = Debug|Pocket PC 2003 (ARMV4) 9 | Debug|Smartphone 2003 (ARMV4) = Debug|Smartphone 2003 (ARMV4) 10 | Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 11 | Release|Pocket PC 2003 (ARMV4) = Release|Pocket PC 2003 (ARMV4) 12 | Release|Smartphone 2003 (ARMV4) = Release|Smartphone 2003 (ARMV4) 13 | Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4) 17 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Debug|Pocket PC 2003 (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4) 18 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Debug|Pocket PC 2003 (ARMV4).Deploy.0 = Debug|Pocket PC 2003 (ARMV4) 19 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Debug|Smartphone 2003 (ARMV4).ActiveCfg = Debug|Smartphone 2003 (ARMV4) 20 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Debug|Smartphone 2003 (ARMV4).Build.0 = Debug|Smartphone 2003 (ARMV4) 21 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Debug|Smartphone 2003 (ARMV4).Deploy.0 = Debug|Smartphone 2003 (ARMV4) 22 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 23 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 24 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 25 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4) 26 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4) 27 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4) 28 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Release|Smartphone 2003 (ARMV4).ActiveCfg = Release|Smartphone 2003 (ARMV4) 29 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Release|Smartphone 2003 (ARMV4).Build.0 = Release|Smartphone 2003 (ARMV4) 30 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Release|Smartphone 2003 (ARMV4).Deploy.0 = Release|Smartphone 2003 (ARMV4) 31 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 32 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 33 | {6885D5CD-7353-45A3-BC16-0F94F68B6F76}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | This copy of the CxImage notices is provided for your convenience. In case of 2 | any discrepancy between this copy and the notices in the file ximage.h that is 3 | included in the CxImage distribution, the latter shall prevail. 4 | 5 | If you modify CxImage you may insert additional notices immediately following 6 | this sentence. 7 | 8 | -------------------------------------------------------------------------------- 9 | 10 | COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: 11 | 12 | CxImage version 7.0.1 07/Jan/2011 13 | 14 | CxImage : Copyright (C) 2001 - 2011, Davide Pizzolato 15 | 16 | Original CImage and CImageIterator implementation are: 17 | Copyright (C) 1995, Alejandro Aguilar Sierra (asierra(at)servidor(dot)unam(dot)mx) 18 | 19 | Covered code is provided under this license on an "as is" basis, without warranty 20 | of any kind, either expressed or implied, including, without limitation, warranties 21 | that the covered code is free of defects, merchantable, fit for a particular purpose 22 | or non-infringing. The entire risk as to the quality and performance of the covered 23 | code is with you. Should any covered code prove defective in any respect, you (not 24 | the initial developer or any other contributor) assume the cost of any necessary 25 | servicing, repair or correction. This disclaimer of warranty constitutes an essential 26 | part of this license. No use of any covered code is authorized hereunder except under 27 | this disclaimer. 28 | 29 | Permission is hereby granted to use, copy, modify, and distribute this 30 | source code, or portions hereof, for any purpose, including commercial applications, 31 | freely and without fee, subject to the following restrictions: 32 | 33 | 1. The origin of this software must not be misrepresented; you must not 34 | claim that you wrote the original software. If you use this software 35 | in a product, an acknowledgment in the product documentation would be 36 | appreciated but is not required. 37 | 38 | 2. Altered source versions must be plainly marked as such, and must not be 39 | misrepresented as being the original software. 40 | 41 | 3. This notice may not be removed or altered from any source distribution. 42 | 43 | -------------------------------------------------------------------------------- 44 | 45 | Other information: about CxImage, and the latest version, can be found at the 46 | CxImage home page: http://www.xdp.it 47 | 48 | -------------------------------------------------------------------------------- 49 | -------------------------------------------------------------------------------- /stdint.h: -------------------------------------------------------------------------------- 1 | // ISO C9x compliant stdint.h for Microsoft Visual Studio 2 | // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 3 | // 4 | // Copyright (c) 2006-2008 Alexander Chemeris 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // 3. The name of the author may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #ifndef _MSC_VER // [ 33 | #error "Use this header only with Microsoft Visual C++ compilers!" 34 | #endif // _MSC_VER ] 35 | 36 | #ifndef _MSC_STDINT_H_ // [ 37 | #define _MSC_STDINT_H_ 38 | 39 | #if _MSC_VER > 1000 40 | #pragma once 41 | #endif 42 | 43 | #include 44 | 45 | // For Visual Studio 6 in C++ mode and for many Visual Studio versions when 46 | // compiling for ARM we should wrap include with 'extern "C++" {}' 47 | // or compiler give many errors like this: 48 | // error C2733: second C linkage of overloaded function 'wmemchr' not allowed 49 | /* 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | # include 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | */ 58 | 59 | // Define _W64 macros to mark types changing their size, like intptr_t. 60 | #ifndef _W64 61 | # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 62 | # define _W64 __w64 63 | # else 64 | # define _W64 65 | # endif 66 | #endif 67 | 68 | 69 | // 7.18.1 Integer types 70 | 71 | // 7.18.1.1 Exact-width integer types 72 | 73 | // Visual Studio 6 and Embedded Visual C++ 4 doesn't 74 | // realize that, e.g. char has the same size as __int8 75 | // so we give up on __intX for them. 76 | #if (_MSC_VER < 1300) 77 | typedef signed char int8_t; 78 | typedef signed short int16_t; 79 | typedef signed int int32_t; 80 | typedef unsigned char uint8_t; 81 | typedef unsigned short uint16_t; 82 | typedef unsigned int uint32_t; 83 | #else 84 | typedef signed __int8 int8_t; 85 | typedef signed __int16 int16_t; 86 | typedef signed __int32 int32_t; 87 | typedef unsigned __int8 uint8_t; 88 | typedef unsigned __int16 uint16_t; 89 | typedef unsigned __int32 uint32_t; 90 | #endif 91 | typedef signed __int64 int64_t; 92 | typedef unsigned __int64 uint64_t; 93 | 94 | 95 | // 7.18.1.2 Minimum-width integer types 96 | typedef int8_t int_least8_t; 97 | typedef int16_t int_least16_t; 98 | typedef int32_t int_least32_t; 99 | typedef int64_t int_least64_t; 100 | typedef uint8_t uint_least8_t; 101 | typedef uint16_t uint_least16_t; 102 | typedef uint32_t uint_least32_t; 103 | typedef uint64_t uint_least64_t; 104 | 105 | // 7.18.1.3 Fastest minimum-width integer types 106 | typedef int8_t int_fast8_t; 107 | typedef int16_t int_fast16_t; 108 | typedef int32_t int_fast32_t; 109 | typedef int64_t int_fast64_t; 110 | typedef uint8_t uint_fast8_t; 111 | typedef uint16_t uint_fast16_t; 112 | typedef uint32_t uint_fast32_t; 113 | typedef uint64_t uint_fast64_t; 114 | 115 | // 7.18.1.4 Integer types capable of holding object pointers 116 | #ifdef _WIN64 // [ 117 | typedef signed __int64 intptr_t; 118 | typedef unsigned __int64 uintptr_t; 119 | #else // _WIN64 ][ 120 | typedef _W64 signed int intptr_t; 121 | typedef _W64 unsigned int uintptr_t; 122 | #endif // _WIN64 ] 123 | 124 | // 7.18.1.5 Greatest-width integer types 125 | typedef int64_t intmax_t; 126 | typedef uint64_t uintmax_t; 127 | 128 | 129 | // 7.18.2 Limits of specified-width integer types 130 | 131 | #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 132 | 133 | // 7.18.2.1 Limits of exact-width integer types 134 | #define INT8_MIN ((int8_t)_I8_MIN) 135 | #define INT8_MAX _I8_MAX 136 | #define INT16_MIN ((int16_t)_I16_MIN) 137 | #define INT16_MAX _I16_MAX 138 | #define INT32_MIN ((int32_t)_I32_MIN) 139 | #define INT32_MAX _I32_MAX 140 | #define INT64_MIN ((int64_t)_I64_MIN) 141 | #define INT64_MAX _I64_MAX 142 | #define UINT8_MAX _UI8_MAX 143 | #define UINT16_MAX _UI16_MAX 144 | #define UINT32_MAX _UI32_MAX 145 | #define UINT64_MAX _UI64_MAX 146 | 147 | // 7.18.2.2 Limits of minimum-width integer types 148 | #define INT_LEAST8_MIN INT8_MIN 149 | #define INT_LEAST8_MAX INT8_MAX 150 | #define INT_LEAST16_MIN INT16_MIN 151 | #define INT_LEAST16_MAX INT16_MAX 152 | #define INT_LEAST32_MIN INT32_MIN 153 | #define INT_LEAST32_MAX INT32_MAX 154 | #define INT_LEAST64_MIN INT64_MIN 155 | #define INT_LEAST64_MAX INT64_MAX 156 | #define UINT_LEAST8_MAX UINT8_MAX 157 | #define UINT_LEAST16_MAX UINT16_MAX 158 | #define UINT_LEAST32_MAX UINT32_MAX 159 | #define UINT_LEAST64_MAX UINT64_MAX 160 | 161 | // 7.18.2.3 Limits of fastest minimum-width integer types 162 | #define INT_FAST8_MIN INT8_MIN 163 | #define INT_FAST8_MAX INT8_MAX 164 | #define INT_FAST16_MIN INT16_MIN 165 | #define INT_FAST16_MAX INT16_MAX 166 | #define INT_FAST32_MIN INT32_MIN 167 | #define INT_FAST32_MAX INT32_MAX 168 | #define INT_FAST64_MIN INT64_MIN 169 | #define INT_FAST64_MAX INT64_MAX 170 | #define UINT_FAST8_MAX UINT8_MAX 171 | #define UINT_FAST16_MAX UINT16_MAX 172 | #define UINT_FAST32_MAX UINT32_MAX 173 | #define UINT_FAST64_MAX UINT64_MAX 174 | 175 | // 7.18.2.4 Limits of integer types capable of holding object pointers 176 | #ifdef _WIN64 // [ 177 | # define INTPTR_MIN INT64_MIN 178 | # define INTPTR_MAX INT64_MAX 179 | # define UINTPTR_MAX UINT64_MAX 180 | #else // _WIN64 ][ 181 | # define INTPTR_MIN INT32_MIN 182 | # define INTPTR_MAX INT32_MAX 183 | # define UINTPTR_MAX UINT32_MAX 184 | #endif // _WIN64 ] 185 | 186 | // 7.18.2.5 Limits of greatest-width integer types 187 | #define INTMAX_MIN INT64_MIN 188 | #define INTMAX_MAX INT64_MAX 189 | #define UINTMAX_MAX UINT64_MAX 190 | 191 | // 7.18.3 Limits of other integer types 192 | 193 | #ifdef _WIN64 // [ 194 | # define PTRDIFF_MIN _I64_MIN 195 | # define PTRDIFF_MAX _I64_MAX 196 | #else // _WIN64 ][ 197 | # define PTRDIFF_MIN _I32_MIN 198 | # define PTRDIFF_MAX _I32_MAX 199 | #endif // _WIN64 ] 200 | 201 | #define SIG_ATOMIC_MIN INT_MIN 202 | #define SIG_ATOMIC_MAX INT_MAX 203 | 204 | #ifndef SIZE_MAX // [ 205 | # ifdef _WIN64 // [ 206 | # define SIZE_MAX _UI64_MAX 207 | # else // _WIN64 ][ 208 | # define SIZE_MAX _UI32_MAX 209 | # endif // _WIN64 ] 210 | #endif // SIZE_MAX ] 211 | 212 | // WCHAR_MIN and WCHAR_MAX are also defined in 213 | #ifndef WCHAR_MIN // [ 214 | # define WCHAR_MIN 0 215 | #endif // WCHAR_MIN ] 216 | #ifndef WCHAR_MAX // [ 217 | # define WCHAR_MAX _UI16_MAX 218 | #endif // WCHAR_MAX ] 219 | 220 | #define WINT_MIN 0 221 | #define WINT_MAX _UI16_MAX 222 | 223 | #endif // __STDC_LIMIT_MACROS ] 224 | 225 | 226 | // 7.18.4 Limits of other integer types 227 | 228 | #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 229 | 230 | // 7.18.4.1 Macros for minimum-width integer constants 231 | 232 | #define INT8_C(val) val##i8 233 | #define INT16_C(val) val##i16 234 | #define INT32_C(val) val##i32 235 | #define INT64_C(val) val##i64 236 | 237 | #define UINT8_C(val) val##ui8 238 | #define UINT16_C(val) val##ui16 239 | #define UINT32_C(val) val##ui32 240 | #define UINT64_C(val) val##ui64 241 | 242 | // 7.18.4.2 Macros for greatest-width integer constants 243 | #define INTMAX_C INT64_C 244 | #define UINTMAX_C UINT64_C 245 | 246 | #endif // __STDC_CONSTANT_MACROS ] 247 | 248 | 249 | #endif // _MSC_STDINT_H_ ] 250 | -------------------------------------------------------------------------------- /tif_xfile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TIFF file IO, using CxFile. 3 | */ 4 | 5 | #ifdef WIN32 6 | #include 7 | #endif 8 | #include 9 | 10 | #include "ximage.h" 11 | 12 | #if CXIMAGE_SUPPORT_TIF 13 | 14 | #include "../tiff/tiffiop.h" 15 | #include "../tiff/tiffvers.h" 16 | 17 | #include "xfile.h" 18 | 19 | static tsize_t 20 | _tiffReadProcEx(thandle_t fd, tdata_t buf, tsize_t size) 21 | { 22 | return (tsize_t)((CxFile*)fd)->Read(buf, 1, size); 23 | } 24 | 25 | static tsize_t 26 | _tiffWriteProcEx(thandle_t fd, tdata_t buf, tsize_t size) 27 | { 28 | return (tsize_t)((CxFile*)fd)->Write(buf, 1, size); 29 | } 30 | 31 | static toff_t 32 | _tiffSeekProcEx(thandle_t fd, toff_t off, int whence) 33 | { 34 | if ( off == 0xFFFFFFFF ) 35 | return 0xFFFFFFFF; 36 | if (!((CxFile*)fd)->Seek(off, whence)) 37 | return 0xFFFFFFFF; 38 | if (whence == SEEK_SET) 39 | return off; 40 | 41 | return (toff_t)((CxFile*)fd)->Tell(); 42 | } 43 | 44 | // Return nonzero if error 45 | static int 46 | _tiffCloseProcEx(thandle_t /*fd*/) 47 | { 48 | // return !((CxFile*)fd)->Close(); // "//" needed for memory files 49 | return 0; 50 | } 51 | 52 | #include 53 | 54 | static toff_t 55 | _tiffSizeProcEx(thandle_t fd) 56 | { 57 | return ((CxFile*)fd)->Size(); 58 | } 59 | 60 | static int 61 | _tiffMapProcEx(thandle_t /*fd*/, tdata_t* /*pbase*/, toff_t* /*psize*/) 62 | { 63 | return (0); 64 | } 65 | 66 | static void 67 | _tiffUnmapProcEx(thandle_t /*fd*/, tdata_t /*base*/, toff_t /*size*/) 68 | { 69 | } 70 | 71 | // Open a TIFF file descriptor for read/writing. 72 | /* 73 | TIFF* 74 | TIFFOpen(const char* name, const char* mode) 75 | { 76 | static const char module[] = "TIFFOpen"; 77 | FILE* stream = fopen(name, mode); 78 | if (stream == NULL) 79 | { 80 | TIFFError(module, "%s: Cannot open", name); 81 | return NULL; 82 | } 83 | return (TIFFFdOpen((int)stream, name, mode)); 84 | } 85 | */ 86 | 87 | TIFF* 88 | _TIFFFdOpen(void* fd, const char* name, const char* mode) 89 | { 90 | TIFF* tif; 91 | 92 | tif = TIFFClientOpen(name, mode, 93 | (thandle_t) fd, 94 | _tiffReadProcEx, _tiffWriteProcEx, _tiffSeekProcEx, _tiffCloseProcEx, 95 | _tiffSizeProcEx, _tiffMapProcEx, _tiffUnmapProcEx); 96 | if (tif) 97 | { 98 | tif->tif_fd = (int)fd; 99 | } 100 | return (tif); 101 | } 102 | 103 | extern "C" TIFF* _TIFFOpenEx(CxFile* stream, const char* mode) 104 | { 105 | return (_TIFFFdOpen(stream, "TIFF IMAGE", mode)); 106 | } 107 | 108 | #ifdef __GNUC__ 109 | extern char* malloc(); 110 | extern char* realloc(); 111 | #else 112 | #include 113 | #endif 114 | 115 | tdata_t 116 | _TIFFmalloc(tsize_t s) 117 | { 118 | return (malloc((size_t) s)); 119 | } 120 | 121 | void 122 | _TIFFfree(tdata_t p) 123 | { 124 | free(p); 125 | } 126 | 127 | tdata_t 128 | _TIFFrealloc(tdata_t p, tsize_t s) 129 | { 130 | return (realloc(p, (size_t) s)); 131 | } 132 | 133 | void 134 | _TIFFmemset(tdata_t p, int v, tsize_t c) 135 | { 136 | memset(p, v, (size_t) c); 137 | } 138 | 139 | void 140 | _TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) 141 | { 142 | memcpy(d, s, (size_t) c); 143 | } 144 | 145 | int 146 | _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) 147 | { 148 | return (memcmp(p1, p2, (size_t) c)); 149 | } 150 | 151 | #ifndef UNICODE 152 | #define DbgPrint wvsprintf 153 | #define DbgPrint2 wsprintf 154 | #define DbgMsgBox MessageBox 155 | #else 156 | #define DbgPrint wvsprintfA 157 | #define DbgPrint2 wsprintfA 158 | #define DbgMsgBox MessageBoxA 159 | #endif 160 | 161 | static void 162 | Win32WarningHandler(const char* module, const char* fmt, va_list ap) 163 | { 164 | #ifdef _DEBUG 165 | #if (!defined(_CONSOLE) && !defined(_WIN32_WCE) && defined(WIN32)) 166 | LPSTR szTitle; 167 | LPSTR szTmp; 168 | LPCSTR szTitleText = "%s Warning"; 169 | LPCSTR szDefaultModule = "TIFFLIB"; 170 | szTmp = (module == NULL) ? (LPSTR)szDefaultModule : (LPSTR)module; 171 | if ((szTitle = (LPSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmp) + 172 | strlen(szTitleText) + strlen(fmt) + 128))) == NULL) 173 | return; 174 | DbgPrint2(szTitle, szTitleText, szTmp); 175 | szTmp = szTitle + (strlen(szTitle)+2); 176 | DbgPrint(szTmp, fmt, ap); 177 | DbgMsgBox(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION); 178 | LocalFree(szTitle); 179 | return; 180 | #else 181 | if (module != NULL) 182 | fprintf(stderr, "%s: ", module); 183 | fprintf(stderr, "Warning, "); 184 | vfprintf(stderr, fmt, ap); 185 | fprintf(stderr, ".\n"); 186 | #endif 187 | #endif 188 | } 189 | TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler; 190 | 191 | static void 192 | Win32ErrorHandler(const char* module, const char* fmt, va_list ap) 193 | { 194 | #ifdef _DEBUG 195 | #if (!defined(_CONSOLE) && !defined(_WIN32_WCE) && defined(WIN32)) 196 | LPSTR szTitle; 197 | LPSTR szTmp; 198 | LPCSTR szTitleText = "%s Error"; 199 | LPCSTR szDefaultModule = "TIFFLIB"; 200 | szTmp = (module == NULL) ? (LPSTR)szDefaultModule : (LPSTR)module; 201 | if ((szTitle = (LPSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmp) + 202 | strlen(szTitleText) + strlen(fmt) + 128))) == NULL) 203 | return; 204 | DbgPrint2(szTitle, szTitleText, szTmp); 205 | szTmp = szTitle + (strlen(szTitle)+2); 206 | DbgPrint(szTmp, fmt, ap); 207 | DbgMsgBox(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION); 208 | LocalFree(szTitle); 209 | return; 210 | #else 211 | if (module != NULL) 212 | fprintf(stderr, "%s: ", module); 213 | vfprintf(stderr, fmt, ap); 214 | fprintf(stderr, ".\n"); 215 | #endif 216 | #endif 217 | } 218 | TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler; 219 | 220 | #endif 221 | 222 | -------------------------------------------------------------------------------- /xfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: xfile.h 3 | * Purpose: General Purpose File Class 4 | */ 5 | /* 6 | -------------------------------------------------------------------------------- 7 | 8 | COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: 9 | 10 | CxFile (c) 11/May/2002 Davide Pizzolato - www.xdp.it 11 | CxFile version 2.00 23/Aug/2002 12 | CxFile version 2.10 16/Dec/2007 13 | 14 | Special thanks to Chris Shearer Cooper for new features, enhancements and bugfixes 15 | 16 | Covered code is provided under this license on an "as is" basis, without warranty 17 | of any kind, either expressed or implied, including, without limitation, warranties 18 | that the covered code is free of defects, merchantable, fit for a particular purpose 19 | or non-infringing. The entire risk as to the quality and performance of the covered 20 | code is with you. Should any covered code prove defective in any respect, you (not 21 | the initial developer or any other contributor) assume the cost of any necessary 22 | servicing, repair or correction. This disclaimer of warranty constitutes an essential 23 | part of this license. No use of any covered code is authorized hereunder except under 24 | this disclaimer. 25 | 26 | Permission is hereby granted to use, copy, modify, and distribute this 27 | source code, or portions hereof, for any purpose, including commercial applications, 28 | freely and without fee, subject to the following restrictions: 29 | 30 | 1. The origin of this software must not be misrepresented; you must not 31 | claim that you wrote the original software. If you use this software 32 | in a product, an acknowledgment in the product documentation would be 33 | appreciated but is not required. 34 | 35 | 2. Altered source versions must be plainly marked as such, and must not be 36 | misrepresented as being the original software. 37 | 38 | 3. This notice may not be removed or altered from any source distribution. 39 | -------------------------------------------------------------------------------- 40 | */ 41 | #if !defined(__xfile_h) 42 | #define __xfile_h 43 | 44 | #if defined (WIN32) || defined (_WIN32_WCE) 45 | #include 46 | #endif 47 | 48 | #include 49 | #include 50 | 51 | #include "ximadef.h" 52 | 53 | class DLL_EXP CxFile 54 | { 55 | public: 56 | CxFile(void) { }; 57 | virtual ~CxFile() { }; 58 | 59 | virtual bool Close() = 0; 60 | virtual size_t Read(void *buffer, size_t size, size_t count) = 0; 61 | virtual size_t Write(const void *buffer, size_t size, size_t count) = 0; 62 | virtual bool Seek(int32_t offset, int32_t origin) = 0; 63 | virtual int32_t Tell() = 0; 64 | virtual int32_t Size() = 0; 65 | virtual bool Flush() = 0; 66 | virtual bool Eof() = 0; 67 | virtual int32_t Error() = 0; 68 | virtual bool PutC(uint8_t c) 69 | { 70 | // Default implementation 71 | size_t nWrote = Write(&c, 1, 1); 72 | return (bool)(nWrote == 1); 73 | } 74 | virtual int32_t GetC() = 0; 75 | virtual char * GetS(char *string, int32_t n) = 0; 76 | virtual int32_t Scanf(const char *format, void* output) = 0; 77 | }; 78 | 79 | #endif //__xfile_h 80 | -------------------------------------------------------------------------------- /ximabmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximabmp.h 3 | * Purpose: BMP Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageBMP (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * 9 | * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes 10 | * 11 | * original CImageBMP and CImageIterator implementation are: 12 | * Copyright: (c) 1995, Alejandro Aguilar Sierra 13 | * 14 | * ========================================================== 15 | */ 16 | 17 | #if !defined(__ximaBMP_h) 18 | #define __ximaBMP_h 19 | 20 | #include "ximage.h" 21 | 22 | const int32_t RLE_COMMAND = 0; 23 | const int32_t RLE_ENDOFLINE = 0; 24 | const int32_t RLE_ENDOFBITMAP = 1; 25 | const int32_t RLE_DELTA = 2; 26 | 27 | #if !defined(BI_RLE8) 28 | #define BI_RLE8 1L 29 | #endif 30 | #if !defined(BI_RLE4) 31 | #define BI_RLE4 2L 32 | #endif 33 | 34 | #if CXIMAGE_SUPPORT_BMP 35 | 36 | class CxImageBMP: public CxImage 37 | { 38 | public: 39 | CxImageBMP(): CxImage(CXIMAGE_FORMAT_BMP) {}; 40 | 41 | bool Decode(CxFile * hFile); 42 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 43 | 44 | #if CXIMAGE_SUPPORT_ENCODE 45 | bool Encode(CxFile * hFile); 46 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 47 | #endif // CXIMAGE_SUPPORT_ENCODE 48 | 49 | protected: 50 | bool DibReadBitmapInfo(CxFile* fh, BITMAPINFOHEADER *pdib); 51 | }; 52 | 53 | #define BFT_ICON 0x4349 /* 'IC' */ 54 | #define BFT_BITMAP 0x4d42 /* 'BM' */ 55 | #define BFT_CURSOR 0x5450 /* 'PT' */ 56 | 57 | #ifndef WIDTHBYTES 58 | #define WIDTHBYTES(i) ((unsigned)((i+31)&(~31))/8) /* ULONG aligned ! */ 59 | #endif 60 | 61 | #endif 62 | 63 | #define DibWidthBytesN(lpbi, n) (uint32_t)WIDTHBYTES((uint32_t)(lpbi)->biWidth * (uint32_t)(n)) 64 | #define DibWidthBytes(lpbi) DibWidthBytesN(lpbi, (lpbi)->biBitCount) 65 | 66 | #define DibSizeImage(lpbi) ((lpbi)->biSizeImage == 0 \ 67 | ? ((uint32_t)(uint32_t)DibWidthBytes(lpbi) * (uint32_t)(uint32_t)(lpbi)->biHeight) \ 68 | : (lpbi)->biSizeImage) 69 | 70 | #define DibNumColors(lpbi) ((lpbi)->biClrUsed == 0 && (lpbi)->biBitCount <= 8 \ 71 | ? (int32_t)(1 << (int32_t)(lpbi)->biBitCount) \ 72 | : (int32_t)(lpbi)->biClrUsed) 73 | 74 | #define FixBitmapInfo(lpbi) if ((lpbi)->biSizeImage == 0) \ 75 | (lpbi)->biSizeImage = DibSizeImage(lpbi); \ 76 | if ((lpbi)->biClrUsed == 0) \ 77 | (lpbi)->biClrUsed = DibNumColors(lpbi); \ 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /ximacfg.h: -------------------------------------------------------------------------------- 1 | #if !defined(__ximaCFG_h) 2 | #define __ximaCFG_h 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // CxImage supported features 6 | #define CXIMAGE_SUPPORT_ALPHA 1 7 | #define CXIMAGE_SUPPORT_SELECTION 1 8 | #define CXIMAGE_SUPPORT_TRANSFORMATION 1 9 | #define CXIMAGE_SUPPORT_DSP 1 10 | #define CXIMAGE_SUPPORT_LAYERS 1 11 | #define CXIMAGE_SUPPORT_INTERPOLATION 1 12 | 13 | #define CXIMAGE_SUPPORT_DECODE 1 14 | #define CXIMAGE_SUPPORT_ENCODE 1 // 15 | #define CXIMAGE_SUPPORT_WINDOWS 1 16 | #define CXIMAGE_SUPPORT_EXIF 0 17 | 18 | ///////////////////////////////////////////////////////////////////////////// 19 | // CxImage supported formats 20 | #define CXIMAGE_SUPPORT_BMP 1 21 | #define CXIMAGE_SUPPORT_GIF 1 22 | #define CXIMAGE_SUPPORT_JPG 0 23 | #define CXIMAGE_SUPPORT_PNG 0 24 | #define CXIMAGE_SUPPORT_ICO 1 25 | #define CXIMAGE_SUPPORT_TIF 0 26 | #define CXIMAGE_SUPPORT_TGA 1 27 | #define CXIMAGE_SUPPORT_PCX 1 28 | #define CXIMAGE_SUPPORT_WBMP 1 29 | #define CXIMAGE_SUPPORT_WMF 1 30 | 31 | #define CXIMAGE_SUPPORT_JP2 0 32 | #define CXIMAGE_SUPPORT_JPC 0 33 | #define CXIMAGE_SUPPORT_PGX 0 34 | #define CXIMAGE_SUPPORT_PNM 0 35 | #define CXIMAGE_SUPPORT_RAS 0 36 | 37 | #define CXIMAGE_SUPPORT_JBG 0 // GPL'd see ../jbig/copying.txt & ../jbig/patents.htm 38 | 39 | #define CXIMAGE_SUPPORT_MNG 0 40 | #define CXIMAGE_SUPPORT_SKA 1 41 | #define CXIMAGE_SUPPORT_RAW 0 42 | #define CXIMAGE_SUPPORT_PSD 1 43 | 44 | ///////////////////////////////////////////////////////////////////////////// 45 | #define CXIMAGE_MAX_MEMORY 268435456 46 | 47 | #define CXIMAGE_DEFAULT_DPI 96 48 | 49 | #define CXIMAGE_ERR_NOFILE "null file handler" 50 | #define CXIMAGE_ERR_NOIMAGE "null image!!!" 51 | 52 | #define CXIMAGE_SUPPORT_EXCEPTION_HANDLING 1 53 | 54 | ///////////////////////////////////////////////////////////////////////////// 55 | //color to grey mapping 56 | //#define RGB2GRAY(r,g,b) (((b)*114 + (g)*587 + (r)*299)/1000) 57 | #define RGB2GRAY(r,g,b) (((b)*117 + (g)*601 + (r)*306) >> 10) 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /ximadef.h: -------------------------------------------------------------------------------- 1 | #if !defined(__ximadefs_h) 2 | #define __ximadefs_h 3 | 4 | #include "ximacfg.h" 5 | 6 | #if /*defined(_AFXDLL)||*/defined(_USRDLL) 7 | #define DLL_EXP __declspec(dllexport) 8 | #elif defined(_MSC_VER)&&(_MSC_VER<1200) 9 | #define DLL_EXP __declspec(dllimport) 10 | #else 11 | #define DLL_EXP 12 | #endif 13 | 14 | 15 | #if CXIMAGE_SUPPORT_EXCEPTION_HANDLING 16 | #define cx_try try 17 | #define cx_throw(message) throw(message) 18 | #define cx_catch catch (const char *message) 19 | #else 20 | #define cx_try bool cx_error=false; 21 | #define cx_throw(message) {cx_error=true; if(strcmp(message,"")) strncpy(info.szLastError,message,255); goto cx_error_catch;} 22 | #define cx_catch cx_error_catch: char message[]=""; if(cx_error) 23 | #endif 24 | 25 | 26 | #if CXIMAGE_SUPPORT_JP2 || CXIMAGE_SUPPORT_JPC || CXIMAGE_SUPPORT_PGX || CXIMAGE_SUPPORT_PNM || CXIMAGE_SUPPORT_RAS 27 | #define CXIMAGE_SUPPORT_JASPER 1 28 | #else 29 | #define CXIMAGE_SUPPORT_JASPER 0 30 | #endif 31 | 32 | #if CXIMAGE_SUPPORT_DSP 33 | #undef CXIMAGE_SUPPORT_TRANSFORMATION 34 | #define CXIMAGE_SUPPORT_TRANSFORMATION 1 35 | #endif 36 | 37 | #if CXIMAGE_SUPPORT_TRANSFORMATION || CXIMAGE_SUPPORT_TIF || CXIMAGE_SUPPORT_TGA || CXIMAGE_SUPPORT_BMP || CXIMAGE_SUPPORT_WINDOWS 38 | #define CXIMAGE_SUPPORT_BASICTRANSFORMATIONS 1 39 | #endif 40 | 41 | #if CXIMAGE_SUPPORT_DSP || CXIMAGE_SUPPORT_TRANSFORMATION 42 | #undef CXIMAGE_SUPPORT_INTERPOLATION 43 | #define CXIMAGE_SUPPORT_INTERPOLATION 1 44 | #endif 45 | 46 | #if (CXIMAGE_SUPPORT_DECODE == 0) 47 | #undef CXIMAGE_SUPPORT_EXIF 48 | #define CXIMAGE_SUPPORT_EXIF 0 49 | #endif 50 | 51 | #if defined (_WIN32_WCE) 52 | #undef CXIMAGE_SUPPORT_WMF 53 | #define CXIMAGE_SUPPORT_WMF 0 54 | #endif 55 | 56 | #if !defined(WIN32) && !defined(_WIN32_WCE) 57 | #undef CXIMAGE_SUPPORT_WINDOWS 58 | #define CXIMAGE_SUPPORT_WINDOWS 0 59 | #endif 60 | 61 | #ifndef min 62 | #define min(a,b) (((a)<(b))?(a):(b)) 63 | #endif 64 | #ifndef max 65 | #define max(a,b) (((a)>(b))?(a):(b)) 66 | #endif 67 | 68 | #ifndef PI 69 | #define PI 3.141592653589793f 70 | #endif 71 | 72 | 73 | #if defined(WIN32) || defined(_WIN32_WCE) 74 | #include 75 | #include 76 | #endif 77 | 78 | #include 79 | #include 80 | 81 | #ifdef __BORLANDC__ 82 | 83 | #ifndef _COMPLEX_DEFINED 84 | 85 | typedef struct tagcomplex { 86 | double x,y; 87 | } _complex; 88 | 89 | #endif 90 | 91 | #define _cabs(c) sqrt(c.x*c.x+c.y*c.y) 92 | 93 | #endif 94 | 95 | #if defined(WIN32) || defined(_WIN32_WCE) 96 | #include "stdint.h" 97 | #endif 98 | 99 | #if !defined(WIN32) && !defined(_WIN32_WCE) 100 | 101 | #include 102 | #include 103 | #include 104 | #include 105 | 106 | typedef uint32_t COLORREF; 107 | typedef void* HANDLE; 108 | typedef void* HRGN; 109 | 110 | #ifndef BOOL 111 | #define BOOL bool 112 | #endif 113 | 114 | #ifndef TRUE 115 | #define TRUE true 116 | #endif 117 | 118 | #ifndef FALSE 119 | #define FALSE false 120 | #endif 121 | 122 | #ifndef TCHAR 123 | #define TCHAR char 124 | #define _T 125 | #endif 126 | 127 | typedef struct tagRECT 128 | { 129 | int32_t left; 130 | int32_t top; 131 | int32_t right; 132 | int32_t bottom; 133 | } RECT; 134 | 135 | typedef struct tagPOINT 136 | { 137 | int32_t x; 138 | int32_t y; 139 | } POINT; 140 | 141 | typedef struct tagRGBQUAD { 142 | uint8_t rgbBlue; 143 | uint8_t rgbGreen; 144 | uint8_t rgbRed; 145 | uint8_t rgbReserved; 146 | } RGBQUAD; 147 | 148 | #pragma pack(1) 149 | 150 | typedef struct tagBITMAPINFOHEADER{ 151 | uint32_t biSize; 152 | int32_t biWidth; 153 | int32_t biHeight; 154 | uint16_t biPlanes; 155 | uint16_t biBitCount; 156 | uint32_t biCompression; 157 | uint32_t biSizeImage; 158 | int32_t biXPelsPerMeter; 159 | int32_t biYPelsPerMeter; 160 | uint32_t biClrUsed; 161 | uint32_t biClrImportant; 162 | } BITMAPINFOHEADER; 163 | 164 | typedef struct tagBITMAPFILEHEADER { 165 | uint16_t bfType; 166 | uint32_t bfSize; 167 | uint16_t bfReserved1; 168 | uint16_t bfReserved2; 169 | uint32_t bfOffBits; 170 | } BITMAPFILEHEADER; 171 | 172 | typedef struct tagBITMAPCOREHEADER { 173 | uint32_t bcSize; 174 | uint16_t bcWidth; 175 | uint16_t bcHeight; 176 | uint16_t bcPlanes; 177 | uint16_t bcBitCount; 178 | } BITMAPCOREHEADER; 179 | 180 | typedef struct tagRGBTRIPLE { 181 | uint8_t rgbtBlue; 182 | uint8_t rgbtGreen; 183 | uint8_t rgbtRed; 184 | } RGBTRIPLE; 185 | 186 | #pragma pack() 187 | 188 | #define BI_RGB 0L 189 | #define BI_RLE8 1L 190 | #define BI_RLE4 2L 191 | #define BI_BITFIELDS 3L 192 | 193 | #define GetRValue(rgb) ((uint8_t)(rgb)) 194 | #define GetGValue(rgb) ((uint8_t)(((uint16_t)(rgb)) >> 8)) 195 | #define GetBValue(rgb) ((uint8_t)((rgb)>>16)) 196 | #define RGB(r,g,b) ((COLORREF)(((uint8_t)(r)|((uint16_t)((uint8_t)(g))<<8))|(((uint32_t)(uint8_t)(b))<<16))) 197 | 198 | #ifndef _COMPLEX_DEFINED 199 | 200 | typedef struct tagcomplex { 201 | double x,y; 202 | } _complex; 203 | 204 | #endif 205 | 206 | #define _cabs(c) sqrt(c.x*c.x+c.y*c.y) 207 | 208 | #endif 209 | 210 | #endif //__ximadefs 211 | -------------------------------------------------------------------------------- /ximadsp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/movableink/cximage/73a4518e7a3a7fbc2f27c91e5873a56769c8dbf7/ximadsp.cpp -------------------------------------------------------------------------------- /ximagif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximagif.h 3 | * Purpose: GIF Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageGIF (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * 9 | * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes 10 | * 11 | * original CImageGIF and CImageIterator implementation are: 12 | * Copyright: (c) 1995, Alejandro Aguilar Sierra 13 | * 14 | * 6/15/97 Randy Spann: Added GIF87a writing support 15 | * R.Spann@ConnRiver.net 16 | * 17 | * DECODE.C - An LZW decoder for GIF 18 | * Copyright (C) 1987, by Steven A. Bennett 19 | * Copyright (C) 1994, C++ version by Alejandro Aguilar Sierra 20 | * 21 | * In accordance with the above, I want to credit Steve Wilhite who wrote 22 | * the code which this is heavily inspired by... 23 | * 24 | * GIF and 'Graphics Interchange Format' are trademarks (tm) of 25 | * Compuserve, Incorporated, an H&R Block Company. 26 | * 27 | * Release Notes: This file contains a decoder routine for GIF images 28 | * which is similar, structurally, to the original routine by Steve Wilhite. 29 | * It is, however, somewhat noticably faster in most cases. 30 | * 31 | * ========================================================== 32 | */ 33 | 34 | #if !defined(__ximaGIF_h) 35 | #define __ximaGIF_h 36 | 37 | #include "ximage.h" 38 | 39 | #if CXIMAGE_SUPPORT_GIF 40 | 41 | typedef int16_t code_int; 42 | 43 | /* Various error codes used by decoder */ 44 | #define OUT_OF_MEMORY -10 45 | #define BAD_CODE_SIZE -20 46 | #define READ_ERROR -1 47 | #define WRITE_ERROR -2 48 | #define OPEN_ERROR -3 49 | #define CREATE_ERROR -4 50 | #define BAD_LINE_WIDTH -5 51 | #define MAX_CODES 4095 52 | #define GIFBUFTAM 16383 53 | #define TRANSPARENCY_CODE 0xF9 54 | 55 | //LZW GIF Image compression 56 | #define MAXBITSCODES 12 57 | #define HSIZE 5003 /* 80% occupancy */ 58 | #define MAXCODE(n_bits) (((code_int) 1 << (n_bits)) - 1) 59 | #define HashTabOf(i) htab[i] 60 | #define CodeTabOf(i) codetab[i] 61 | 62 | 63 | class CImageIterator; 64 | class DLL_EXP CxImageGIF: public CxImage 65 | { 66 | #pragma pack(1) 67 | 68 | typedef struct tag_gifgce{ 69 | uint8_t flags; /*res:3|dispmeth:3|userinputflag:1|transpcolflag:1*/ 70 | uint16_t delaytime; 71 | uint8_t transpcolindex; 72 | } struct_gifgce; 73 | 74 | typedef struct tag_dscgif{ /* Logic Screen Descriptor */ 75 | char header[6]; /* Firma and version */ 76 | uint16_t scrwidth; 77 | uint16_t scrheight; 78 | char pflds; 79 | char bcindx; 80 | char pxasrat; 81 | } struct_dscgif; 82 | 83 | typedef struct tag_image{ /* Image Descriptor */ 84 | uint16_t l; 85 | uint16_t t; 86 | uint16_t w; 87 | uint16_t h; 88 | uint8_t pf; 89 | } struct_image; 90 | 91 | typedef struct tag_TabCol{ /* Tabla de colores */ 92 | int16_t colres; /* color resolution */ 93 | int16_t sogct; /* size of global color table */ 94 | rgb_color paleta[256]; /* paleta */ 95 | } struct_TabCol; 96 | 97 | typedef struct tag_RLE{ 98 | int32_t rl_pixel; 99 | int32_t rl_basecode; 100 | int32_t rl_count; 101 | int32_t rl_table_pixel; 102 | int32_t rl_table_max; 103 | int32_t just_cleared; 104 | int32_t out_bits; 105 | int32_t out_bits_init; 106 | int32_t out_count; 107 | int32_t out_bump; 108 | int32_t out_bump_init; 109 | int32_t out_clear; 110 | int32_t out_clear_init; 111 | int32_t max_ocodes; 112 | int32_t code_clear; 113 | int32_t code_eof; 114 | uint32_t obuf; 115 | int32_t obits; 116 | uint8_t oblock[256]; 117 | int32_t oblen; 118 | } struct_RLE; 119 | #pragma pack() 120 | 121 | public: 122 | CxImageGIF(); 123 | ~CxImageGIF(); 124 | 125 | // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_GIF);} 126 | // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_GIF);} 127 | 128 | bool Decode(CxFile * fp); 129 | bool Decode(FILE *fp) { CxIOFile file(fp); return Decode(&file); } 130 | 131 | #if CXIMAGE_SUPPORT_ENCODE 132 | bool Encode(CxFile * fp); 133 | bool Encode(CxFile * fp, CxImage ** pImages, int32_t pagecount, bool bLocalColorMap = false, bool bLocalDispMeth = false); 134 | bool Encode(FILE *fp) { CxIOFile file(fp); return Encode(&file); } 135 | bool Encode(FILE *fp, CxImage ** pImages, int32_t pagecount, bool bLocalColorMap = false) 136 | { CxIOFile file(fp); return Encode(&file, pImages, pagecount, bLocalColorMap); } 137 | #endif // CXIMAGE_SUPPORT_ENCODE 138 | 139 | void SetLoops(int32_t loops); 140 | int32_t GetLoops(); 141 | void SetComment(const char* sz_comment_in); 142 | void GetComment(char* sz_comment_out); 143 | 144 | protected: 145 | bool DecodeExtension(CxFile *fp); 146 | void EncodeHeader(CxFile *fp); 147 | void EncodeLoopExtension(CxFile *fp); 148 | void EncodeExtension(CxFile *fp); 149 | void EncodeBody(CxFile *fp, bool bLocalColorMap = false); 150 | void EncodeComment(CxFile *fp); 151 | bool EncodeRGB(CxFile *fp); 152 | void GifMix(CxImage & imgsrc2, struct_image & imgdesc); 153 | 154 | struct_gifgce gifgce; 155 | 156 | int32_t curx, cury; 157 | int32_t CountDown; 158 | uint32_t cur_accum; 159 | int32_t cur_bits; 160 | int32_t interlaced, iypos, istep, iheight, ipass; 161 | int32_t ibf; 162 | int32_t ibfmax; 163 | uint8_t * buf; 164 | // Implementation 165 | int32_t GifNextPixel (); 166 | void Putword (int32_t w, CxFile* fp ); 167 | void compressNONE (int32_t init_bits, CxFile* outfile); 168 | void compressLZW (int32_t init_bits, CxFile* outfile); 169 | void output (code_int code ); 170 | void cl_hash (int32_t hsize); 171 | void char_out (int32_t c); 172 | void flush_char (); 173 | int16_t init_exp(int16_t size); 174 | int16_t get_next_code(CxFile*); 175 | int16_t decoder(CxFile*, CImageIterator* iter, int16_t linewidth, int32_t &bad_code_count); 176 | int32_t get_byte(CxFile*); 177 | int32_t out_line(CImageIterator* iter, uint8_t *pixels, int32_t linelen); 178 | int32_t get_num_frames(CxFile *f,struct_TabCol* TabColSrc,struct_dscgif* dscgif); 179 | int32_t seek_next_image(CxFile* fp, int32_t position); 180 | 181 | int16_t curr_size; /* The current code size */ 182 | int16_t clear; /* Value for a clear code */ 183 | int16_t ending; /* Value for a ending code */ 184 | int16_t newcodes; /* First available code */ 185 | int16_t top_slot; /* Highest code for current size */ 186 | int16_t slot; /* Last read code */ 187 | 188 | /* The following static variables are used 189 | * for seperating out codes */ 190 | int16_t navail_bytes; /* # bytes left in block */ 191 | int16_t nbits_left; /* # bits left in current uint8_t */ 192 | uint8_t b1; /* Current uint8_t */ 193 | uint8_t * byte_buff; /* Current block */ 194 | uint8_t *pbytes; /* Pointer to next uint8_t in block */ 195 | /* The reason we have these seperated like this instead of using 196 | * a structure like the original Wilhite code did, is because this 197 | * stuff generally produces significantly faster code when compiled... 198 | * This code is full of similar speedups... (For a good book on writing 199 | * C for speed or for space optomisation, see Efficient C by Tom Plum, 200 | * published by Plum-Hall Associates...) 201 | */ 202 | uint8_t * stack; /* Stack for storing pixels */ 203 | uint8_t * suffix; /* Suffix table */ 204 | uint16_t * prefix; /* Prefix linked list */ 205 | 206 | //LZW GIF Image compression routines 207 | int32_t * htab; 208 | uint16_t * codetab; 209 | int32_t n_bits; /* number of bits/code */ 210 | code_int maxcode; /* maximum code, given n_bits */ 211 | code_int free_ent; /* first unused entry */ 212 | int32_t clear_flg; 213 | int32_t g_init_bits; 214 | CxFile* g_outfile; 215 | int32_t ClearCode; 216 | int32_t EOFCode; 217 | 218 | int32_t a_count; 219 | char * accum; 220 | 221 | char * m_comment; 222 | int32_t m_loops; 223 | 224 | //RLE compression routines 225 | void compressRLE( int32_t init_bits, CxFile* outfile); 226 | void rle_clear(struct_RLE* rle); 227 | void rle_flush(struct_RLE* rle); 228 | void rle_flush_withtable(int32_t count, struct_RLE* rle); 229 | void rle_flush_clearorrep(int32_t count, struct_RLE* rle); 230 | void rle_flush_fromclear(int32_t count,struct_RLE* rle); 231 | void rle_output_plain(int32_t c,struct_RLE* rle); 232 | void rle_reset_out_clear(struct_RLE* rle); 233 | uint32_t rle_compute_triangle_count(uint32_t count, uint32_t nrepcodes); 234 | uint32_t rle_isqrt(uint32_t x); 235 | void rle_write_block(struct_RLE* rle); 236 | void rle_block_out(uint8_t c, struct_RLE* rle); 237 | void rle_block_flush(struct_RLE* rle); 238 | void rle_output(int32_t val, struct_RLE* rle); 239 | void rle_output_flush(struct_RLE* rle); 240 | }; 241 | 242 | #endif 243 | 244 | #endif 245 | -------------------------------------------------------------------------------- /ximaico.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximaico.h 3 | * Purpose: ICON Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageICO (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * ========================================================== 9 | */ 10 | #if !defined(__ximaICO_h) 11 | #define __ximaICO_h 12 | 13 | #include "ximage.h" 14 | 15 | #if CXIMAGE_SUPPORT_ICO 16 | 17 | class CxImageICO: public CxImage 18 | { 19 | typedef struct tagIconDirectoryEntry { 20 | uint8_t bWidth; 21 | uint8_t bHeight; 22 | uint8_t bColorCount; 23 | uint8_t bReserved; 24 | uint16_t wPlanes; 25 | uint16_t wBitCount; 26 | uint32_t dwBytesInRes; 27 | uint32_t dwImageOffset; 28 | } ICONDIRENTRY; 29 | 30 | typedef struct tagIconDir { 31 | uint16_t idReserved; 32 | uint16_t idType; 33 | uint16_t idCount; 34 | } ICONHEADER; 35 | 36 | public: 37 | CxImageICO(): CxImage(CXIMAGE_FORMAT_ICO) {m_dwImageOffset=0;} 38 | 39 | // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_ICO);} 40 | // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_ICO);} 41 | bool Decode(CxFile * hFile); 42 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 43 | 44 | #if CXIMAGE_SUPPORT_ENCODE 45 | bool Encode(CxFile * hFile, bool bAppend=false, int32_t nPageCount=0); 46 | bool Encode(CxFile * hFile, CxImage ** pImages, int32_t nPageCount); 47 | bool Encode(FILE *hFile, bool bAppend=false, int32_t nPageCount=0) 48 | { CxIOFile file(hFile); return Encode(&file,bAppend,nPageCount); } 49 | bool Encode(FILE *hFile, CxImage ** pImages, int32_t nPageCount) 50 | { CxIOFile file(hFile); return Encode(&file, pImages, nPageCount); } 51 | #endif // CXIMAGE_SUPPORT_ENCODE 52 | protected: 53 | uint32_t m_dwImageOffset; 54 | }; 55 | 56 | #endif 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /ximainfo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/movableink/cximage/73a4518e7a3a7fbc2f27c91e5873a56769c8dbf7/ximainfo.cpp -------------------------------------------------------------------------------- /ximaint.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/movableink/cximage/73a4518e7a3a7fbc2f27c91e5873a56769c8dbf7/ximaint.cpp -------------------------------------------------------------------------------- /ximaiter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ImaIter.h 3 | * Purpose: Declaration of the Platform Independent Image Base Class 4 | * Author: Alejandro Aguilar Sierra 5 | * Created: 1995 6 | * Copyright: (c) 1995, Alejandro Aguilar Sierra 7 | * 8 | * 07/08/2001 Davide Pizzolato - www.xdp.it 9 | * - removed slow loops 10 | * - added safe checks 11 | * 12 | * Permission is given by the author to freely redistribute and include 13 | * this code in any program as int32_t as this credit is given where due. 14 | * 15 | * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY 16 | * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES 17 | * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE 18 | * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED 19 | * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT 20 | * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY 21 | * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL 22 | * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER 23 | * THIS DISCLAIMER. 24 | * 25 | * Use at your own risk! 26 | * ========================================================== 27 | */ 28 | 29 | #if !defined(__ImaIter_h) 30 | #define __ImaIter_h 31 | 32 | #include "ximage.h" 33 | #include "ximadef.h" 34 | 35 | class CImageIterator 36 | { 37 | friend class CxImage; 38 | protected: 39 | int32_t Itx, Ity; // Counters 40 | int32_t Stepx, Stepy; 41 | uint8_t* IterImage; // Image pointer 42 | CxImage *ima; 43 | public: 44 | // Constructors 45 | CImageIterator ( void ); 46 | CImageIterator ( CxImage *image ); 47 | operator CxImage* (); 48 | 49 | // Iterators 50 | BOOL ItOK (); 51 | void Reset (); 52 | void Upset (); 53 | void SetRow(uint8_t *buf, int32_t n); 54 | void GetRow(uint8_t *buf, int32_t n); 55 | uint8_t GetByte( ) { return IterImage[Itx]; } 56 | void SetByte(uint8_t b) { IterImage[Itx] = b; } 57 | uint8_t* GetRow(void); 58 | uint8_t* GetRow(int32_t n); 59 | BOOL NextRow(); 60 | BOOL PrevRow(); 61 | BOOL NextByte(); 62 | BOOL PrevByte(); 63 | 64 | void SetSteps(int32_t x, int32_t y=0) { Stepx = x; Stepy = y; } 65 | void GetSteps(int32_t *x, int32_t *y) { *x = Stepx; *y = Stepy; } 66 | BOOL NextStep(); 67 | BOOL PrevStep(); 68 | 69 | void SetY(int32_t y); /* AD - for interlace */ 70 | int32_t GetY() {return Ity;} 71 | BOOL GetCol(uint8_t* pCol, uint32_t x); 72 | BOOL SetCol(uint8_t* pCol, uint32_t x); 73 | }; 74 | 75 | ///////////////////////////////////////////////////////////////////// 76 | inline 77 | CImageIterator::CImageIterator(void) 78 | { 79 | ima = 0; 80 | IterImage = 0; 81 | Itx = Ity = 0; 82 | Stepx = Stepy = 0; 83 | } 84 | ///////////////////////////////////////////////////////////////////// 85 | inline 86 | CImageIterator::CImageIterator(CxImage *imageImpl): ima(imageImpl) 87 | { 88 | if (ima) IterImage = ima->GetBits(); 89 | Itx = Ity = 0; 90 | Stepx = Stepy = 0; 91 | } 92 | ///////////////////////////////////////////////////////////////////// 93 | inline 94 | CImageIterator::operator CxImage* () 95 | { 96 | return ima; 97 | } 98 | ///////////////////////////////////////////////////////////////////// 99 | inline BOOL CImageIterator::ItOK () 100 | { 101 | if (ima) return ima->IsInside(Itx, Ity); 102 | else return FALSE; 103 | } 104 | ///////////////////////////////////////////////////////////////////// 105 | inline void CImageIterator::Reset() 106 | { 107 | if (ima) IterImage = ima->GetBits(); 108 | else IterImage=0; 109 | Itx = Ity = 0; 110 | } 111 | ///////////////////////////////////////////////////////////////////// 112 | inline void CImageIterator::Upset() 113 | { 114 | Itx = 0; 115 | Ity = ima->GetHeight()-1; 116 | IterImage = ima->GetBits() + ima->GetEffWidth()*(ima->GetHeight()-1); 117 | } 118 | ///////////////////////////////////////////////////////////////////// 119 | inline BOOL CImageIterator::NextRow() 120 | { 121 | if (++Ity >= (int32_t)ima->GetHeight()) return 0; 122 | IterImage += ima->GetEffWidth(); 123 | return 1; 124 | } 125 | ///////////////////////////////////////////////////////////////////// 126 | inline BOOL CImageIterator::PrevRow() 127 | { 128 | if (--Ity < 0) return 0; 129 | IterImage -= ima->GetEffWidth(); 130 | return 1; 131 | } 132 | /* AD - for interlace */ 133 | inline void CImageIterator::SetY(int32_t y) 134 | { 135 | if ((y < 0) || (y > (int32_t)ima->GetHeight())) return; 136 | Ity = y; 137 | IterImage = ima->GetBits() + ima->GetEffWidth()*y; 138 | } 139 | ///////////////////////////////////////////////////////////////////// 140 | inline void CImageIterator::SetRow(uint8_t *buf, int32_t n) 141 | { 142 | if (n<0) n = (int32_t)ima->GetEffWidth(); 143 | else n = min(n,(int32_t)ima->GetEffWidth()); 144 | 145 | if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) memcpy(IterImage,buf,n); 146 | } 147 | ///////////////////////////////////////////////////////////////////// 148 | inline void CImageIterator::GetRow(uint8_t *buf, int32_t n) 149 | { 150 | if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) 151 | memcpy(buf,IterImage,min(n,(int32_t)ima->GetEffWidth())); 152 | } 153 | ///////////////////////////////////////////////////////////////////// 154 | inline uint8_t* CImageIterator::GetRow() 155 | { 156 | return IterImage; 157 | } 158 | ///////////////////////////////////////////////////////////////////// 159 | inline uint8_t* CImageIterator::GetRow(int32_t n) 160 | { 161 | SetY(n); 162 | return IterImage; 163 | } 164 | ///////////////////////////////////////////////////////////////////// 165 | inline BOOL CImageIterator::NextByte() 166 | { 167 | if (++Itx < (int32_t)ima->GetEffWidth()) return 1; 168 | else 169 | if (++Ity < (int32_t)ima->GetHeight()){ 170 | IterImage += ima->GetEffWidth(); 171 | Itx = 0; 172 | return 1; 173 | } else 174 | return 0; 175 | } 176 | ///////////////////////////////////////////////////////////////////// 177 | inline BOOL CImageIterator::PrevByte() 178 | { 179 | if (--Itx >= 0) return 1; 180 | else 181 | if (--Ity >= 0){ 182 | IterImage -= ima->GetEffWidth(); 183 | Itx = 0; 184 | return 1; 185 | } else 186 | return 0; 187 | } 188 | ///////////////////////////////////////////////////////////////////// 189 | inline BOOL CImageIterator::NextStep() 190 | { 191 | Itx += Stepx; 192 | if (Itx < (int32_t)ima->GetEffWidth()) return 1; 193 | else { 194 | Ity += Stepy; 195 | if (Ity < (int32_t)ima->GetHeight()){ 196 | IterImage += ima->GetEffWidth(); 197 | Itx = 0; 198 | return 1; 199 | } else 200 | return 0; 201 | } 202 | } 203 | ///////////////////////////////////////////////////////////////////// 204 | inline BOOL CImageIterator::PrevStep() 205 | { 206 | Itx -= Stepx; 207 | if (Itx >= 0) return 1; 208 | else { 209 | Ity -= Stepy; 210 | if (Ity >= 0 && Ity < (int32_t)ima->GetHeight()) { 211 | IterImage -= ima->GetEffWidth(); 212 | Itx = 0; 213 | return 1; 214 | } else 215 | return 0; 216 | } 217 | } 218 | ///////////////////////////////////////////////////////////////////// 219 | inline BOOL CImageIterator::GetCol(uint8_t* pCol, uint32_t x) 220 | { 221 | if ((pCol==0)||(ima->GetBpp()<8)||(x>=ima->GetWidth())) 222 | return 0; 223 | uint32_t h = ima->GetHeight(); 224 | //uint32_t line = ima->GetEffWidth(); 225 | uint8_t bytes = (uint8_t)(ima->GetBpp()>>3); 226 | uint8_t* pSrc; 227 | for (uint32_t y=0;yGetBits(y) + x*bytes; 229 | for (uint8_t w=0;wGetBpp()<8)||(x>=ima->GetWidth())) 239 | return 0; 240 | uint32_t h = ima->GetHeight(); 241 | //uint32_t line = ima->GetEffWidth(); 242 | uint8_t bytes = (uint8_t)(ima->GetBpp()>>3); 243 | uint8_t* pSrc; 244 | for (uint32_t y=0;yGetBits(y) + x*bytes; 246 | for (uint8_t w=0;wnumcmpts_ > 64 || image->numcmpts_ < 0) 86 | cx_throw("error: too many components"); 87 | 88 | // 01/Jan/2005: Always force conversion to sRGB. Seems to be required for many types of JPEG2000 file. 89 | // if (depth!=1 && depth!=4 && depth!=8) 90 | if (image->numcmpts_>=3 && depth <=8) 91 | { 92 | jas_image_t *newimage; 93 | jas_cmprof_t *outprof; 94 | //jas_eprintf("forcing conversion to sRGB\n"); 95 | outprof = jas_cmprof_createfromclrspc(JAS_CLRSPC_SRGB); 96 | if (!outprof) { 97 | cx_throw("cannot create sRGB profile"); 98 | } 99 | newimage = jas_image_chclrspc(image, outprof, JAS_CMXFORM_INTENT_PER); 100 | if (!newimage) { 101 | jas_cmprof_destroy(outprof); // 01/Jan/2005: Destroy color profile on error. 102 | cx_throw("cannot convert to sRGB"); 103 | } 104 | jas_image_destroy(image); 105 | jas_cmprof_destroy(outprof); 106 | image = newimage; 107 | } 108 | 109 | bufs = (jas_matrix_t **)calloc(image->numcmpts_, sizeof(jas_matrix_t**)); 110 | for (i = 0; i < image->numcmpts_; ++i) { 111 | bufs[i] = jas_matrix_create(1, w); 112 | if (!bufs[i]) { 113 | cx_throw("error: cannot allocate memory"); 114 | } 115 | } 116 | 117 | int32_t nshift = (depth>8) ? (depth-8) : 0; 118 | 119 | if (image->numcmpts_==3 && 120 | image->cmpts_[0]->width_ == image->cmpts_[1]->width_ && 121 | image->cmpts_[1]->width_ == image->cmpts_[2]->width_ && 122 | image->cmpts_[0]->height_ == image->cmpts_[1]->height_ && 123 | image->cmpts_[1]->height_ == image->cmpts_[2]->height_ && 124 | image->cmpts_[0]->prec_ == image->cmpts_[1]->prec_ && 125 | image->cmpts_[1]->prec_ == image->cmpts_[2]->prec_ ) 126 | { 127 | 128 | if(!Create(w,h,24,fmt)) 129 | cx_throw(""); 130 | 131 | RGBQUAD c; 132 | for (y=0; ynumcmpts_; ++cmptno) { 134 | jas_image_readcmpt(image, cmptno, 0, y, w, 1, bufs[cmptno]); 135 | } 136 | 137 | for (x=0; x>nshift)); 139 | c.rgbGreen = (uint8_t)((jas_matrix_getv(bufs[1], x)>>nshift)); 140 | c.rgbBlue = (uint8_t)((jas_matrix_getv(bufs[2], x)>>nshift)); 141 | SetPixelColor(x,h-1-y,c); 142 | } 143 | } 144 | } else { 145 | info.nNumFrames = image->numcmpts_; 146 | if ((info.nFrame<0)||(info.nFrame>=info.nNumFrames)){ 147 | cx_throw("wrong frame!"); 148 | } 149 | for (cmptno=0; cmptno<=info.nFrame; cmptno++) { 150 | w = jas_image_cmptwidth(image,cmptno); 151 | h = jas_image_cmptheight(image,cmptno); 152 | depth = jas_image_cmptprec(image,cmptno); 153 | if (depth>8) depth=8; 154 | if(!Create(w,h,depth,imagetype)) 155 | cx_throw(""); 156 | SetGrayPalette(); 157 | for (y=0; y>nshift))); 161 | } 162 | } 163 | } 164 | } 165 | 166 | 167 | } cx_catch { 168 | if (strcmp(message,"")) strncpy(info.szLastError,message,255); 169 | if (info.nEscape == -1 && fmt>0){ 170 | error = 0; 171 | } else { 172 | error = 1; 173 | } 174 | } 175 | 176 | if (bufs) { 177 | for (i = 0; i < image->numcmpts_; ++i){ if (bufs[i]) jas_matrix_destroy(bufs[i]);} 178 | free(bufs); 179 | } 180 | jas_cleanup(); 181 | if (image) jas_image_destroy(image); 182 | if (in) jas_stream_close(in); 183 | return (error==0); 184 | } 185 | //////////////////////////////////////////////////////////////////////////////// 186 | #endif //CXIMAGE_SUPPORT_DECODE 187 | //////////////////////////////////////////////////////////////////////////////// 188 | #if CXIMAGE_SUPPORT_ENCODE 189 | //////////////////////////////////////////////////////////////////////////////// 190 | bool CxImageJAS::Encode(CxFile * hFile, uint32_t imagetype) 191 | { 192 | if (EncodeSafeCheck(hFile)) return false; 193 | 194 | if (head.biClrUsed!=0 && !IsGrayScale()){ 195 | strcpy(info.szLastError,"JasPer can save only RGB or GrayScale images"); 196 | return false; 197 | } 198 | 199 | jas_image_t *image=0; 200 | jas_stream_t *out=0; 201 | jas_matrix_t *cmpts[3]; 202 | int32_t x,y,yflip,error=0; 203 | uint_fast16_t cmptno, numcmpts=0; 204 | jas_image_cmptparm_t cmptparms[3], *cmptparm; 205 | 206 | cx_try { 207 | 208 | if (jas_init()) 209 | cx_throw("cannot initialize jasper"); 210 | 211 | out = jas_stream_fdopen(0, "wb"); 212 | if (!out) 213 | cx_throw("error: cannot open standard output"); 214 | 215 | CxFileJas src(hFile,out); 216 | 217 | numcmpts = head.biClrUsed==0 ? 3 : 1; 218 | 219 | for (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno, ++cmptparm) { 220 | cmptparm->tlx = 0; 221 | cmptparm->tly = 0; 222 | cmptparm->hstep = 1; 223 | cmptparm->vstep = 1; 224 | cmptparm->width = head.biWidth; 225 | cmptparm->height = head.biHeight; 226 | cmptparm->prec = 8; 227 | cmptparm->sgnd = false; 228 | } 229 | 230 | /* Create image object. */ 231 | image = jas_image_create(numcmpts, cmptparms, JAS_CLRSPC_UNKNOWN); 232 | if (!image) 233 | cx_throw("error : jas_image_create"); 234 | 235 | if (numcmpts == 3) { 236 | jas_image_setclrspc(image, JAS_CLRSPC_SRGB); 237 | jas_image_setcmpttype(image, 0, 238 | JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_R)); 239 | jas_image_setcmpttype(image, 1, 240 | JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_G)); 241 | jas_image_setcmpttype(image, 2, 242 | JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_B)); 243 | } else { 244 | jas_image_setclrspc(image, JAS_CLRSPC_SGRAY); 245 | jas_image_setcmpttype(image, 0, 246 | JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y)); 247 | } 248 | 249 | 250 | for (x = 0; x < numcmpts; ++x) { cmpts[x] = 0; } 251 | /* Create temporary matrices to hold component data. */ 252 | for (x = 0; x < numcmpts; ++x) { 253 | cmpts[x] = jas_matrix_create(1, head.biWidth); 254 | if (!cmpts[x]) { 255 | cx_throw("error : can't allocate memory"); 256 | } 257 | } 258 | 259 | RGBQUAD c; 260 | for (y = 0; y < head.biHeight; ++y) { 261 | for (x = 0; x < head.biWidth; ++x) { 262 | if (head.biClrUsed==0){ 263 | c = GetPixelColor(x,y); 264 | jas_matrix_setv(cmpts[0], x, c.rgbRed); 265 | jas_matrix_setv(cmpts[1], x, c.rgbGreen); 266 | jas_matrix_setv(cmpts[2], x, c.rgbBlue); 267 | } else { 268 | jas_matrix_setv(cmpts[0], x, GetPixelIndex(x,y)); 269 | } 270 | } 271 | yflip = head.biHeight - 1 - y; 272 | for (cmptno = 0; cmptno < numcmpts; ++cmptno) { 273 | if (jas_image_writecmpt(image, cmptno, 0, yflip, head.biWidth, 1, cmpts[cmptno])) { 274 | cx_throw("error : jas_image_writecmpt"); 275 | } 276 | } 277 | } 278 | 279 | char szfmt[4]; 280 | *szfmt = '\0'; 281 | #if CXIMAGE_SUPPORT_JP2 282 | if (imagetype == CXIMAGE_FORMAT_JP2) strcpy(szfmt,"jp2"); 283 | #endif 284 | #if CXIMAGE_SUPPORT_JPC 285 | if (imagetype == CXIMAGE_FORMAT_JPC) strcpy(szfmt,"jpc"); 286 | #endif 287 | #if CXIMAGE_SUPPORT_RAS 288 | if (imagetype == CXIMAGE_FORMAT_RAS) strcpy(szfmt,"ras"); 289 | #endif 290 | #if CXIMAGE_SUPPORT_PNM 291 | if (imagetype == CXIMAGE_FORMAT_PNM) strcpy(szfmt,"pnm"); 292 | #endif 293 | #if CXIMAGE_SUPPORT_PGX 294 | if (imagetype == CXIMAGE_FORMAT_PGX){ 295 | strcpy(szfmt,"pgx"); 296 | if (head.biClrUsed==0) cx_throw("PGX can save only GrayScale images"); 297 | } 298 | #endif 299 | int32_t outfmt = jas_image_strtofmt(szfmt); 300 | 301 | char szoutopts[32]; 302 | sprintf(szoutopts,"rate=%.3f", info.fQuality/100.0f); 303 | 304 | if (jas_image_encode(image, out, outfmt, szoutopts)) { 305 | cx_throw("error: cannot encode image"); 306 | } 307 | jas_stream_flush(out); 308 | 309 | } cx_catch { 310 | if (strcmp(message,"")) strncpy(info.szLastError,message,255); 311 | error = 1; 312 | } 313 | 314 | for (x = 0; x < numcmpts; ++x) { if (cmpts[x]) { jas_matrix_destroy(cmpts[x]); } } 315 | jas_cleanup(); 316 | if (image) jas_image_destroy(image); 317 | if (out) jas_stream_close(out); 318 | 319 | return (error==0); 320 | } 321 | //////////////////////////////////////////////////////////////////////////////// 322 | #endif // CXIMAGE_SUPPORT_ENCODE 323 | //////////////////////////////////////////////////////////////////////////////// 324 | #endif // CXIMAGE_SUPPORT_JASPER 325 | 326 | -------------------------------------------------------------------------------- /ximajas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximajas.h 3 | * Purpose: Jasper Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageJAS (c) 12/Apr/2003 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * 9 | * based on JasPer Copyright (c) 2001-2003 Michael David Adams - All rights reserved. 10 | * ========================================================== 11 | */ 12 | #if !defined(__ximaJAS_h) 13 | #define __ximaJAS_h 14 | 15 | #include "ximage.h" 16 | 17 | #if CXIMAGE_SUPPORT_JASPER 18 | 19 | #ifdef _LINUX 20 | #include 21 | #else 22 | #include "../jasper/include/jasper/jasper.h" 23 | #endif 24 | 25 | class CxImageJAS: public CxImage 26 | { 27 | public: 28 | CxImageJAS(): CxImage((uint32_t)0) {} // cast to uint32_t 29 | 30 | // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,0);} 31 | // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,0);} 32 | bool Decode(CxFile * hFile, uint32_t imagetype = 0); 33 | bool Decode(FILE *hFile, uint32_t imagetype = 0) { CxIOFile file(hFile); return Decode(&file,imagetype); } 34 | 35 | #if CXIMAGE_SUPPORT_ENCODE 36 | bool Encode(CxFile * hFile, uint32_t imagetype = 0); 37 | bool Encode(FILE *hFile, uint32_t imagetype = 0) { CxIOFile file(hFile); return Encode(&file,imagetype); } 38 | #endif // CXIMAGE_SUPPORT_ENCODE 39 | protected: 40 | 41 | class CxFileJas 42 | { 43 | public: 44 | CxFileJas(CxFile* pFile,jas_stream_t *stream) 45 | { 46 | if (stream->obj_) jas_free(stream->obj_); 47 | stream->obj_ = pFile; 48 | 49 | // - cannot set the stream->ops_->functions here, 50 | // because this overwrites a static structure in the Jasper library. 51 | // This structure is used by Jasper for internal operations too, e.g. tempfile. 52 | // However the ops_ pointer in the stream can be overwritten. 53 | 54 | //stream->ops_->close_ = JasClose; 55 | //stream->ops_->read_ = JasRead; 56 | //stream->ops_->seek_ = JasSeek; 57 | //stream->ops_->write_ = JasWrite; 58 | 59 | jas_stream_CxFile.close_ = JasClose; 60 | jas_stream_CxFile.read_ = JasRead; 61 | jas_stream_CxFile.seek_ = JasSeek; 62 | jas_stream_CxFile.write_ = JasWrite; 63 | 64 | stream->ops_ = &jas_stream_CxFile; 65 | 66 | // - end 67 | } 68 | static int32_t JasRead(jas_stream_obj_t *obj, char *buf, int32_t cnt) 69 | { return ((CxFile*)obj)->Read(buf,1,cnt); } 70 | static int32_t JasWrite(jas_stream_obj_t *obj, char *buf, int32_t cnt) 71 | { return ((CxFile*)obj)->Write(buf,1,cnt); } 72 | static long JasSeek(jas_stream_obj_t *obj, long offset, int32_t origin) 73 | { return ((CxFile*)obj)->Seek(offset,origin); } 74 | static int32_t JasClose(jas_stream_obj_t * /*obj*/) 75 | { return 1; } 76 | 77 | // 78 | private: 79 | jas_stream_ops_t jas_stream_CxFile; 80 | // - end 81 | 82 | }; 83 | 84 | }; 85 | 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /ximajbg.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximajbg.cpp 3 | * Purpose: Platform Independent JBG Image Class Loader and Writer 4 | * 18/Aug/2002 Davide Pizzolato - www.xdp.it 5 | * CxImage version 7.0.1 07/Jan/2011 6 | */ 7 | 8 | #include "ximajbg.h" 9 | 10 | #if CXIMAGE_SUPPORT_JBG 11 | 12 | #include "ximaiter.h" 13 | 14 | #define JBIG_BUFSIZE 8192 15 | 16 | //////////////////////////////////////////////////////////////////////////////// 17 | #if CXIMAGE_SUPPORT_DECODE 18 | //////////////////////////////////////////////////////////////////////////////// 19 | bool CxImageJBG::Decode(CxFile *hFile) 20 | { 21 | if (hFile == NULL) return false; 22 | 23 | struct jbg_dec_state jbig_state; 24 | uint32_t xmax = 4294967295UL, ymax = 4294967295UL; 25 | uint32_t len, cnt; 26 | uint8_t *buffer=0,*p; 27 | int32_t result; 28 | 29 | cx_try 30 | { 31 | jbg_dec_init(&jbig_state); 32 | jbg_dec_maxsize(&jbig_state, xmax, ymax); 33 | 34 | buffer = (uint8_t*)malloc(JBIG_BUFSIZE); 35 | if (!buffer) cx_throw("Sorry, not enough memory available!"); 36 | 37 | result = JBG_EAGAIN; 38 | do { 39 | len = hFile->Read(buffer, 1, JBIG_BUFSIZE); 40 | if (!len) break; 41 | cnt = 0; 42 | p = buffer; 43 | while (len > 0 && (result == JBG_EAGAIN || result == JBG_EOK)) { 44 | result = jbg_dec_in(&jbig_state, p, len, &cnt); 45 | p += cnt; 46 | len -= cnt; 47 | } 48 | } while (result == JBG_EAGAIN || result == JBG_EOK); 49 | 50 | if (hFile->Error()) 51 | cx_throw("Problem while reading input file"); 52 | if (result != JBG_EOK && result != JBG_EOK_INTR) 53 | cx_throw("Problem with input file"); 54 | 55 | int32_t w, h, bpp, planes, ew; 56 | 57 | w = jbg_dec_getwidth(&jbig_state); 58 | h = jbg_dec_getheight(&jbig_state); 59 | planes = jbg_dec_getplanes(&jbig_state); 60 | bpp = (planes+7)>>3; 61 | ew = (w + 7)>>3; 62 | 63 | if (info.nEscape == -1){ 64 | head.biWidth = w; 65 | head.biHeight= h; 66 | info.dwType = CXIMAGE_FORMAT_JBG; 67 | cx_throw("output dimensions returned"); 68 | } 69 | 70 | switch (planes){ 71 | case 1: 72 | { 73 | uint8_t* binary_image = jbg_dec_getimage(&jbig_state, 0); 74 | 75 | if (!Create(w,h,1,CXIMAGE_FORMAT_JBG)) 76 | cx_throw(""); 77 | 78 | SetPaletteColor(0,255,255,255); 79 | SetPaletteColor(1,0,0,0); 80 | 81 | CImageIterator iter(this); 82 | iter.Upset(); 83 | for (int32_t i=0;i>3; 124 | ew = (w + 7)>>3; 125 | 126 | uint8_t mask; 127 | RGBQUAD *rgb = GetPalette(); 128 | if (CompareColors(&rgb[0],&rgb[1])<0) mask=255; else mask=0; 129 | 130 | uint8_t *buffer = (uint8_t*)malloc(ew*h*2); 131 | if (!buffer) { 132 | strcpy(info.szLastError,"Sorry, not enough memory available!"); 133 | return false; 134 | } 135 | 136 | for (y=0; yError()){ 166 | strcpy(info.szLastError,"Problem while writing JBG file"); 167 | return false; 168 | } 169 | 170 | return true; 171 | } 172 | //////////////////////////////////////////////////////////////////////////////// 173 | #endif // CXIMAGE_SUPPORT_JBG 174 | 175 | -------------------------------------------------------------------------------- /ximajbg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximajbg.h 3 | * Purpose: JBG Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageJBG (c) 18/Aug/2002 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * 9 | * based on LIBJBG Copyright (c) 2002, Markus Kuhn - All rights reserved. 10 | * ========================================================== 11 | */ 12 | #if !defined(__ximaJBG_h) 13 | #define __ximaJBG_h 14 | 15 | #include "ximage.h" 16 | 17 | #if CXIMAGE_SUPPORT_JBG 18 | 19 | extern "C" { 20 | #include "../jbig/jbig.h" 21 | }; 22 | 23 | class CxImageJBG: public CxImage 24 | { 25 | public: 26 | CxImageJBG(): CxImage(CXIMAGE_FORMAT_JBG) {} 27 | 28 | // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_JBG);} 29 | // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_JBG);} 30 | bool Decode(CxFile * hFile); 31 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 32 | 33 | #if CXIMAGE_SUPPORT_ENCODE 34 | bool Encode(CxFile * hFile); 35 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 36 | #endif // CXIMAGE_SUPPORT_ENCODE 37 | protected: 38 | static void jbig_data_out(uint8_t *buffer, uint32_t len, void *file) 39 | {((CxFile*)file)->Write(buffer,len,1);} 40 | }; 41 | 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /ximajpg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximajpg.h 3 | * Purpose: JPG Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageJPG (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * 9 | * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes 10 | * 11 | * Special thanks to Chris Shearer Cooper for CxFileJpg tips & code 12 | * 13 | * EXIF support based on jhead-1.8 by Matthias Wandel 14 | * 15 | * original CImageJPG and CImageIterator implementation are: 16 | * Copyright: (c) 1995, Alejandro Aguilar Sierra 17 | * 18 | * This software is based in part on the work of the Independent JPEG Group. 19 | * Copyright (C) 1991-1998, Thomas G. Lane. 20 | * ========================================================== 21 | */ 22 | #if !defined(__ximaJPEG_h) 23 | #define __ximaJPEG_h 24 | 25 | #include "ximage.h" 26 | 27 | #if CXIMAGE_SUPPORT_JPG 28 | 29 | #define CXIMAGEJPG_SUPPORT_EXIF CXIMAGE_SUPPORT_EXIF 30 | 31 | extern "C" { 32 | #ifdef _LINUX 33 | #include 34 | #include 35 | #else 36 | #include "../jpeg/jpeglib.h" 37 | #include "../jpeg/jerror.h" 38 | #endif 39 | } 40 | 41 | class DLL_EXP CxImageJPG: public CxImage 42 | { 43 | public: 44 | CxImageJPG(); 45 | ~CxImageJPG(); 46 | 47 | // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_JPG);} 48 | // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_JPG);} 49 | bool Decode(CxFile * hFile); 50 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 51 | 52 | #if CXIMAGE_SUPPORT_ENCODE 53 | bool Encode(CxFile * hFile); 54 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 55 | #endif // CXIMAGE_SUPPORT_ENCODE 56 | 57 | /* 58 | * EXIF support based on jhead-1.8 by Matthias Wandel 59 | */ 60 | 61 | #if CXIMAGEJPG_SUPPORT_EXIF 62 | 63 | //-------------------------------------------------------------------------- 64 | // JPEG markers consist of one or more 0xFF bytes, followed by a marker 65 | // code byte (which is not an FF). Here are the marker codes of interest 66 | // in this program. (See jdmarker.c for a more complete list.) 67 | //-------------------------------------------------------------------------- 68 | 69 | #define M_SOF0 0xC0 // Start Of Frame N 70 | #define M_SOF1 0xC1 // N indicates which compression process 71 | #define M_SOF2 0xC2 // Only SOF0-SOF2 are now in common use 72 | #define M_SOF3 0xC3 73 | #define M_SOF5 0xC5 // NB: codes C4 and CC are NOT SOF markers 74 | #define M_SOF6 0xC6 75 | #define M_SOF7 0xC7 76 | #define M_SOF9 0xC9 77 | #define M_SOF10 0xCA 78 | #define M_SOF11 0xCB 79 | #define M_SOF13 0xCD 80 | #define M_SOF14 0xCE 81 | #define M_SOF15 0xCF 82 | #define M_SOI 0xD8 // Start Of Image (beginning of datastream) 83 | #define M_EOI 0xD9 // End Of Image (end of datastream) 84 | #define M_SOS 0xDA // Start Of Scan (begins compressed data) 85 | #define M_JFIF 0xE0 // Jfif marker 86 | #define M_EXIF 0xE1 // Exif marker 87 | #define M_COM 0xFE // COMment 88 | 89 | #define PSEUDO_IMAGE_MARKER 0x123; // Extra value. 90 | 91 | #define EXIF_READ_EXIF 0x01 92 | #define EXIF_READ_IMAGE 0x02 93 | #define EXIF_READ_ALL 0x03 94 | 95 | class DLL_EXP CxExifInfo 96 | { 97 | 98 | typedef struct tag_Section_t{ 99 | uint8_t* Data; 100 | int32_t Type; 101 | unsigned Size; 102 | } Section_t; 103 | 104 | public: 105 | EXIFINFO* m_exifinfo; 106 | char m_szLastError[256]; 107 | CxExifInfo(EXIFINFO* info = NULL); 108 | ~CxExifInfo(); 109 | bool DecodeExif(CxFile * hFile, int32_t nReadMode = EXIF_READ_EXIF); 110 | bool EncodeExif(CxFile * hFile); 111 | void DiscardAllButExif(); 112 | protected: 113 | bool process_EXIF(uint8_t * CharBuf, uint32_t length); 114 | void process_COM (const uint8_t * Data, int32_t length); 115 | void process_SOFn (const uint8_t * Data, int32_t marker); 116 | int32_t Get16u(void * Short); 117 | int32_t Get16m(void * Short); 118 | int32_t Get32s(void * Long); 119 | uint32_t Get32u(void * Long); 120 | double ConvertAnyFormat(void * ValuePtr, int32_t Format); 121 | void* FindSection(int32_t SectionType); 122 | bool ProcessExifDir(uint8_t * DirStart, uint8_t * OffsetBase, unsigned ExifLength, 123 | EXIFINFO * const pInfo, uint8_t ** const LastExifRefdP, int32_t NestingLevel=0); 124 | int32_t ExifImageWidth; 125 | int32_t MotorolaOrder; 126 | Section_t Sections[MAX_SECTIONS]; 127 | int32_t SectionsRead; 128 | bool freeinfo; 129 | }; 130 | 131 | CxExifInfo* m_exif; 132 | bool DecodeExif(CxFile * hFile); 133 | bool DecodeExif(FILE * hFile) { CxIOFile file(hFile); return DecodeExif(&file); } 134 | bool GetExifThumbnail(const TCHAR *filename, const TCHAR *outname, int32_t type); 135 | 136 | #endif //CXIMAGEJPG_SUPPORT_EXIF 137 | 138 | //////////////////////////////////////////////////////////////////////////////////////// 139 | ////////////////////// C x F i l e J p g //////////////////////////////// 140 | //////////////////////////////////////////////////////////////////////////////////////// 141 | 142 | // thanks to Chris Shearer Cooper 143 | class CxFileJpg : public jpeg_destination_mgr, public jpeg_source_mgr 144 | { 145 | public: 146 | enum { eBufSize = 4096 }; 147 | 148 | CxFileJpg(CxFile* pFile) 149 | { 150 | m_pFile = pFile; 151 | 152 | init_destination = InitDestination; 153 | empty_output_buffer = EmptyOutputBuffer; 154 | term_destination = TermDestination; 155 | 156 | init_source = InitSource; 157 | fill_input_buffer = FillInputBuffer; 158 | skip_input_data = SkipInputData; 159 | resync_to_restart = jpeg_resync_to_restart; // use default method 160 | term_source = TermSource; 161 | next_input_byte = NULL; //* => next byte to read from buffer 162 | bytes_in_buffer = 0; //* # of bytes remaining in buffer 163 | 164 | m_pBuffer = new uint8_t[eBufSize]; 165 | } 166 | ~CxFileJpg() 167 | { 168 | delete [] m_pBuffer; 169 | } 170 | 171 | static void InitDestination(j_compress_ptr cinfo) 172 | { 173 | CxFileJpg* pDest = (CxFileJpg*)cinfo->dest; 174 | pDest->next_output_byte = pDest->m_pBuffer; 175 | pDest->free_in_buffer = eBufSize; 176 | } 177 | 178 | static boolean EmptyOutputBuffer(j_compress_ptr cinfo) 179 | { 180 | CxFileJpg* pDest = (CxFileJpg*)cinfo->dest; 181 | if (pDest->m_pFile->Write(pDest->m_pBuffer,1,eBufSize)!=(size_t)eBufSize) 182 | ERREXIT(cinfo, JERR_FILE_WRITE); 183 | pDest->next_output_byte = pDest->m_pBuffer; 184 | pDest->free_in_buffer = eBufSize; 185 | return TRUE; 186 | } 187 | 188 | static void TermDestination(j_compress_ptr cinfo) 189 | { 190 | CxFileJpg* pDest = (CxFileJpg*)cinfo->dest; 191 | size_t datacount = eBufSize - pDest->free_in_buffer; 192 | /* Write any data remaining in the buffer */ 193 | if (datacount > 0) { 194 | if (!pDest->m_pFile->Write(pDest->m_pBuffer,1,datacount)) 195 | ERREXIT(cinfo, JERR_FILE_WRITE); 196 | } 197 | pDest->m_pFile->Flush(); 198 | /* Make sure we wrote the output file OK */ 199 | if (pDest->m_pFile->Error()) ERREXIT(cinfo, JERR_FILE_WRITE); 200 | return; 201 | } 202 | 203 | static void InitSource(j_decompress_ptr cinfo) 204 | { 205 | CxFileJpg* pSource = (CxFileJpg*)cinfo->src; 206 | pSource->m_bStartOfFile = TRUE; 207 | } 208 | 209 | static boolean FillInputBuffer(j_decompress_ptr cinfo) 210 | { 211 | size_t nbytes; 212 | CxFileJpg* pSource = (CxFileJpg*)cinfo->src; 213 | nbytes = pSource->m_pFile->Read(pSource->m_pBuffer,1,eBufSize); 214 | if (nbytes <= 0){ 215 | if (pSource->m_bStartOfFile) //* Treat empty input file as fatal error 216 | ERREXIT(cinfo, JERR_INPUT_EMPTY); 217 | WARNMS(cinfo, JWRN_JPEG_EOF); 218 | // Insert a fake EOI marker 219 | pSource->m_pBuffer[0] = (JOCTET) 0xFF; 220 | pSource->m_pBuffer[1] = (JOCTET) JPEG_EOI; 221 | nbytes = 2; 222 | } 223 | pSource->next_input_byte = pSource->m_pBuffer; 224 | pSource->bytes_in_buffer = nbytes; 225 | pSource->m_bStartOfFile = FALSE; 226 | return TRUE; 227 | } 228 | 229 | static void SkipInputData(j_decompress_ptr cinfo, long num_bytes) 230 | { 231 | CxFileJpg* pSource = (CxFileJpg*)cinfo->src; 232 | if (num_bytes > 0){ 233 | while (num_bytes > (int32_t)pSource->bytes_in_buffer){ 234 | num_bytes -= (int32_t)pSource->bytes_in_buffer; 235 | FillInputBuffer(cinfo); 236 | // note we assume that fill_input_buffer will never return FALSE, 237 | // so suspension need not be handled. 238 | } 239 | pSource->next_input_byte += (size_t) num_bytes; 240 | pSource->bytes_in_buffer -= (size_t) num_bytes; 241 | } 242 | } 243 | 244 | static void TermSource(j_decompress_ptr /*cinfo*/) 245 | { 246 | return; 247 | } 248 | protected: 249 | CxFile *m_pFile; 250 | uint8_t *m_pBuffer; 251 | bool m_bStartOfFile; 252 | }; 253 | 254 | public: 255 | enum CODEC_OPTION 256 | { 257 | ENCODE_BASELINE = 0x1, 258 | ENCODE_ARITHMETIC = 0x2, 259 | ENCODE_GRAYSCALE = 0x4, 260 | ENCODE_OPTIMIZE = 0x8, 261 | ENCODE_PROGRESSIVE = 0x10, 262 | ENCODE_LOSSLESS = 0x20, 263 | ENCODE_SMOOTHING = 0x40, 264 | DECODE_GRAYSCALE = 0x80, 265 | DECODE_QUANTIZE = 0x100, 266 | DECODE_DITHER = 0x200, 267 | DECODE_ONEPASS = 0x400, 268 | DECODE_NOSMOOTH = 0x800, 269 | ENCODE_SUBSAMPLE_422 = 0x1000, 270 | ENCODE_SUBSAMPLE_444 = 0x2000 271 | }; 272 | 273 | int32_t m_nPredictor; 274 | int32_t m_nPointTransform; 275 | int32_t m_nSmoothing; 276 | int32_t m_nQuantize; 277 | J_DITHER_MODE m_nDither; 278 | 279 | }; 280 | 281 | #endif 282 | 283 | #endif 284 | -------------------------------------------------------------------------------- /ximalpha.cpp: -------------------------------------------------------------------------------- 1 | // xImalpha.cpp : Alpha channel functions 2 | /* 07/08/2001 v1.00 - Davide Pizzolato - www.xdp.it 3 | * CxImage version 7.0.1 07/Jan/2011 4 | */ 5 | 6 | #include "ximage.h" 7 | 8 | #if CXIMAGE_SUPPORT_ALPHA 9 | 10 | //////////////////////////////////////////////////////////////////////////////// 11 | /** 12 | * \sa AlphaSetMax 13 | */ 14 | uint8_t CxImage::AlphaGetMax() const 15 | { 16 | return info.nAlphaMax; 17 | } 18 | //////////////////////////////////////////////////////////////////////////////// 19 | /** 20 | * Sets global Alpha (opacity) value applied to the whole image, 21 | * valid only for painting functions. 22 | * \param nAlphaMax: can be from 0 to 255 23 | */ 24 | void CxImage::AlphaSetMax(uint8_t nAlphaMax) 25 | { 26 | info.nAlphaMax=nAlphaMax; 27 | } 28 | //////////////////////////////////////////////////////////////////////////////// 29 | /** 30 | * Checks if the image has a valid alpha channel. 31 | */ 32 | bool CxImage::AlphaIsValid() 33 | { 34 | return pAlpha!=0; 35 | } 36 | //////////////////////////////////////////////////////////////////////////////// 37 | /** 38 | * Enables the alpha palette, so the Draw() function changes its behavior. 39 | */ 40 | void CxImage::AlphaPaletteEnable(bool enable) 41 | { 42 | info.bAlphaPaletteEnabled=enable; 43 | } 44 | //////////////////////////////////////////////////////////////////////////////// 45 | /** 46 | * True if the alpha palette is enabled for painting. 47 | */ 48 | bool CxImage::AlphaPaletteIsEnabled() 49 | { 50 | return info.bAlphaPaletteEnabled; 51 | } 52 | //////////////////////////////////////////////////////////////////////////////// 53 | /** 54 | * Sets the alpha channel to full transparent. AlphaSet(0) has the same effect 55 | */ 56 | void CxImage::AlphaClear() 57 | { 58 | if (pAlpha) memset(pAlpha,0,head.biWidth * head.biHeight); 59 | } 60 | //////////////////////////////////////////////////////////////////////////////// 61 | /** 62 | * Sets the alpha level for the whole image. 63 | * \param level : from 0 (transparent) to 255 (opaque) 64 | */ 65 | void CxImage::AlphaSet(uint8_t level) 66 | { 67 | if (pAlpha) memset(pAlpha,level,head.biWidth * head.biHeight); 68 | } 69 | //////////////////////////////////////////////////////////////////////////////// 70 | /** 71 | * Allocates an empty (opaque) alpha channel. 72 | */ 73 | bool CxImage::AlphaCreate() 74 | { 75 | if (pAlpha==NULL) { 76 | pAlpha = (uint8_t*)malloc(head.biWidth * head.biHeight); 77 | if (pAlpha) memset(pAlpha,255,head.biWidth * head.biHeight); 78 | } 79 | return (pAlpha!=0); 80 | } 81 | //////////////////////////////////////////////////////////////////////////////// 82 | void CxImage::AlphaDelete() 83 | { 84 | if (pAlpha) { free(pAlpha); pAlpha=0; } 85 | } 86 | //////////////////////////////////////////////////////////////////////////////// 87 | void CxImage::AlphaInvert() 88 | { 89 | if (pAlpha) { 90 | uint8_t *iSrc=pAlpha; 91 | int32_t n=head.biHeight*head.biWidth; 92 | for(int32_t i=0; i < n; i++){ 93 | *iSrc=(uint8_t)~(*(iSrc)); 94 | iSrc++; 95 | } 96 | } 97 | } 98 | //////////////////////////////////////////////////////////////////////////////// 99 | /** 100 | * Imports an existing alpa channel from another image with the same width and height. 101 | */ 102 | bool CxImage::AlphaCopy(CxImage &from) 103 | { 104 | if (from.pAlpha == NULL || head.biWidth != from.head.biWidth || head.biHeight != from.head.biHeight) return false; 105 | if (pAlpha==NULL) pAlpha = (uint8_t*)malloc(head.biWidth * head.biHeight); 106 | if (pAlpha==NULL) return false; 107 | memcpy(pAlpha,from.pAlpha,head.biWidth * head.biHeight); 108 | info.nAlphaMax=from.info.nAlphaMax; 109 | return true; 110 | } 111 | //////////////////////////////////////////////////////////////////////////////// 112 | /** 113 | * Creates the alpha channel from a gray scale image. 114 | */ 115 | bool CxImage::AlphaSet(CxImage &from) 116 | { 117 | if (!from.IsGrayScale() || head.biWidth != from.head.biWidth || head.biHeight != from.head.biHeight) return false; 118 | if (pAlpha==NULL) pAlpha = (uint8_t*)malloc(head.biWidth * head.biHeight); 119 | uint8_t* src = from.info.pImage; 120 | uint8_t* dst = pAlpha; 121 | if (src==NULL || dst==NULL) return false; 122 | for (int32_t y=0; y>8); 220 | c.rgbGreen = (uint8_t)((c.rgbGreen * a + a1 * info.nBkgndColor.rgbGreen)>>8); 221 | c.rgbRed = (uint8_t)((c.rgbRed * a + a1 * info.nBkgndColor.rgbRed)>>8); 222 | BlindSetPixelColor(x,y,c); 223 | } 224 | } 225 | AlphaDelete(); 226 | } else { 227 | CxImage tmp(head.biWidth,head.biHeight,24); 228 | if (!tmp.IsValid()){ 229 | strcpy(info.szLastError,tmp.GetLastError()); 230 | return; 231 | } 232 | 233 | for(int32_t y=0; y>8); 240 | c.rgbGreen = (uint8_t)((c.rgbGreen * a + a1 * info.nBkgndColor.rgbGreen)>>8); 241 | c.rgbRed = (uint8_t)((c.rgbRed * a + a1 * info.nBkgndColor.rgbRed)>>8); 242 | tmp.BlindSetPixelColor(x,y,c); 243 | } 244 | } 245 | Transfer(tmp); 246 | } 247 | return; 248 | } 249 | //////////////////////////////////////////////////////////////////////////////// 250 | bool CxImage::AlphaFlip() 251 | { 252 | if (!pAlpha) return false; 253 | 254 | uint8_t *buff = (uint8_t*)malloc(head.biWidth); 255 | if (!buff) return false; 256 | 257 | uint8_t *iSrc,*iDst; 258 | iSrc = pAlpha + (head.biHeight-1)*head.biWidth; 259 | iDst = pAlpha; 260 | for (int32_t i=0; i<(head.biHeight/2); ++i) 261 | { 262 | memcpy(buff, iSrc, head.biWidth); 263 | memcpy(iSrc, iDst, head.biWidth); 264 | memcpy(iDst, buff, head.biWidth); 265 | iSrc-=head.biWidth; 266 | iDst+=head.biWidth; 267 | } 268 | 269 | free(buff); 270 | 271 | return true; 272 | } 273 | //////////////////////////////////////////////////////////////////////////////// 274 | bool CxImage::AlphaMirror() 275 | { 276 | if (!pAlpha) return false; 277 | uint8_t* pAlpha2 = (uint8_t*)malloc(head.biWidth * head.biHeight); 278 | if (!pAlpha2) return false; 279 | uint8_t *iSrc,*iDst; 280 | int32_t wdt=head.biWidth-1; 281 | iSrc=pAlpha + wdt; 282 | iDst=pAlpha2; 283 | for(int32_t y=0; y < head.biHeight; y++){ 284 | for(int32_t x=0; x <= wdt; x++) 285 | *(iDst+x)=*(iSrc-x); 286 | iSrc+=head.biWidth; 287 | iDst+=head.biWidth; 288 | } 289 | free(pAlpha); 290 | pAlpha=pAlpha2; 291 | return true; 292 | } 293 | //////////////////////////////////////////////////////////////////////////////// 294 | /** 295 | * Exports the alpha channel in a 8bpp grayscale image. 296 | */ 297 | bool CxImage::AlphaSplit(CxImage *dest) 298 | { 299 | if (!pAlpha || !dest) return false; 300 | 301 | CxImage tmp(head.biWidth,head.biHeight,8); 302 | if (!tmp.IsValid()){ 303 | strcpy(info.szLastError,tmp.GetLastError()); 304 | return false; 305 | } 306 | 307 | uint8_t* src = pAlpha; 308 | uint8_t* dst = tmp.info.pImage; 309 | for (int32_t y=0; yTransfer(tmp); 317 | 318 | return true; 319 | } 320 | //////////////////////////////////////////////////////////////////////////////// 321 | /** 322 | * Exports the alpha palette channel in a 8bpp grayscale image. 323 | */ 324 | bool CxImage::AlphaPaletteSplit(CxImage *dest) 325 | { 326 | if (!AlphaPaletteIsValid() || !dest) return false; 327 | 328 | CxImage tmp(head.biWidth,head.biHeight,8); 329 | if (!tmp.IsValid()){ 330 | strcpy(info.szLastError,tmp.GetLastError()); 331 | return false; 332 | } 333 | 334 | for(int32_t y=0; yTransfer(tmp); 342 | 343 | return true; 344 | } 345 | //////////////////////////////////////////////////////////////////////////////// 346 | /** 347 | * Merge in the alpha layer the transparent color mask 348 | * (previously set with SetTransColor or SetTransIndex) 349 | */ 350 | bool CxImage::AlphaFromTransparency() 351 | { 352 | if (!IsValid() || !IsTransparent()) 353 | return false; 354 | 355 | AlphaCreate(); 356 | 357 | for(int32_t y=0; y info.nNumLayers ) position = info.nNumLayers; 33 | 34 | CxImage** ptmp = new CxImage*[info.nNumLayers + 1]; 35 | if (ptmp==0) return false; 36 | 37 | int32_t i=0; 38 | for (int32_t n=0; ninfo.pParent = this; 49 | } else { 50 | free(ptmp); 51 | return false; 52 | } 53 | 54 | info.nNumLayers++; 55 | delete [] ppLayers; 56 | ppLayers = ptmp; 57 | return true; 58 | } 59 | //////////////////////////////////////////////////////////////////////////////// 60 | /** 61 | * Deletes a layer. If position is less than 0, the last layer will be deleted 62 | */ 63 | bool CxImage::LayerDelete(int32_t position) 64 | { 65 | if ( position >= info.nNumLayers ) return false; 66 | if ( position < 0) position = info.nNumLayers - 1; 67 | if ( position < 0) return false; 68 | 69 | if (info.nNumLayers>1){ 70 | 71 | CxImage** ptmp = new CxImage*[info.nNumLayers - 1]; 72 | if (ptmp==0) return false; 73 | 74 | int32_t i=0; 75 | for (int32_t n=0; n= info.nNumLayers ) return NULL; 112 | if ( position < 0) position = info.nNumLayers - 1; 113 | return ppLayers[position]; 114 | } 115 | //////////////////////////////////////////////////////////////////////////////// 116 | #endif //CXIMAGE_SUPPORT_LAYERS 117 | -------------------------------------------------------------------------------- /ximamng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximamng.h 3 | * Purpose: Declaration of the MNG Image Class 4 | * Author: Davide Pizzolato - www.xdp.it 5 | * Created: 2001 6 | */ 7 | /* ========================================================== 8 | * CxImageMNG (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it 9 | * For conditions of distribution and use, see copyright notice in ximage.h 10 | * 11 | * Special thanks to Frank Haug for suggestions and code. 12 | * 13 | * original mng.cpp code created by Nikolaus Brennig, November 14th, 2000. 14 | * 15 | * LIBMNG Copyright (c) 2000,2001 Gerard Juyn (gerard@libmng.com) 16 | * ========================================================== 17 | */ 18 | 19 | #if !defined(__ximaMNG_h) 20 | #define __ximaMNG_h 21 | 22 | #include "ximage.h" 23 | 24 | #if CXIMAGE_SUPPORT_MNG 25 | 26 | //#define MNG_NO_CMS 27 | #define MNG_SUPPORT_DISPLAY 28 | #define MNG_SUPPORT_READ 29 | #define MNG_SUPPORT_WRITE 30 | #define MNG_ACCESS_CHUNKS 31 | #define MNG_STORE_CHUNKS 32 | 33 | extern "C" { 34 | #include "../mng/libmng.h" 35 | #include "../mng/libmng_data.h" 36 | #include "../mng/libmng_error.h" 37 | } 38 | 39 | //uint32_t _stdcall RunMNGThread(void *lpParam); 40 | 41 | typedef struct tagmngstuff 42 | { 43 | CxFile *file; 44 | uint8_t *image; 45 | uint8_t *alpha; 46 | HANDLE thread; 47 | mng_uint32 delay; 48 | mng_uint32 width; 49 | mng_uint32 height; 50 | mng_uint32 effwdt; 51 | mng_int16 bpp; 52 | mng_bool animation; 53 | mng_bool animation_enabled; 54 | float speed; 55 | int32_t nBkgndIndex; 56 | RGBQUAD nBkgndColor; 57 | } mngstuff; 58 | 59 | class CxImageMNG: public CxImage 60 | { 61 | public: 62 | CxImageMNG(); 63 | ~CxImageMNG(); 64 | 65 | bool Load(const TCHAR * imageFileName); 66 | 67 | bool Decode(CxFile * hFile); 68 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 69 | 70 | #if CXIMAGE_SUPPORT_ENCODE 71 | bool Encode(CxFile * hFile); 72 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 73 | bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_MNG);} 74 | #endif // CXIMAGE_SUPPORT_ENCODE 75 | 76 | int32_t Resume(); 77 | void SetSpeed(float speed); 78 | 79 | mng_handle hmng; 80 | mngstuff mnginfo; 81 | protected: 82 | void WritePNG(mng_handle hMNG, int32_t Frame, int32_t FrameCount ); 83 | void SetCallbacks(mng_handle mng); 84 | }; 85 | 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /ximapcx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximapcx.h 3 | * Purpose: PCX Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImagePCX (c) 05/Jan/2002 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * 9 | * Parts of the code come from Paintlib: Copyright (c) 1996-1998 Ulrich von Zadow 10 | * ========================================================== 11 | */ 12 | #if !defined(__ximaPCX_h) 13 | #define __ximaPCX_h 14 | 15 | #include "ximage.h" 16 | 17 | #if CXIMAGE_SUPPORT_PCX 18 | 19 | class CxImagePCX: public CxImage 20 | { 21 | // PCX Image File 22 | #pragma pack(1) 23 | typedef struct tagPCXHEADER 24 | { 25 | char Manufacturer; // always 0X0A 26 | char Version; // version number 27 | char Encoding; // always 1 28 | char BitsPerPixel; // color bits 29 | uint16_t Xmin, Ymin; // image origin 30 | uint16_t Xmax, Ymax; // image dimensions 31 | uint16_t Hres, Vres; // resolution values 32 | uint8_t ColorMap[16][3]; // color palette 33 | char Reserved; 34 | char ColorPlanes; // color planes 35 | uint16_t BytesPerLine; // line buffer size 36 | uint16_t PaletteType; // grey or color palette 37 | char Filter[58]; 38 | } PCXHEADER; 39 | #pragma pack() 40 | 41 | public: 42 | CxImagePCX(): CxImage(CXIMAGE_FORMAT_PCX) {} 43 | 44 | // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_PCX);} 45 | // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_PCX);} 46 | bool Decode(CxFile * hFile); 47 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 48 | 49 | #if CXIMAGE_SUPPORT_ENCODE 50 | bool Encode(CxFile * hFile); 51 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 52 | #endif // CXIMAGE_SUPPORT_ENCODE 53 | protected: 54 | bool PCX_PlanesToPixels(uint8_t * pixels, uint8_t * bitplanes, int16_t bytesperline, int16_t planes, int16_t bitsperpixel); 55 | bool PCX_UnpackPixels(uint8_t * pixels, uint8_t * bitplanes, int16_t bytesperline, int16_t planes, int16_t bitsperpixel); 56 | void PCX_PackPixels(const int32_t p,uint8_t &c, uint8_t &n, CxFile &f); 57 | void PCX_PackPlanes(uint8_t* buff, const int32_t size, CxFile &f); 58 | void PCX_PixelsToPlanes(uint8_t* raw, int32_t width, uint8_t* buf, int32_t plane); 59 | void PCX_toh(PCXHEADER* p); 60 | }; 61 | 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /ximapng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximapng.h 3 | * Purpose: PNG Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImagePNG (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * 9 | * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes 10 | * 11 | * original CImagePNG and CImageIterator implementation are: 12 | * Copyright: (c) 1995, Alejandro Aguilar Sierra 13 | * 14 | * libpng Copyright (c) 1998-2003 Glenn Randers-Pehrson 15 | * ========================================================== 16 | */ 17 | #if !defined(__ximaPNG_h) 18 | #define __ximaPNG_h 19 | 20 | #include "ximage.h" 21 | 22 | #if CXIMAGE_SUPPORT_PNG 23 | 24 | extern "C" { 25 | #ifdef _LINUX 26 | #undef _DLL 27 | #include 28 | #include 29 | #include 30 | #else 31 | #include "../png/png.h" 32 | #include "../png/pngstruct.h" 33 | #include "../png/pnginfo.h" 34 | #endif 35 | } 36 | 37 | class CxImagePNG: public CxImage 38 | { 39 | public: 40 | CxImagePNG(): CxImage(CXIMAGE_FORMAT_PNG) {} 41 | 42 | // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_PNG);} 43 | // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_PNG);} 44 | bool Decode(CxFile * hFile); 45 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 46 | 47 | #if CXIMAGE_SUPPORT_ENCODE 48 | bool Encode(CxFile * hFile); 49 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 50 | #endif // CXIMAGE_SUPPORT_ENCODE 51 | 52 | enum CODEC_OPTION 53 | { 54 | ENCODE_INTERLACE = 0x01, 55 | // Exclusive compression types : 3 bit wide field 56 | ENCODE_COMPRESSION_MASK = 0x0E, 57 | ENCODE_NO_COMPRESSION = 1 << 1, 58 | ENCODE_BEST_SPEED = 2 << 1, 59 | ENCODE_BEST_COMPRESSION = 3 << 1, 60 | ENCODE_DEFAULT_COMPRESSION = 4 << 1 61 | }; 62 | 63 | protected: 64 | void ima_png_error(png_struct *png_ptr, char *message); 65 | void expand2to4bpp(uint8_t* prow); 66 | 67 | static void PNGAPI user_read_data(png_structp png_ptr, png_bytep data, png_size_t length) 68 | { 69 | CxFile* hFile = (CxFile*)png_get_io_ptr(png_ptr); 70 | if (hFile == NULL || hFile->Read(data,1,length) != length) png_error(png_ptr, "Read Error"); 71 | } 72 | 73 | static void PNGAPI user_write_data(png_structp png_ptr, png_bytep data, png_size_t length) 74 | { 75 | CxFile* hFile = (CxFile*)png_get_io_ptr(png_ptr); 76 | if (hFile == NULL || hFile->Write(data,1,length) != length) png_error(png_ptr, "Write Error"); 77 | } 78 | 79 | static void PNGAPI user_flush_data(png_structp png_ptr) 80 | { 81 | CxFile* hFile = (CxFile*)png_get_io_ptr(png_ptr); 82 | if (hFile == NULL || !hFile->Flush()) png_error(png_ptr, "Flush Error"); 83 | } 84 | 85 | static void PNGAPI user_error_fn(png_structp png_ptr,png_const_charp error_msg) 86 | { 87 | strncpy((char*)png_ptr->error_ptr,error_msg,255); 88 | longjmp(png_ptr->png_jmpbuf, 1); 89 | } 90 | }; 91 | 92 | #endif 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /ximapsd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/movableink/cximage/73a4518e7a3a7fbc2f27c91e5873a56769c8dbf7/ximapsd.cpp -------------------------------------------------------------------------------- /ximapsd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximapsd.h 3 | * Purpose: PSD Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImagePSD (c) Dec/2010 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * 9 | * libpsd (c) 2004-2007 Graphest Software 10 | * 11 | * ========================================================== 12 | */ 13 | #if !defined(__ximaPSD_h) 14 | #define __ximaPSD_h 15 | 16 | #include "ximage.h" 17 | 18 | #if CXIMAGE_SUPPORT_PSD 19 | 20 | #define CXIMAGE_USE_LIBPSD 0 21 | 22 | #if CXIMAGE_USE_LIBPSD 23 | extern "C" { 24 | #include "../libpsd/libpsd.h" 25 | } 26 | #endif 27 | 28 | class CxImagePSD: public CxImage 29 | { 30 | 31 | public: 32 | CxImagePSD(): CxImage(CXIMAGE_FORMAT_PSD) {} 33 | 34 | // bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_PSD);} 35 | // bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_PSD);} 36 | bool Decode(CxFile * hFile); 37 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 38 | 39 | //#if CXIMAGE_SUPPORT_EXIF 40 | // bool GetExifThumbnail(const TCHAR *filename, const TCHAR *outname, int32_t type); 41 | //#endif //CXIMAGE_SUPPORT_EXIF 42 | 43 | #if CXIMAGE_SUPPORT_ENCODE 44 | bool Encode(CxFile * hFile); 45 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 46 | #endif // CXIMAGE_SUPPORT_ENCODE 47 | 48 | #if CXIMAGE_USE_LIBPSD 49 | protected: 50 | class CxFilePsd 51 | { 52 | public: 53 | CxFilePsd(CxFile* pFile,psd_context *context) 54 | { 55 | context->file = pFile; 56 | 57 | psd_CxFile_ops.size_ = psd_file_size; 58 | psd_CxFile_ops.seek_ = psd_file_seek; 59 | psd_CxFile_ops.read_ = psd_file_read; 60 | // psd_CxFile_ops.write_ = psd_file_write; 61 | // psd_CxFile_ops.close_ = psd_file_close; 62 | // psd_CxFile_ops.gets_ = psd_file_gets; 63 | // psd_CxFile_ops.eof_ = psd_file_eof; 64 | // psd_CxFile_ops.tell_ = psd_file_tell; 65 | // psd_CxFile_ops.getc_ = psd_file_getc; 66 | // psd_CxFile_ops.scanf_ = psd_file_scanf; 67 | 68 | context->ops_ = &psd_CxFile_ops; 69 | 70 | } 71 | 72 | static int32_t psd_file_size(psd_file_obj *obj) 73 | { return ((CxFile*)obj)->Size(); } 74 | 75 | static int32_t psd_file_seek(psd_file_obj *obj, int32_t offset, int32_t origin) 76 | { return ((CxFile*)obj)->Seek(offset,origin); } 77 | 78 | static int32_t psd_file_read(psd_file_obj *obj, void *buf, int32_t size, int32_t cnt) 79 | { return ((CxFile*)obj)->Read(buf,size,cnt); } 80 | 81 | // static int32_t psd_file_write(psd_file_obj *obj, void *buf, int32_t size, int32_t cnt) 82 | // { return ((CxFile*)obj)->Write(buf,size,cnt); } 83 | 84 | // static int32_t psd_file_close(psd_file_obj *obj) 85 | // { return 1; /*((CxFile*)obj)->Close();*/ } 86 | 87 | // static char* psd_file_gets(psd_file_obj *obj, char *string, int32_t n) 88 | // { return ((CxFile*)obj)->GetS(string,n); } 89 | 90 | // static int32_t psd_file_eof(psd_file_obj *obj) 91 | // { return ((CxFile*)obj)->Eof(); } 92 | 93 | // static long psd_file_tell(psd_file_obj *obj) 94 | // { return ((CxFile*)obj)->Tell(); } 95 | 96 | // static int32_t psd_file_getc(psd_file_obj *obj) 97 | // { return ((CxFile*)obj)->GetC(); } 98 | 99 | // static int32_t psd_file_scanf(psd_file_obj *obj,const char *format, void* output) 100 | // { return ((CxFile*)obj)->Scanf(format, output); } 101 | 102 | private: 103 | psd_file_ops psd_CxFile_ops; 104 | }; 105 | #endif //CXIMAGE_USE_LIBPSD 106 | }; 107 | 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /ximaraw.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximaraw.cpp 3 | * Purpose: Platform Independent RAW Image Class Loader 4 | * 16/Dec/2007 Davide Pizzolato - www.xdp.it 5 | * CxImage version 7.0.1 07/Jan/2011 6 | * 7 | * CxImageRAW (c) May/2006 pdw63 8 | * 9 | * based on dcraw.c -- Dave Coffin's raw photo decoder 10 | * Copyright 1997-2007 by Dave Coffin, dcoffin a cybercom o net 11 | */ 12 | 13 | #include "ximaraw.h" 14 | 15 | #if CXIMAGE_SUPPORT_RAW 16 | 17 | //////////////////////////////////////////////////////////////////////////////// 18 | #if CXIMAGE_SUPPORT_DECODE 19 | //////////////////////////////////////////////////////////////////////////////// 20 | bool CxImageRAW::Decode(CxFile *hFile) 21 | { 22 | if (hFile==NULL) 23 | return false; 24 | 25 | DCRAW dcr; 26 | 27 | cx_try 28 | { 29 | // initialization 30 | dcr_init_dcraw(&dcr); 31 | 32 | dcr.opt.user_qual = GetCodecOption(CXIMAGE_FORMAT_RAW) & 0x03; 33 | 34 | // setup variables for debugging 35 | char szClass[] = "CxImageRAW"; 36 | dcr.ifname = szClass; 37 | dcr.sz_error = info.szLastError; 38 | 39 | // setup library options, see dcr_print_manual for the available switches 40 | // call dcr_parse_command_line_options(&dcr,0,0,0) to set default options 41 | // if (dcr_parse_command_line_options(&dcr,argc,argv,&arg)) 42 | if (dcr_parse_command_line_options(&dcr,0,0,0)){ 43 | cx_throw("CxImageRAW: unknown option"); 44 | } 45 | 46 | // set return point for error handling 47 | if (setjmp (dcr.failure)) { 48 | cx_throw(""); 49 | } 50 | 51 | // install file manager 52 | CxFileRaw src(hFile,&dcr); 53 | 54 | // check file header 55 | dcr_identify(&dcr); 56 | 57 | if(!dcr.is_raw){ 58 | cx_throw("CxImageRAW: not a raw image"); 59 | } 60 | 61 | if (dcr.load_raw == NULL) { 62 | cx_throw("CxImageRAW: missing raw decoder"); 63 | } 64 | 65 | // verify special case 66 | if (dcr.load_raw == dcr_kodak_ycbcr_load_raw) { 67 | dcr.height += dcr.height & 1; 68 | dcr.width += dcr.width & 1; 69 | } 70 | 71 | if (info.nEscape == -1){ 72 | head.biWidth = dcr.width; 73 | head.biHeight= dcr.height; 74 | info.dwType = CXIMAGE_FORMAT_RAW; 75 | cx_throw("output dimensions returned"); 76 | } 77 | 78 | // shrinked decoding available and requested? 79 | dcr.shrink = dcr.filters && (dcr.opt.half_size || dcr.opt.threshold || dcr.opt.aber[0] != 1 || dcr.opt.aber[2] != 1); 80 | dcr.iheight = (dcr.height + dcr.shrink) >> dcr.shrink; 81 | dcr.iwidth = (dcr.width + dcr.shrink) >> dcr.shrink; 82 | 83 | // install custom camera matrix 84 | if (dcr.opt.use_camera_matrix && dcr.cmatrix[0][0] > 0.25) { 85 | memcpy (dcr.rgb_cam, dcr.cmatrix, sizeof dcr.cmatrix); 86 | dcr.raw_color = 0; 87 | } else { 88 | dcr.opt.use_camera_wb = 1; 89 | } 90 | 91 | // allocate memory for the image 92 | dcr.image = (ushort (*)[4]) calloc (dcr.iheight*dcr.iwidth, sizeof *dcr.image); 93 | dcr_merror (&dcr, dcr.image, szClass); 94 | 95 | if (dcr.meta_length) { 96 | dcr.meta_data = (char *) malloc (dcr.meta_length); 97 | dcr_merror (&dcr, dcr.meta_data, szClass); 98 | } 99 | 100 | // start image decoder 101 | hFile->Seek(dcr.data_offset, SEEK_SET); 102 | (*dcr.load_raw)(&dcr); 103 | 104 | // post processing 105 | if (dcr.zero_is_bad) dcr_remove_zeroes(&dcr); 106 | 107 | dcr_bad_pixels(&dcr,dcr.opt.bpfile); 108 | 109 | if (dcr.opt.dark_frame) dcr_subtract (&dcr,dcr.opt.dark_frame); 110 | 111 | dcr.quality = 2 + !dcr.fuji_width; 112 | 113 | if (dcr.opt.user_qual >= 0) dcr.quality = dcr.opt.user_qual; 114 | 115 | if (dcr.opt.user_black >= 0) dcr.black = dcr.opt.user_black; 116 | 117 | if (dcr.opt.user_sat >= 0) dcr.maximum = dcr.opt.user_sat; 118 | 119 | #ifdef COLORCHECK 120 | dcr_colorcheck(&dcr); 121 | #endif 122 | 123 | #if RESTRICTED 124 | if (dcr.is_foveon && !dcr.opt.document_mode) dcr_foveon_interpolate(&dcr); 125 | #endif 126 | 127 | if (!dcr.is_foveon && dcr.opt.document_mode < 2) dcr_scale_colors(&dcr); 128 | 129 | // pixel interpolation and filters 130 | dcr_pre_interpolate(&dcr); 131 | 132 | if (dcr.filters && !dcr.opt.document_mode) { 133 | if (dcr.quality == 0) 134 | dcr_lin_interpolate(&dcr); 135 | else if (dcr.quality == 1 || dcr.colors > 3) 136 | dcr_vng_interpolate(&dcr); 137 | else if (dcr.quality == 2) 138 | dcr_ppg_interpolate(&dcr); 139 | else 140 | dcr_ahd_interpolate(&dcr); 141 | } 142 | 143 | if (dcr.mix_green) { 144 | int32_t i; 145 | for (dcr.colors=3, i=0; i < dcr.height*dcr.width; i++) { 146 | dcr.image[i][1] = (dcr.image[i][1] + dcr.image[i][3]) >> 1; 147 | } 148 | } 149 | 150 | if (!dcr.is_foveon && dcr.colors == 3) dcr_median_filter(&dcr); 151 | 152 | if (!dcr.is_foveon && dcr.opt.highlight == 2) dcr_blend_highlights(&dcr); 153 | 154 | if (!dcr.is_foveon && dcr.opt.highlight > 2) dcr_recover_highlights(&dcr); 155 | 156 | if (dcr.opt.use_fuji_rotate) dcr_fuji_rotate(&dcr); 157 | 158 | #ifndef NO_LCMS 159 | if (dcr.opt.cam_profile) dcr_apply_profile (dcr.opt.cam_profile, dcr.opt.out_profile); 160 | #endif 161 | 162 | // final conversion 163 | dcr_convert_to_rgb(&dcr); 164 | 165 | if (dcr.opt.use_fuji_rotate) dcr_stretch(&dcr); 166 | 167 | dcr.iheight = dcr.height; 168 | dcr.iwidth = dcr.width; 169 | if (dcr.flip & 4) SWAP(dcr.height,dcr.width); 170 | 171 | // ready to transfer data from dcr.image 172 | if (!Create(dcr.width,dcr.height,24,CXIMAGE_FORMAT_RAW)){ 173 | cx_throw(""); 174 | } 175 | 176 | uchar *ppm = (uchar *) calloc (dcr.width, dcr.colors*dcr.opt.output_bps/8); 177 | ushort *ppm2 = (ushort *) ppm; 178 | dcr_merror (&dcr, ppm, szClass); 179 | 180 | uchar lut[0x10000]; 181 | if (dcr.opt.output_bps == 8) dcr_gamma_lut (&dcr, lut); 182 | 183 | int32_t c, row, col, soff, rstep, cstep; 184 | soff = dcr_flip_index (&dcr, 0, 0); 185 | cstep = dcr_flip_index (&dcr, 0, 1) - soff; 186 | rstep = dcr_flip_index (&dcr, 1, 0) - dcr_flip_index (&dcr, 0, dcr.width); 187 | for (row=0; row < dcr.height; row++, soff += rstep) { 188 | for (col=0; col < dcr.width; col++, soff += cstep) { 189 | if (dcr.opt.output_bps == 8) 190 | for (c=0; c < dcr.colors; c++) ppm [col*dcr.colors+c] = lut[dcr.image[soff][c]]; 191 | else 192 | for (c=0; c < dcr.colors; c++) ppm2[col*dcr.colors+c] = dcr.image[soff][c]; 193 | } 194 | if (dcr.opt.output_bps == 16 && !dcr.opt.output_tiff && htons(0x55aa) != 0x55aa) 195 | #if defined(_LINUX) || defined(__APPLE__) 196 | swab ((char*)ppm2, (char*)ppm2, dcr.width*dcr.colors*2); 197 | #else 198 | _swab ((char*)ppm2, (char*)ppm2, dcr.width*dcr.colors*2); 199 | #endif 200 | 201 | uint32_t size = dcr.width * (dcr.colors*dcr.opt.output_bps/8); 202 | RGBtoBGR(ppm,size); 203 | memcpy(GetBits(dcr.height - 1 - row), ppm, min(size,GetEffWidth())); 204 | } 205 | free (ppm); 206 | 207 | 208 | dcr_cleanup_dcraw(&dcr); 209 | 210 | } cx_catch { 211 | 212 | dcr_cleanup_dcraw(&dcr); 213 | 214 | if (strcmp(message,"")) strncpy(info.szLastError,message,255); 215 | if (info.nEscape == -1 && info.dwType == CXIMAGE_FORMAT_RAW) return true; 216 | return false; 217 | } 218 | /* that's it */ 219 | return true; 220 | } 221 | 222 | #if CXIMAGE_SUPPORT_EXIF 223 | bool CxImageRAW::GetExifThumbnail(const TCHAR *filename, const TCHAR *outname, int32_t type) 224 | { 225 | DCRAW dcr; 226 | 227 | CxIOFile file; 228 | if (!file.Open(filename, _T("rb"))) 229 | return false; 230 | 231 | cx_try 232 | { 233 | // initialization 234 | dcr_init_dcraw(&dcr); 235 | 236 | dcr.opt.user_qual = GetCodecOption(CXIMAGE_FORMAT_RAW) & 0x03; 237 | 238 | // setup variables for debugging 239 | char szClass[] = "CxImageRAW"; 240 | dcr.ifname = szClass; 241 | dcr.sz_error = info.szLastError; 242 | 243 | // setup library options, see dcr_print_manual for the available switches 244 | // call dcr_parse_command_line_options(&dcr,0,0,0) to set default options 245 | // if (dcr_parse_command_line_options(&dcr,argc,argv,&arg)) 246 | if (dcr_parse_command_line_options(&dcr,0,0,0)){ 247 | cx_throw("CxImageRAW: unknown option"); 248 | } 249 | 250 | // set return point for error handling 251 | if (setjmp (dcr.failure)) { 252 | cx_throw(""); 253 | } 254 | 255 | // install file manager 256 | CxFileRaw src(&file,&dcr); 257 | 258 | // check file header 259 | dcr_identify(&dcr); 260 | 261 | if(!dcr.is_raw){ 262 | cx_throw("CxImageRAW: not a raw image"); 263 | } 264 | 265 | if (dcr.load_raw == NULL) { 266 | cx_throw("CxImageRAW: missing raw decoder"); 267 | } 268 | 269 | // THUMB. 270 | if (dcr.thumb_offset != 0) 271 | { 272 | FILE* file = _tfopen(outname, _T("wb")); 273 | DCRAW* p = &dcr; 274 | dcr_fseek(dcr.obj_, dcr.thumb_offset, SEEK_SET); 275 | dcr.write_thumb(&dcr, file); 276 | fclose(file); 277 | 278 | // Read in the thumbnail to resize and rotate. 279 | CxImage image(outname, CXIMAGE_FORMAT_UNKNOWN); 280 | if (image.IsValid()) 281 | { 282 | #if CXIMAGE_SUPPORT_TRANSFORMATION 283 | // Resizing. 284 | if (image.GetWidth() > 256 || image.GetHeight() > 256) 285 | { 286 | float amount = 256.0f / max(image.GetWidth(), image.GetHeight()); 287 | image.Resample((int32_t)(image.GetWidth() * amount), (int32_t)(image.GetHeight() * amount), 0); 288 | } 289 | // Rotation. 290 | if (p->flip != 0) 291 | image.RotateExif(p->flip); 292 | #endif 293 | #if CXIMAGE_SUPPORT_ENCODE && CXIMAGE_SUPPORT_JPG 294 | return image.Save(outname, CXIMAGE_FORMAT_JPG); 295 | #endif 296 | } 297 | } 298 | else 299 | { 300 | cx_throw("No thumbnail!"); 301 | } 302 | 303 | dcr_cleanup_dcraw(&dcr); 304 | 305 | } cx_catch { 306 | 307 | dcr_cleanup_dcraw(&dcr); 308 | 309 | if (strcmp(message,"")) strncpy(info.szLastError,message,255); 310 | if (info.nEscape == -1 && info.dwType == CXIMAGE_FORMAT_RAW) return true; 311 | return false; 312 | } 313 | /* that's it */ 314 | return true; 315 | } 316 | #endif //CXIMAGE_SUPPORT_EXIF 317 | 318 | //////////////////////////////////////////////////////////////////////////////// 319 | #endif //CXIMAGE_SUPPORT_DECODE 320 | //////////////////////////////////////////////////////////////////////////////// 321 | #if CXIMAGE_SUPPORT_ENCODE 322 | //////////////////////////////////////////////////////////////////////////////// 323 | bool CxImageRAW::Encode(CxFile * hFile) 324 | { 325 | if (hFile == NULL) return false; 326 | strcpy(info.szLastError, "Save RAW not supported"); 327 | return false; 328 | } 329 | //////////////////////////////////////////////////////////////////////////////// 330 | #endif // CXIMAGE_SUPPORT_ENCODE 331 | //////////////////////////////////////////////////////////////////////////////// 332 | #endif // CXIMAGE_SUPPORT_RAW 333 | 334 | -------------------------------------------------------------------------------- /ximaraw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximaraw.h 3 | * Purpose: RAW Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageRAW (c) May/2006 pdw63 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * Special thanks to David Coffin for dcraw without which this class would not exist 9 | * 10 | * libdcr (c) Dec/2007 Davide Pizzolato - www.xdp.it 11 | * 12 | * based on dcraw.c -- Dave Coffin's raw photo decoder 13 | * Copyright 1997-2007 by Dave Coffin, dcoffin a cybercom o net 14 | * ========================================================== 15 | */ 16 | #if !defined(__ximaRAW_h) 17 | #define __ximaRAW_h 18 | 19 | #include "ximage.h" 20 | 21 | #if CXIMAGE_SUPPORT_RAW 22 | 23 | extern "C" { 24 | #include "../raw/libdcr.h" 25 | } 26 | 27 | class CxImageRAW: public CxImage 28 | { 29 | 30 | public: 31 | CxImageRAW(): CxImage(CXIMAGE_FORMAT_RAW) {} 32 | 33 | // bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_ICO);} 34 | // bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_ICO);} 35 | bool Decode(CxFile * hFile); 36 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 37 | 38 | #if CXIMAGE_SUPPORT_EXIF 39 | bool GetExifThumbnail(const TCHAR *filename, const TCHAR *outname, int32_t type); 40 | #endif //CXIMAGE_SUPPORT_EXIF 41 | 42 | #if CXIMAGE_SUPPORT_ENCODE 43 | bool Encode(CxFile * hFile); 44 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 45 | #endif // CXIMAGE_SUPPORT_ENCODE 46 | 47 | enum CODEC_OPTION 48 | { 49 | DECODE_QUALITY_LIN = 0x00, 50 | DECODE_QUALITY_VNG = 0x01, 51 | DECODE_QUALITY_PPG = 0x02, 52 | DECODE_QUALITY_AHD = 0x03, 53 | }; 54 | 55 | protected: 56 | 57 | class CxFileRaw 58 | { 59 | public: 60 | CxFileRaw(CxFile* pFile,DCRAW *stream) 61 | { 62 | stream->obj_ = pFile; 63 | 64 | ras_stream_CxFile.read_ = raw_sfile_read; 65 | ras_stream_CxFile.write_ = raw_sfile_write; 66 | ras_stream_CxFile.seek_ = raw_sfile_seek; 67 | ras_stream_CxFile.close_ = raw_sfile_close; 68 | ras_stream_CxFile.gets_ = raw_sfile_gets; 69 | ras_stream_CxFile.eof_ = raw_sfile_eof; 70 | ras_stream_CxFile.tell_ = raw_sfile_tell; 71 | ras_stream_CxFile.getc_ = raw_sfile_getc; 72 | ras_stream_CxFile.scanf_ = raw_sfile_scanf; 73 | 74 | stream->ops_ = &ras_stream_CxFile; 75 | 76 | } 77 | 78 | static int32_t raw_sfile_read(dcr_stream_obj *obj, void *buf, int32_t size, int32_t cnt) 79 | { return ((CxFile*)obj)->Read(buf,size,cnt); } 80 | 81 | static int32_t raw_sfile_write(dcr_stream_obj *obj, void *buf, int32_t size, int32_t cnt) 82 | { return ((CxFile*)obj)->Write(buf,size,cnt); } 83 | 84 | static long raw_sfile_seek(dcr_stream_obj *obj, long offset, int32_t origin) 85 | { return ((CxFile*)obj)->Seek(offset,origin); } 86 | 87 | static int32_t raw_sfile_close(dcr_stream_obj *obj) 88 | { return 1; /*((CxFile*)obj)->Close();*/ } 89 | 90 | static char* raw_sfile_gets(dcr_stream_obj *obj, char *string, int32_t n) 91 | { return ((CxFile*)obj)->GetS(string,n); } 92 | 93 | static int32_t raw_sfile_eof(dcr_stream_obj *obj) 94 | { return ((CxFile*)obj)->Eof(); } 95 | 96 | static long raw_sfile_tell(dcr_stream_obj *obj) 97 | { return ((CxFile*)obj)->Tell(); } 98 | 99 | static int32_t raw_sfile_getc(dcr_stream_obj *obj) 100 | { return ((CxFile*)obj)->GetC(); } 101 | 102 | static int32_t raw_sfile_scanf(dcr_stream_obj *obj,const char *format, void* output) 103 | { return ((CxFile*)obj)->Scanf(format, output); } 104 | 105 | private: 106 | dcr_stream_ops ras_stream_CxFile; 107 | }; 108 | }; 109 | 110 | #endif 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /ximaska.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximaska.cpp 3 | * Purpose: Platform Independent SKA Image Class Loader and Writer 4 | * 25/Sep/2007 Davide Pizzolato - www.xdp.it 5 | * CxImage version 7.0.1 07/Jan/2011 6 | */ 7 | 8 | #include "ximaska.h" 9 | 10 | #if CXIMAGE_SUPPORT_SKA 11 | 12 | //////////////////////////////////////////////////////////////////////////////// 13 | #if CXIMAGE_SUPPORT_DECODE 14 | //////////////////////////////////////////////////////////////////////////////// 15 | bool CxImageSKA::Decode(CxFile *hFile) 16 | { 17 | if (hFile==NULL) 18 | return false; 19 | 20 | // read the header 21 | SKAHEADER ska_header; 22 | hFile->Read(&ska_header,sizeof(SKAHEADER),1); 23 | 24 | ska_header.Width = m_ntohs(ska_header.Width); 25 | ska_header.Height = m_ntohs(ska_header.Height); 26 | ska_header.dwUnknown = m_ntohl(ska_header.dwUnknown); 27 | 28 | // check header 29 | if (ska_header.dwUnknown != 0x01000000 || 30 | ska_header.Width > 0x7FFF || ska_header.Height > 0x7FFF || 31 | ska_header.BppExp != 3) 32 | return false; 33 | 34 | if (info.nEscape == -1){ 35 | head.biWidth = ska_header.Width ; 36 | head.biHeight= ska_header.Height; 37 | info.dwType = CXIMAGE_FORMAT_SKA; 38 | return true; 39 | } 40 | 41 | int32_t bpp = 1<Read(ppal,nColors*sizeof(rgb_color),1); 52 | SetPalette(ppal,nColors); 53 | free(ppal); 54 | 55 | //read the image 56 | hFile->Read(GetBits(),ska_header.Width*ska_header.Height,1); 57 | 58 | //reorder rows 59 | if (GetEffWidth() != ska_header.Width){ 60 | uint8_t *src,*dst; 61 | src = GetBits() + ska_header.Width*(ska_header.Height-1); 62 | dst = GetBits(ska_header.Height-1); 63 | for(int32_t y=0;y 8) { 84 | strcpy(info.szLastError,"SKA Images must be 8 bit or less"); 85 | return false; 86 | } 87 | 88 | SKAHEADER ska_header; 89 | 90 | ska_header.Width = (uint16_t)GetWidth(); 91 | ska_header.Height = (uint16_t)GetHeight(); 92 | ska_header.BppExp = 3; 93 | ska_header.dwUnknown = 0x01000000; 94 | 95 | ska_header.Width = m_ntohs(ska_header.Width); 96 | ska_header.Height = m_ntohs(ska_header.Height); 97 | ska_header.dwUnknown = m_ntohl(ska_header.dwUnknown); 98 | 99 | hFile->Write(&ska_header,sizeof(SKAHEADER),1); 100 | 101 | ska_header.Width = m_ntohs(ska_header.Width); 102 | ska_header.Height = m_ntohs(ska_header.Height); 103 | ska_header.dwUnknown = m_ntohl(ska_header.dwUnknown); 104 | 105 | if (head.biBitCount<8) IncreaseBpp(8); 106 | 107 | rgb_color pal[256]; 108 | for(int32_t idx=0; idx<256; idx++){ 109 | GetPaletteColor(idx,&(pal[idx].r),&(pal[idx].g),&(pal[idx].b)); 110 | } 111 | 112 | hFile->Write(pal,256*sizeof(rgb_color),1); 113 | 114 | uint8_t* src = GetBits(ska_header.Height-1); 115 | for(int32_t y=0;yWrite(src,ska_header.Width,1); 117 | src -= GetEffWidth(); 118 | } 119 | 120 | return true; 121 | } 122 | //////////////////////////////////////////////////////////////////////////////// 123 | #endif // CXIMAGE_SUPPORT_ENCODE 124 | //////////////////////////////////////////////////////////////////////////////// 125 | #endif // CXIMAGE_SUPPORT_SKA 126 | 127 | -------------------------------------------------------------------------------- /ximaska.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximaska.h 3 | * Purpose: SKA Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageSKA (c) 25/Sep/2007 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * ========================================================== 9 | */ 10 | #if !defined(__ximaSKA_h) 11 | #define __ximaSKA_h 12 | 13 | #include "ximage.h" 14 | 15 | #if CXIMAGE_SUPPORT_SKA 16 | 17 | class CxImageSKA: public CxImage 18 | { 19 | #pragma pack(1) 20 | typedef struct tagSkaHeader { 21 | uint16_t Width; 22 | uint16_t Height; 23 | uint8_t BppExp; 24 | uint32_t dwUnknown; 25 | } SKAHEADER; 26 | #pragma pack() 27 | 28 | public: 29 | CxImageSKA(): CxImage(CXIMAGE_FORMAT_SKA) {} 30 | 31 | // bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_ICO);} 32 | // bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_ICO);} 33 | bool Decode(CxFile * hFile); 34 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 35 | 36 | #if CXIMAGE_SUPPORT_ENCODE 37 | bool Encode(CxFile * hFile); 38 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 39 | #endif // CXIMAGE_SUPPORT_ENCODE 40 | }; 41 | 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /ximatga.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximatga.cpp 3 | * Purpose: Platform Independent TGA Image Class Loader and Writer 4 | * 05/Jan/2001 Davide Pizzolato - www.xdp.it 5 | * CxImage version 7.0.1 07/Jan/2011 6 | */ 7 | 8 | #include "ximatga.h" 9 | 10 | #if CXIMAGE_SUPPORT_TGA 11 | 12 | #include "ximaiter.h" 13 | 14 | // Definitions for image types. 15 | #define TGA_Null 0 16 | #define TGA_Map 1 17 | #define TGA_RGB 2 18 | #define TGA_Mono 3 19 | #define TGA_RLEMap 9 20 | #define TGA_RLERGB 10 21 | #define TGA_RLEMono 11 22 | #define TGA_CompMap 32 23 | #define TGA_CompMap4 33 24 | 25 | //////////////////////////////////////////////////////////////////////////////// 26 | #if CXIMAGE_SUPPORT_DECODE 27 | //////////////////////////////////////////////////////////////////////////////// 28 | bool CxImageTGA::Decode(CxFile *hFile) 29 | { 30 | if (hFile == NULL) return false; 31 | 32 | TGAHEADER tgaHead; 33 | 34 | cx_try 35 | { 36 | if (hFile->Read(&tgaHead,sizeof(tgaHead),1)==0) 37 | cx_throw("Not a TGA"); 38 | 39 | tga_toh(&tgaHead); 40 | 41 | bool bCompressed; 42 | switch (tgaHead.ImageType){ 43 | case TGA_Map: 44 | case TGA_RGB: 45 | case TGA_Mono: 46 | bCompressed = false; 47 | break; 48 | case TGA_RLEMap: 49 | case TGA_RLERGB: 50 | case TGA_RLEMono: 51 | bCompressed = true; 52 | break; 53 | default: 54 | cx_throw("Unknown TGA image type"); 55 | } 56 | 57 | if (tgaHead.ImageWidth==0 || tgaHead.ImageHeight==0 || tgaHead.PixelDepth==0 || tgaHead.CmapLength>256) 58 | cx_throw("bad TGA header"); 59 | 60 | if (tgaHead.PixelDepth!=8 && tgaHead.PixelDepth!=15 && tgaHead.PixelDepth!=16 && tgaHead.PixelDepth!=24 && tgaHead.PixelDepth!=32) 61 | cx_throw("bad TGA header"); 62 | 63 | if (info.nEscape == -1){ 64 | head.biWidth = tgaHead.ImageWidth ; 65 | head.biHeight= tgaHead.ImageHeight; 66 | info.dwType = CXIMAGE_FORMAT_TGA; 67 | return true; 68 | } 69 | 70 | if (tgaHead.IdLength>0) hFile->Seek(tgaHead.IdLength,SEEK_CUR); //skip descriptor 71 | 72 | Create(tgaHead.ImageWidth, tgaHead.ImageHeight, tgaHead.PixelDepth, CXIMAGE_FORMAT_TGA); 73 | #if CXIMAGE_SUPPORT_ALPHA // 74 | if (tgaHead.PixelDepth==32) AlphaCreate(); // Image has alpha channel 75 | #endif //CXIMAGE_SUPPORT_ALPHA 76 | 77 | if (!IsValid()) cx_throw("TGA Create failed"); 78 | 79 | if (info.nEscape) cx_throw("Cancelled"); // - cancel decoding 80 | 81 | if (tgaHead.CmapType != 0){ // read the palette 82 | rgb_color pal[256]; 83 | hFile->Read(pal,tgaHead.CmapLength*sizeof(rgb_color), 1); 84 | for (int32_t i=0;i - cancel decoding 100 | 101 | if (hFile == NULL || hFile->Eof()) cx_throw("corrupted TGA"); 102 | 103 | if (bYReversed) pDest = iter.GetRow(tgaHead.ImageHeight-y-1); 104 | else pDest = iter.GetRow(y); 105 | 106 | if (bCompressed) rleLeftover = ExpandCompressedLine(pDest,&tgaHead,hFile,tgaHead.ImageWidth,y,rleLeftover); 107 | else ExpandUncompressedLine (pDest,&tgaHead,hFile,tgaHead.ImageWidth,y,0); 108 | } 109 | 110 | if (bXReversed) Mirror(); 111 | 112 | #if CXIMAGE_SUPPORT_ALPHA 113 | if (bYReversed && tgaHead.PixelDepth==32) AlphaFlip(); // 114 | #endif //CXIMAGE_SUPPORT_ALPHA 115 | 116 | } cx_catch { 117 | if (strcmp(message,"")) strncpy(info.szLastError,message,255); 118 | return false; 119 | } 120 | return true; 121 | } 122 | //////////////////////////////////////////////////////////////////////////////// 123 | #endif //CXIMAGE_SUPPORT_DECODE 124 | //////////////////////////////////////////////////////////////////////////////// 125 | #if CXIMAGE_SUPPORT_ENCODE 126 | //////////////////////////////////////////////////////////////////////////////// 127 | bool CxImageTGA::Encode(CxFile * hFile) 128 | { 129 | if (EncodeSafeCheck(hFile)) return false; 130 | 131 | if (head.biBitCount<8){ 132 | strcpy(info.szLastError,"Bit depth must be 8 or 24"); 133 | return false; 134 | } 135 | 136 | TGAHEADER tgaHead; 137 | 138 | tgaHead.IdLength = 0; // Image ID Field Length 139 | tgaHead.CmapType = GetPalette()!=0; // Color Map Type 140 | tgaHead.ImageType = (head.biBitCount == 8) ? (uint8_t)TGA_Map : (uint8_t)TGA_RGB; // Image Type 141 | 142 | tgaHead.CmapIndex=0; // First Entry Index 143 | tgaHead.CmapLength=(head.biBitCount == 8) ? 256 : 0; // Color Map Length 144 | tgaHead.CmapEntrySize=(head.biBitCount == 8) ? (uint8_t)24 : (uint8_t)0; // Color Map Entry Size 145 | 146 | tgaHead.X_Origin=0; // X-origin of Image 147 | tgaHead.Y_Origin=0; // Y-origin of Image 148 | tgaHead.ImageWidth=(uint16_t)head.biWidth; // Image Width 149 | tgaHead.ImageHeight=(uint16_t)head.biHeight; // Image Height 150 | tgaHead.PixelDepth=(uint8_t)head.biBitCount; // Pixel Depth 151 | tgaHead.ImagDesc=0; // Image Descriptor 152 | 153 | if (pAlpha && head.biBitCount==24) tgaHead.PixelDepth=32; 154 | 155 | tga_toh(&tgaHead); 156 | hFile->Write(&tgaHead,sizeof(TGAHEADER),1); 157 | tga_toh(&tgaHead); 158 | 159 | if (head.biBitCount==8){ 160 | rgb_color pal[256]; 161 | RGBQUAD* ppal = GetPalette(); 162 | for (int32_t i=0;i<256; i++){ 163 | pal[i].r = ppal[i].rgbBlue; 164 | pal[i].g = ppal[i].rgbGreen; 165 | pal[i].b = ppal[i].rgbRed; 166 | } 167 | hFile->Write(&pal,256*sizeof(rgb_color),1); 168 | } 169 | 170 | CImageIterator iter(this); 171 | uint8_t* pDest; 172 | if (pAlpha==0 || head.biBitCount==8){ 173 | for (int32_t y=0; y < tgaHead.ImageHeight; y++){ 174 | pDest = iter.GetRow(y); 175 | hFile->Write(pDest,tgaHead.ImageWidth * (head.biBitCount >> 3),1); 176 | } 177 | } else { 178 | pDest = (uint8_t*)malloc(4*tgaHead.ImageWidth); 179 | RGBQUAD c; 180 | for (int32_t y=0; y < tgaHead.ImageHeight; y++){ 181 | for(int32_t x=0, x4=0;x 187 | pDest[x4+3]=AlphaGet(x,y); 188 | #else 189 | pDest[x4+3]=0; 190 | #endif //CXIMAGE_SUPPORT_ALPHA 191 | } 192 | hFile->Write(pDest,4*tgaHead.ImageWidth,1); 193 | } 194 | free(pDest); 195 | } 196 | return true; 197 | } 198 | //////////////////////////////////////////////////////////////////////////////// 199 | #endif // CXIMAGE_SUPPORT_ENCODE 200 | //////////////////////////////////////////////////////////////////////////////// 201 | uint8_t CxImageTGA::ExpandCompressedLine(uint8_t* pDest,TGAHEADER* ptgaHead,CxFile *hFile,int32_t width, int32_t y, uint8_t rleLeftover) 202 | { 203 | uint8_t rle; 204 | int32_t filePos=0; 205 | for (int32_t x=0; xRead(&rle,1,1); 211 | } 212 | if (rle & 128) { // RLE-Encoded packet 213 | rle -= 127; // Calculate real repeat count. 214 | if ((x+rle)>width){ 215 | rleLeftover = (uint8_t)(128 + (rle - (width - x) - 1)); 216 | filePos = hFile->Tell(); 217 | rle = (uint8_t)(width - x); 218 | } 219 | switch (ptgaHead->PixelDepth) 220 | { 221 | case 32: { 222 | RGBQUAD color; 223 | hFile->Read(&color,4,1); 224 | for (int32_t ix = 0; ix < rle; ix++){ 225 | memcpy(&pDest[3*ix],&color,3); 226 | #if CXIMAGE_SUPPORT_ALPHA // 227 | AlphaSet(ix+x,y,color.rgbReserved); 228 | #endif //CXIMAGE_SUPPORT_ALPHA 229 | } 230 | break; 231 | } 232 | case 24: { 233 | rgb_color triple; 234 | hFile->Read(&triple,3,1); 235 | for (int32_t ix = 0; ix < rle; ix++) memcpy(&pDest[3*ix],&triple,3); 236 | break; 237 | } 238 | case 15: 239 | case 16: { 240 | uint16_t pixel; 241 | hFile->Read(&pixel,2,1); 242 | rgb_color triple; 243 | triple.r = (uint8_t)(( pixel & 0x1F ) * 8); // red 244 | triple.g = (uint8_t)(( pixel >> 2 ) & 0x0F8); // green 245 | triple.b = (uint8_t)(( pixel >> 7 ) & 0x0F8); // blue 246 | for (int32_t ix = 0; ix < rle; ix++){ 247 | memcpy(&pDest[3*ix],&triple,3); 248 | } 249 | break; 250 | } 251 | case 8: { 252 | uint8_t pixel; 253 | hFile->Read(&pixel,1,1); 254 | for (int32_t ix = 0; ix < rle; ix++) pDest[ix] = pixel; 255 | } 256 | } 257 | if (rleLeftover!=255) hFile->Seek(filePos, SEEK_SET); 258 | } else { // Raw packet 259 | rle += 1; // Calculate real repeat count. 260 | if ((x+rle)>width){ 261 | rleLeftover = (uint8_t)(rle - (width - x) - 1); 262 | rle = (uint8_t)(width - x); 263 | } 264 | ExpandUncompressedLine(pDest,ptgaHead,hFile,rle,y,x); 265 | } 266 | if (head.biBitCount == 24) pDest += rle*3; else pDest += rle; 267 | x += rle; 268 | } 269 | return rleLeftover; 270 | } 271 | //////////////////////////////////////////////////////////////////////////////// 272 | void CxImageTGA::ExpandUncompressedLine(uint8_t* pDest,TGAHEADER* ptgaHead,CxFile *hFile,int32_t width, int32_t y, int32_t xoffset) 273 | { 274 | switch (ptgaHead->PixelDepth){ 275 | case 8: 276 | hFile->Read(pDest,width,1); 277 | break; 278 | case 15: 279 | case 16:{ 280 | uint8_t* dst=pDest; 281 | uint16_t pixel; 282 | for (int32_t x=0; xRead(&pixel,2,1); 284 | *dst++ = (uint8_t)(( pixel & 0x1F ) * 8); // blue 285 | *dst++ = (uint8_t)(( pixel >> 2 ) & 0x0F8); // green 286 | *dst++ = (uint8_t)(( pixel >> 7 ) & 0x0F8); // red 287 | } 288 | break; 289 | } 290 | case 24: 291 | hFile->Read(pDest,3*width,1); 292 | break; 293 | case 32:{ 294 | uint8_t* dst=pDest; 295 | for (int32_t x=0; xRead(&pixel,4,1); 298 | *dst++ = pixel.rgbBlue; 299 | *dst++ = pixel.rgbGreen; 300 | *dst++ = pixel.rgbRed; 301 | #if CXIMAGE_SUPPORT_ALPHA // 302 | AlphaSet(x+xoffset,y,pixel.rgbReserved); //alpha 303 | #endif //CXIMAGE_SUPPORT_ALPHA 304 | } 305 | break; 306 | } 307 | } 308 | } 309 | //////////////////////////////////////////////////////////////////////////////// 310 | void CxImageTGA::tga_toh(TGAHEADER* p) 311 | { 312 | p->CmapIndex = m_ntohs(p->CmapIndex); 313 | p->CmapLength = m_ntohs(p->CmapLength); 314 | p->X_Origin = m_ntohs(p->X_Origin); 315 | p->Y_Origin = m_ntohs(p->Y_Origin); 316 | p->ImageWidth = m_ntohs(p->ImageWidth); 317 | p->ImageHeight = m_ntohs(p->ImageHeight); 318 | } 319 | //////////////////////////////////////////////////////////////////////////////// 320 | #endif // CXIMAGE_SUPPORT_TGA 321 | -------------------------------------------------------------------------------- /ximatga.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximatga.h 3 | * Purpose: TARGA Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageTGA (c) 05/Jan/2002 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * 9 | * Parts of the code come from Paintlib : Copyright (c) 1996-1998 Ulrich von Zadow 10 | * ========================================================== 11 | */ 12 | #if !defined(__ximaTGA_h) 13 | #define __ximaTGA_h 14 | 15 | #include "ximage.h" 16 | 17 | #if CXIMAGE_SUPPORT_TGA 18 | 19 | class CxImageTGA: public CxImage 20 | { 21 | #pragma pack(1) 22 | typedef struct tagTgaHeader 23 | { 24 | uint8_t IdLength; // Image ID Field Length 25 | uint8_t CmapType; // Color Map Type 26 | uint8_t ImageType; // Image Type 27 | 28 | uint16_t CmapIndex; // First Entry Index 29 | uint16_t CmapLength; // Color Map Length 30 | uint8_t CmapEntrySize; // Color Map Entry Size 31 | 32 | uint16_t X_Origin; // X-origin of Image 33 | uint16_t Y_Origin; // Y-origin of Image 34 | uint16_t ImageWidth; // Image Width 35 | uint16_t ImageHeight; // Image Height 36 | uint8_t PixelDepth; // Pixel Depth 37 | uint8_t ImagDesc; // Image Descriptor 38 | } TGAHEADER; 39 | #pragma pack() 40 | 41 | public: 42 | CxImageTGA(): CxImage(CXIMAGE_FORMAT_TGA) {} 43 | 44 | // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_TGA);} 45 | // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_TGA);} 46 | bool Decode(CxFile * hFile); 47 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 48 | 49 | #if CXIMAGE_SUPPORT_ENCODE 50 | bool Encode(CxFile * hFile); 51 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 52 | #endif // CXIMAGE_SUPPORT_ENCODE 53 | protected: 54 | uint8_t ExpandCompressedLine(uint8_t* pDest,TGAHEADER* ptgaHead,CxFile *hFile,int32_t width, int32_t y, uint8_t rleLeftover); 55 | void ExpandUncompressedLine(uint8_t* pDest,TGAHEADER* ptgaHead,CxFile *hFile,int32_t width, int32_t y, int32_t xoffset); 56 | void tga_toh(TGAHEADER* p); 57 | }; 58 | 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /ximath.cpp: -------------------------------------------------------------------------------- 1 | #include "ximage.h" 2 | #include "ximath.h" 3 | #include 4 | 5 | //this module should contain some classes for geometrical transformations 6 | //usable with selections, etc... once it's done, that is. :) 7 | 8 | CxPoint2::CxPoint2() 9 | { 10 | x=y=0.0f; 11 | } 12 | 13 | CxPoint2::CxPoint2(float const x_, float const y_) 14 | { 15 | x=x_; 16 | y=y_; 17 | } 18 | 19 | CxPoint2::CxPoint2(CxPoint2 const &p) 20 | { 21 | x=p.x; 22 | y=p.y; 23 | } 24 | 25 | float CxPoint2::Distance(CxPoint2 const p2) 26 | { 27 | return (float)sqrt((x-p2.x)*(x-p2.x)+(y-p2.y)*(y-p2.y)); 28 | } 29 | 30 | float CxPoint2::Distance(float const x_, float const y_) 31 | { 32 | return (float)sqrt((x-x_)*(x-x_)+(y-y_)*(y-y_)); 33 | } 34 | 35 | CxRect2::CxRect2() 36 | { 37 | } 38 | 39 | CxRect2::CxRect2(float const x1_, float const y1_, float const x2_, float const y2_) 40 | { 41 | botLeft.x=x1_; 42 | botLeft.y=y1_; 43 | topRight.x=x2_; 44 | topRight.y=y2_; 45 | } 46 | 47 | CxRect2::CxRect2(CxRect2 const &p) 48 | { 49 | botLeft=p.botLeft; 50 | topRight=p.topRight; 51 | } 52 | 53 | float CxRect2::Surface() const 54 | /* 55 | * Returns the surface of rectangle. 56 | */ 57 | { 58 | return (topRight.x-botLeft.x)*(topRight.y-botLeft.y); 59 | } 60 | 61 | CxRect2 CxRect2::CrossSection(CxRect2 const &r2) const 62 | /* 63 | * Returns crossection with another rectangle. 64 | */ 65 | { 66 | CxRect2 cs; 67 | cs.botLeft.x=max(botLeft.x, r2.botLeft.x); 68 | cs.botLeft.y=max(botLeft.y, r2.botLeft.y); 69 | cs.topRight.x=min(topRight.x, r2.topRight.x); 70 | cs.topRight.y=min(topRight.y, r2.topRight.y); 71 | if (cs.botLeft.x<=cs.topRight.x && cs.botLeft.y<=cs.topRight.y) { 72 | return cs; 73 | } else { 74 | return CxRect2(0,0,0,0); 75 | }//if 76 | } 77 | 78 | CxPoint2 CxRect2::Center() const 79 | /* 80 | * Returns the center point of rectangle. 81 | */ 82 | { 83 | return CxPoint2((topRight.x+botLeft.x)/2.0f, (topRight.y+botLeft.y)/2.0f); 84 | } 85 | 86 | float CxRect2::Width() const 87 | //returns rectangle width 88 | { 89 | return topRight.x-botLeft.x; 90 | } 91 | 92 | float CxRect2::Height() const 93 | //returns rectangle height 94 | { 95 | return topRight.y-botLeft.y; 96 | } 97 | 98 | -------------------------------------------------------------------------------- /ximath.h: -------------------------------------------------------------------------------- 1 | #if !defined(__ximath_h) 2 | #define __ximath_h 3 | 4 | #include "ximadef.h" 5 | 6 | //***bd*** simple floating point point 7 | class DLL_EXP CxPoint2 8 | { 9 | public: 10 | CxPoint2(); 11 | CxPoint2(float const x_, float const y_); 12 | CxPoint2(CxPoint2 const &p); 13 | 14 | float Distance(CxPoint2 const p2); 15 | float Distance(float const x_, float const y_); 16 | 17 | float x,y; 18 | }; 19 | 20 | //and simple rectangle 21 | class DLL_EXP CxRect2 22 | { 23 | public: 24 | CxRect2(); 25 | CxRect2(float const x1_, float const y1_, float const x2_, float const y2_); 26 | CxRect2(CxPoint2 const &bl, CxPoint2 const &tr); 27 | CxRect2(CxRect2 const &p); 28 | 29 | float Surface() const; 30 | CxRect2 CrossSection(CxRect2 const &r2) const; 31 | CxPoint2 Center() const; 32 | float Width() const; 33 | float Height() const; 34 | 35 | CxPoint2 botLeft; 36 | CxPoint2 topRight; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /ximatif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximatif.h 3 | * Purpose: TIFF Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageTIF (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * 9 | * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes 10 | * 11 | * Special thanks to Abe for MultiPageTIFF code. 12 | * 13 | * LibTIFF is: 14 | * Copyright (c) 1988-1997 Sam Leffler 15 | * Copyright (c) 1991-1997 Silicon Graphics, Inc. 16 | * ========================================================== 17 | */ 18 | 19 | #if !defined(__ximatif_h) 20 | #define __ximatif_h 21 | 22 | #include "ximage.h" 23 | 24 | #if CXIMAGE_SUPPORT_TIF 25 | 26 | #include "../tiff/tiffio.h" 27 | 28 | class DLL_EXP CxImageTIF: public CxImage 29 | { 30 | public: 31 | CxImageTIF(): CxImage(CXIMAGE_FORMAT_TIF) {m_tif2=NULL; m_multipage=false; m_pages=0;} 32 | ~CxImageTIF(); 33 | 34 | TIFF* TIFFOpenEx(CxFile * hFile); 35 | void TIFFCloseEx(TIFF* tif); 36 | 37 | // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_TIF);} 38 | // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_TIF);} 39 | bool Decode(CxFile * hFile); 40 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 41 | 42 | #if CXIMAGE_SUPPORT_ENCODE 43 | bool Encode(CxFile * hFile, bool bAppend=false); 44 | bool Encode(CxFile * hFile, CxImage ** pImages, int32_t pagecount); 45 | bool Encode(FILE *hFile, bool bAppend=false) { CxIOFile file(hFile); return Encode(&file,bAppend); } 46 | bool Encode(FILE *hFile, CxImage ** pImages, int32_t pagecount) 47 | { CxIOFile file(hFile); return Encode(&file, pImages, pagecount); } 48 | #endif // CXIMAGE_SUPPORT_ENCODE 49 | 50 | protected: 51 | void TileToStrip(uint8* out, uint8* in, uint32 rows, uint32 cols, int32_t outskew, int32_t inskew); 52 | bool EncodeBody(TIFF *m_tif, bool multipage=false, int32_t page=0, int32_t pagecount=0); 53 | TIFF *m_tif2; 54 | bool m_multipage; 55 | int32_t m_pages; 56 | void MoveBits( uint8_t* dest, uint8_t* from, int32_t count, int32_t bpp ); 57 | void MoveBitsPal( uint8_t* dest, uint8_t*from, int32_t count, int32_t bpp, RGBQUAD* pal ); 58 | }; 59 | 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /ximawbmp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximawbmp.cpp 3 | * Purpose: Platform Independent WBMP Image Class Loader and Writer 4 | * 12/Jul/2002 Davide Pizzolato - www.xdp.it 5 | * CxImage version 7.0.1 07/Jan/2011 6 | */ 7 | 8 | #include "ximawbmp.h" 9 | 10 | #if CXIMAGE_SUPPORT_WBMP 11 | 12 | #include "ximaiter.h" 13 | 14 | //////////////////////////////////////////////////////////////////////////////// 15 | #if CXIMAGE_SUPPORT_DECODE 16 | //////////////////////////////////////////////////////////////////////////////// 17 | bool CxImageWBMP::Decode(CxFile *hFile) 18 | { 19 | if (hFile == NULL) return false; 20 | 21 | WBMPHEADER wbmpHead; 22 | 23 | cx_try 24 | { 25 | ReadOctet(hFile, &wbmpHead.Type); 26 | 27 | uint32_t dat; 28 | ReadOctet(hFile, &dat); 29 | wbmpHead.FixHeader = (uint8_t)dat; 30 | 31 | ReadOctet(hFile, &wbmpHead.ImageWidth); 32 | ReadOctet(hFile, &wbmpHead.ImageHeight); 33 | 34 | if (hFile->Eof()) 35 | cx_throw("Not a WBMP"); 36 | 37 | if (wbmpHead.Type != 0) 38 | cx_throw("Unsupported WBMP type"); 39 | 40 | head.biWidth = wbmpHead.ImageWidth; 41 | head.biHeight= wbmpHead.ImageHeight; 42 | 43 | if (head.biWidth<=0 || head.biHeight<=0) 44 | cx_throw("Corrupted WBMP"); 45 | 46 | if (info.nEscape == -1){ 47 | info.dwType = CXIMAGE_FORMAT_WBMP; 48 | return true; 49 | } 50 | 51 | Create(head.biWidth, head.biHeight, 1, CXIMAGE_FORMAT_WBMP); 52 | if (!IsValid()) cx_throw("WBMP Create failed"); 53 | SetGrayPalette(); 54 | 55 | int32_t linewidth=(head.biWidth+7)/8; 56 | CImageIterator iter(this); 57 | iter.Upset(); 58 | for (int32_t y=0; y < head.biHeight; y++){ 59 | hFile->Read(iter.GetRow(),linewidth,1); 60 | iter.PrevRow(); 61 | } 62 | 63 | } cx_catch { 64 | if (strcmp(message,"")) strncpy(info.szLastError,message,255); 65 | return FALSE; 66 | } 67 | return true; 68 | } 69 | //////////////////////////////////////////////////////////////////////////////// 70 | bool CxImageWBMP::ReadOctet(CxFile * hFile, uint32_t *data) 71 | { 72 | uint8_t c; 73 | *data = 0; 74 | do { 75 | if (hFile->Eof()) return false; 76 | c = (uint8_t)hFile->GetC(); 77 | *data <<= 7; 78 | *data |= (c & 0x7F); 79 | } while ((c&0x80)!=0); 80 | return true; 81 | } 82 | //////////////////////////////////////////////////////////////////////////////// 83 | #endif //CXIMAGE_SUPPORT_DECODE 84 | //////////////////////////////////////////////////////////////////////////////// 85 | #if CXIMAGE_SUPPORT_ENCODE 86 | //////////////////////////////////////////////////////////////////////////////// 87 | bool CxImageWBMP::Encode(CxFile * hFile) 88 | { 89 | if (EncodeSafeCheck(hFile)) return false; 90 | 91 | //check format limits 92 | if (head.biBitCount!=1){ 93 | strcpy(info.szLastError,"Can't save this image as WBMP"); 94 | return false; 95 | } 96 | 97 | WBMPHEADER wbmpHead; 98 | wbmpHead.Type=0; 99 | wbmpHead.FixHeader=0; 100 | wbmpHead.ImageWidth=head.biWidth; 101 | wbmpHead.ImageHeight=head.biHeight; 102 | 103 | // Write the file header 104 | hFile->PutC('\0'); 105 | hFile->PutC('\0'); 106 | WriteOctet(hFile,wbmpHead.ImageWidth); 107 | WriteOctet(hFile,wbmpHead.ImageHeight); 108 | // Write the pixels 109 | int32_t linewidth=(wbmpHead.ImageWidth+7)/8; 110 | CImageIterator iter(this); 111 | iter.Upset(); 112 | for (uint32_t y=0; y < wbmpHead.ImageHeight; y++){ 113 | hFile->Write(iter.GetRow(),linewidth,1); 114 | iter.PrevRow(); 115 | } 116 | return true; 117 | } 118 | //////////////////////////////////////////////////////////////////////////////// 119 | bool CxImageWBMP::WriteOctet(CxFile * hFile, const uint32_t data) 120 | { 121 | int32_t ns = 0; 122 | while (data>>(ns+7)) ns+=7; 123 | while (ns>0){ 124 | if (!hFile->PutC(0x80 | (uint8_t)(data>>ns))) return false; 125 | ns-=7; 126 | } 127 | if (!(hFile->PutC((uint8_t)(0x7F & data)))) return false; 128 | return true; 129 | } 130 | //////////////////////////////////////////////////////////////////////////////// 131 | #endif // CXIMAGE_SUPPORT_ENCODE 132 | //////////////////////////////////////////////////////////////////////////////// 133 | #endif // CXIMAGE_SUPPORT_WBMP 134 | 135 | -------------------------------------------------------------------------------- /ximawbmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ximawbmp.h 3 | * Purpose: WBMP Image Class Loader and Writer 4 | */ 5 | /* ========================================================== 6 | * CxImageWBMP (c) 12/Jul/2002 Davide Pizzolato - www.xdp.it 7 | * For conditions of distribution and use, see copyright notice in ximage.h 8 | * ========================================================== 9 | */ 10 | #if !defined(__ximaWBMP_h) 11 | #define __ximaWBMP_h 12 | 13 | #include "ximage.h" 14 | 15 | #if CXIMAGE_SUPPORT_WBMP 16 | 17 | class CxImageWBMP: public CxImage 18 | { 19 | #pragma pack(1) 20 | typedef struct tagWbmpHeader 21 | { 22 | uint32_t Type; // 0 23 | uint8_t FixHeader; // 0 24 | uint32_t ImageWidth; // Image Width 25 | uint32_t ImageHeight; // Image Height 26 | } WBMPHEADER; 27 | #pragma pack() 28 | public: 29 | CxImageWBMP(): CxImage(CXIMAGE_FORMAT_WBMP) {} 30 | 31 | // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_WBMP);} 32 | // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_WBMP);} 33 | bool Decode(CxFile * hFile); 34 | bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } 35 | protected: 36 | bool ReadOctet(CxFile * hFile, uint32_t *data); 37 | 38 | public: 39 | #if CXIMAGE_SUPPORT_ENCODE 40 | bool Encode(CxFile * hFile); 41 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 42 | protected: 43 | bool WriteOctet(CxFile * hFile, const uint32_t data); 44 | #endif // CXIMAGE_SUPPORT_ENCODE 45 | }; 46 | 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /ximawmf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************* 3 | * File: ximawmf.h 4 | * Purpose: Windows Metafile Class Loader and Writer 5 | * Author: Volker Horch - vhorch@gmx.de 6 | * created: 13-Jun-2002 7 | ********************************************************************* 8 | */ 9 | 10 | /* 11 | ********************************************************************* 12 | Notes by Author: 13 | ********************************************************************* 14 | 15 | Limitations: 16 | ============ 17 | 18 | a) Transparency: 19 | 20 | A Metafile is vector graphics, which has transparency by design. 21 | This class always converts into a Bitmap format. Transparency is 22 | supported, but there is no good way to find out, which parts 23 | of the Metafile are transparent. There are two ways how we can 24 | handle this: 25 | 26 | - Clear the Background of the Bitmap with the background color 27 | you like (i have used COLOR_WINDOW) and don't support transparency. 28 | 29 | below #define XMF_SUPPORT_TRANSPARENCY 0 30 | #define XMF_COLOR_BACK RGB(Background color you like) 31 | 32 | - Clear the Background of the Bitmap with a very unusual color 33 | (which one ?) and use this color as the transparent color 34 | 35 | below #define XMF_SUPPORT_TRANSPARENCY 1 36 | #define XMF_COLOR_TRANSPARENT_R ... 37 | #define XMF_COLOR_TRANSPARENT_G ... 38 | #define XMF_COLOR_TRANSPARENT_B ... 39 | 40 | b) Resolution 41 | 42 | Once we have converted the Metafile into a Bitmap and we zoom in 43 | or out, the image may not look very good. If we still had the 44 | original Metafile, zooming would produce good results always. 45 | 46 | c) Size 47 | 48 | Although the filesize of a Metafile may be very small, it might 49 | produce a Bitmap with a bombastic size. Assume you have a Metafile 50 | with an image size of 6000*4000, which contains just one Metafile 51 | record ((e.g. a line from (0,0) to (6000, 4000)). The filesize 52 | of this Metafile would be let's say 100kB. If we convert it to 53 | a 6000*4000 Bitmap with 24 Bits/Pixes, the Bitmap would consume 54 | about 68MB of memory. 55 | 56 | I have choosen, to limit the size of the Bitmap to max. 57 | screensize, to avoid memory problems. 58 | 59 | If you want something else, 60 | modify #define XMF_MAXSIZE_CX / XMF_MAXSIZE_CY below 61 | 62 | ********************************************************************* 63 | */ 64 | 65 | #ifndef _XIMAWMF_H 66 | #define _XIMAWMF_H 67 | 68 | #include "ximage.h" 69 | 70 | #if CXIMAGE_SUPPORT_WMF && CXIMAGE_SUPPORT_WINDOWS 71 | 72 | class CxImageWMF: public CxImage 73 | { 74 | 75 | #pragma pack(1) 76 | 77 | typedef struct tagRECT16 78 | { 79 | int16_t left; 80 | int16_t top; 81 | int16_t right; 82 | int16_t bottom; 83 | } RECT16; 84 | 85 | // taken from Windos 3.11 SDK Documentation (Programmer's Reference Volume 4: Resources) 86 | typedef struct tagMETAFILEHEADER 87 | { 88 | uint32_t key; // always 0x9ac6cdd7 89 | uint16_t reserved1; // reserved = 0 90 | RECT16 bbox; // bounding rectangle in metafile units as defined in "inch" 91 | uint16_t inch; // number of metafile units per inch (should be < 1440) 92 | uint32_t reserved2; // reserved = 0 93 | uint16_t checksum; // sum of the first 10 WORDS (using XOR operator) 94 | } METAFILEHEADER; 95 | 96 | #pragma pack() 97 | 98 | public: 99 | CxImageWMF(): CxImage(CXIMAGE_FORMAT_WMF) { } 100 | 101 | bool Decode(CxFile * hFile, int32_t nForceWidth=0, int32_t nForceHeight=0); 102 | bool Decode(FILE *hFile, int32_t nForceWidth=0, int32_t nForceHeight=0) 103 | { CxIOFile file(hFile); return Decode(&file,nForceWidth,nForceHeight); } 104 | 105 | #if CXIMAGE_SUPPORT_ENCODE 106 | bool Encode(CxFile * hFile); 107 | bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } 108 | #endif // CXIMAGE_SUPPORT_ENCODE 109 | 110 | protected: 111 | void ShrinkMetafile(int32_t &cx, int32_t &cy); 112 | BOOL CheckMetafileHeader(METAFILEHEADER *pmetafileheader); 113 | HENHMETAFILE ConvertWmfFiletoEmf(CxFile *pFile, METAFILEHEADER *pmetafileheader); 114 | HENHMETAFILE ConvertEmfFiletoEmf(CxFile *pFile, ENHMETAHEADER *pemfh); 115 | 116 | }; 117 | 118 | #define METAFILEKEY 0x9ac6cdd7L 119 | 120 | // Background color definition (if no transparency). see Notes above 121 | #define XMF_COLOR_BACK GetSysColor(COLOR_WINDOW) 122 | // alternatives 123 | //#define XMF_COLOR_BACK RGB(192, 192, 192) // lite gray 124 | //#define XMF_COLOR_BACK RGB( 0, 0, 0) // black 125 | //#define XMF_COLOR_BACK RGB(255, 255, 255) // white 126 | 127 | 128 | // transparency support. see Notes above 129 | #define XMF_SUPPORT_TRANSPARENCY 0 130 | #define XMF_COLOR_TRANSPARENT_R 211 131 | #define XMF_COLOR_TRANSPARENT_G 121 132 | #define XMF_COLOR_TRANSPARENT_B 112 133 | // don't change 134 | #define XMF_COLOR_TRANSPARENT RGB (XMF_COLOR_TRANSPARENT_R, \ 135 | XMF_COLOR_TRANSPARENT_G, \ 136 | XMF_COLOR_TRANSPARENT_B) 137 | // don't change 138 | #define XMF_RGBQUAD_TRANSPARENT XMF_COLOR_TRANSPARENT_B, \ 139 | XMF_COLOR_TRANSPARENT_G, \ 140 | XMF_COLOR_TRANSPARENT_R, \ 141 | 0 142 | // max. size. see Notes above 143 | // alternatives 144 | //#define XMF_MAXSIZE_CX (GetSystemMetrics(SM_CXSCREEN)-10) 145 | //#define XMF_MAXSIZE_CY (GetSystemMetrics(SM_CYSCREEN)-50) 146 | //#define XMF_MAXSIZE_CX (2*GetSystemMetrics(SM_CXSCREEN)/3) 147 | //#define XMF_MAXSIZE_CY (2*GetSystemMetrics(SM_CYSCREEN)/3) 148 | #define XMF_MAXSIZE_CX 4000 149 | #define XMF_MAXSIZE_CY 4000 150 | 151 | 152 | #endif 153 | 154 | #endif 155 | -------------------------------------------------------------------------------- /ximawnd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/movableink/cximage/73a4518e7a3a7fbc2f27c91e5873a56769c8dbf7/ximawnd.cpp -------------------------------------------------------------------------------- /xiofile.h: -------------------------------------------------------------------------------- 1 | #if !defined(__xiofile_h) 2 | #define __xiofile_h 3 | 4 | #include "xfile.h" 5 | //#include 6 | 7 | class DLL_EXP CxIOFile : public CxFile 8 | { 9 | public: 10 | CxIOFile(FILE* fp = NULL) 11 | { 12 | m_fp = fp; 13 | m_bCloseFile = (bool)(fp==0); 14 | } 15 | 16 | ~CxIOFile() 17 | { 18 | Close(); 19 | } 20 | ////////////////////////////////////////////////////////// 21 | bool Open(const TCHAR * filename, const TCHAR * mode) 22 | { 23 | if (m_fp) return false; // Can't re-open without closing first 24 | 25 | m_fp = _tfopen(filename, mode); 26 | if (!m_fp) return false; 27 | 28 | m_bCloseFile = true; 29 | 30 | return true; 31 | } 32 | ////////////////////////////////////////////////////////// 33 | virtual bool Close() 34 | { 35 | int32_t iErr = 0; 36 | if ( (m_fp) && (m_bCloseFile) ){ 37 | iErr = fclose(m_fp); 38 | m_fp = NULL; 39 | } 40 | return (bool)(iErr==0); 41 | } 42 | ////////////////////////////////////////////////////////// 43 | virtual size_t Read(void *buffer, size_t size, size_t count) 44 | { 45 | if (!m_fp) return 0; 46 | return fread(buffer, size, count, m_fp); 47 | } 48 | ////////////////////////////////////////////////////////// 49 | virtual size_t Write(const void *buffer, size_t size, size_t count) 50 | { 51 | if (!m_fp) return 0; 52 | return fwrite(buffer, size, count, m_fp); 53 | } 54 | ////////////////////////////////////////////////////////// 55 | virtual bool Seek(int32_t offset, int32_t origin) 56 | { 57 | if (!m_fp) return false; 58 | return (bool)(fseek(m_fp, offset, origin) == 0); 59 | } 60 | ////////////////////////////////////////////////////////// 61 | virtual int32_t Tell() 62 | { 63 | if (!m_fp) return 0; 64 | return ftell(m_fp); 65 | } 66 | ////////////////////////////////////////////////////////// 67 | virtual int32_t Size() 68 | { 69 | if (!m_fp) return -1; 70 | int32_t pos,size; 71 | pos = ftell(m_fp); 72 | fseek(m_fp, 0, SEEK_END); 73 | size = ftell(m_fp); 74 | fseek(m_fp, pos,SEEK_SET); 75 | return size; 76 | } 77 | ////////////////////////////////////////////////////////// 78 | virtual bool Flush() 79 | { 80 | if (!m_fp) return false; 81 | return (bool)(fflush(m_fp) == 0); 82 | } 83 | ////////////////////////////////////////////////////////// 84 | virtual bool Eof() 85 | { 86 | if (!m_fp) return true; 87 | return (bool)(feof(m_fp) != 0); 88 | } 89 | ////////////////////////////////////////////////////////// 90 | virtual int32_t Error() 91 | { 92 | if (!m_fp) return -1; 93 | return ferror(m_fp); 94 | } 95 | ////////////////////////////////////////////////////////// 96 | virtual bool PutC(uint8_t c) 97 | { 98 | if (!m_fp) return false; 99 | return (bool)(fputc(c, m_fp) == c); 100 | } 101 | ////////////////////////////////////////////////////////// 102 | virtual int32_t GetC() 103 | { 104 | if (!m_fp) return EOF; 105 | return getc(m_fp); 106 | } 107 | ////////////////////////////////////////////////////////// 108 | virtual char * GetS(char *string, int32_t n) 109 | { 110 | if (!m_fp) return NULL; 111 | return fgets(string,n,m_fp); 112 | } 113 | ////////////////////////////////////////////////////////// 114 | virtual int32_t Scanf(const char *format, void* output) 115 | { 116 | if (!m_fp) return EOF; 117 | return fscanf(m_fp, format, output); 118 | } 119 | ////////////////////////////////////////////////////////// 120 | protected: 121 | FILE *m_fp; 122 | bool m_bCloseFile; 123 | }; 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /xmemfile.cpp: -------------------------------------------------------------------------------- 1 | #include "xmemfile.h" 2 | 3 | ////////////////////////////////////////////////////////// 4 | CxMemFile::CxMemFile(uint8_t* pBuffer, uint32_t size) 5 | { 6 | m_pBuffer = pBuffer; 7 | m_Position = 0; 8 | m_Size = m_Edge = size; 9 | m_bFreeOnClose = (bool)(pBuffer==0); 10 | m_bEOF = false; 11 | } 12 | ////////////////////////////////////////////////////////// 13 | CxMemFile::~CxMemFile() 14 | { 15 | Close(); 16 | } 17 | ////////////////////////////////////////////////////////// 18 | bool CxMemFile::Close() 19 | { 20 | if ( (m_pBuffer) && (m_bFreeOnClose) ){ 21 | free(m_pBuffer); 22 | m_pBuffer = NULL; 23 | m_Size = 0; 24 | } 25 | return true; 26 | } 27 | ////////////////////////////////////////////////////////// 28 | bool CxMemFile::Open() 29 | { 30 | if (m_pBuffer) return false; // Can't re-open without closing first 31 | 32 | m_Position = m_Size = m_Edge = 0; 33 | m_pBuffer=(uint8_t*)malloc(1); 34 | m_bFreeOnClose = true; 35 | 36 | return (m_pBuffer!=0); 37 | } 38 | ////////////////////////////////////////////////////////// 39 | uint8_t* CxMemFile::GetBuffer(bool bDetachBuffer) 40 | { 41 | //can only detach, avoid inadvertantly attaching to 42 | // memory that may not be ours [Jason De Arte] 43 | if( bDetachBuffer ) 44 | m_bFreeOnClose = false; 45 | return m_pBuffer; 46 | } 47 | ////////////////////////////////////////////////////////// 48 | size_t CxMemFile::Read(void *buffer, size_t size, size_t count) 49 | { 50 | if (buffer==NULL) return 0; 51 | 52 | if (m_pBuffer==NULL) return 0; 53 | if (m_Position >= (int32_t)m_Size){ 54 | m_bEOF = true; 55 | return 0; 56 | } 57 | 58 | int32_t nCount = (int32_t)(count*size); 59 | if (nCount == 0) return 0; 60 | 61 | int32_t nRead; 62 | if (m_Position + nCount > (int32_t)m_Size){ 63 | m_bEOF = true; 64 | nRead = (m_Size - m_Position); 65 | } else 66 | nRead = nCount; 67 | 68 | memcpy(buffer, m_pBuffer + m_Position, nRead); 69 | m_Position += nRead; 70 | 71 | return (size_t)(nRead/size); 72 | } 73 | ////////////////////////////////////////////////////////// 74 | size_t CxMemFile::Write(const void *buffer, size_t size, size_t count) 75 | { 76 | m_bEOF = false; 77 | if (m_pBuffer==NULL) return 0; 78 | if (buffer==NULL) return 0; 79 | 80 | int32_t nCount = (int32_t)(count*size); 81 | if (nCount == 0) return 0; 82 | 83 | if (m_Position + nCount > m_Edge){ 84 | if (!Alloc(m_Position + nCount)){ 85 | return false; 86 | } 87 | } 88 | 89 | memcpy(m_pBuffer + m_Position, buffer, nCount); 90 | 91 | m_Position += nCount; 92 | 93 | if (m_Position > (int32_t)m_Size) m_Size = m_Position; 94 | 95 | return count; 96 | } 97 | ////////////////////////////////////////////////////////// 98 | bool CxMemFile::Seek(int32_t offset, int32_t origin) 99 | { 100 | m_bEOF = false; 101 | if (m_pBuffer==NULL) return false; 102 | int32_t lNewPos = m_Position; 103 | 104 | if (origin == SEEK_SET) lNewPos = offset; 105 | else if (origin == SEEK_CUR) lNewPos += offset; 106 | else if (origin == SEEK_END) lNewPos = m_Size + offset; 107 | else return false; 108 | 109 | if (lNewPos < 0) lNewPos = 0; 110 | 111 | m_Position = lNewPos; 112 | return true; 113 | } 114 | ////////////////////////////////////////////////////////// 115 | int32_t CxMemFile::Tell() 116 | { 117 | if (m_pBuffer==NULL) return -1; 118 | return m_Position; 119 | } 120 | ////////////////////////////////////////////////////////// 121 | int32_t CxMemFile::Size() 122 | { 123 | if (m_pBuffer==NULL) return -1; 124 | return m_Size; 125 | } 126 | ////////////////////////////////////////////////////////// 127 | bool CxMemFile::Flush() 128 | { 129 | if (m_pBuffer==NULL) return false; 130 | return true; 131 | } 132 | ////////////////////////////////////////////////////////// 133 | bool CxMemFile::Eof() 134 | { 135 | if (m_pBuffer==NULL) return true; 136 | return m_bEOF; 137 | } 138 | ////////////////////////////////////////////////////////// 139 | int32_t CxMemFile::Error() 140 | { 141 | if (m_pBuffer==NULL) return -1; 142 | return (m_Position > (int32_t)m_Size); 143 | } 144 | ////////////////////////////////////////////////////////// 145 | bool CxMemFile::PutC(uint8_t c) 146 | { 147 | m_bEOF = false; 148 | if (m_pBuffer==NULL) return false; 149 | 150 | if (m_Position >= m_Edge){ 151 | if (!Alloc(m_Position + 1)){ 152 | return false; 153 | } 154 | } 155 | 156 | m_pBuffer[m_Position++] = c; 157 | 158 | if (m_Position > (int32_t)m_Size) m_Size = m_Position; 159 | 160 | return true; 161 | } 162 | ////////////////////////////////////////////////////////// 163 | int32_t CxMemFile::GetC() 164 | { 165 | if (m_pBuffer==NULL || m_Position >= (int32_t)m_Size){ 166 | m_bEOF = true; 167 | return EOF; 168 | } 169 | return *(uint8_t*)((uint8_t*)m_pBuffer + m_Position++); 170 | } 171 | ////////////////////////////////////////////////////////// 172 | char * CxMemFile::GetS(char *string, int32_t n) 173 | { 174 | n--; 175 | int32_t c,i=0; 176 | while (i (uint32_t)m_Edge) 194 | { 195 | // find new buffer size 196 | uint32_t dwNewBufferSize = (uint32_t)(((dwNewLen>>16)+1)<<16); 197 | 198 | // allocate new buffer 199 | if (m_pBuffer == NULL) m_pBuffer = (uint8_t*)malloc(dwNewBufferSize); 200 | else m_pBuffer = (uint8_t*)realloc(m_pBuffer, dwNewBufferSize); 201 | // I own this buffer now (caller knows nothing about it) 202 | m_bFreeOnClose = true; 203 | 204 | m_Edge = dwNewBufferSize; 205 | } 206 | return (m_pBuffer!=0); 207 | } 208 | ////////////////////////////////////////////////////////// 209 | void CxMemFile::Free() 210 | { 211 | Close(); 212 | } 213 | ////////////////////////////////////////////////////////// 214 | -------------------------------------------------------------------------------- /xmemfile.h: -------------------------------------------------------------------------------- 1 | #if !defined(__xmemfile_h) 2 | #define __xmemfile_h 3 | 4 | #include "xfile.h" 5 | 6 | ////////////////////////////////////////////////////////// 7 | class DLL_EXP CxMemFile : public CxFile 8 | { 9 | public: 10 | CxMemFile(uint8_t* pBuffer = NULL, uint32_t size = 0); 11 | ~CxMemFile(); 12 | 13 | bool Open(); 14 | uint8_t* GetBuffer(bool bDetachBuffer = true); 15 | 16 | virtual bool Close(); 17 | virtual size_t Read(void *buffer, size_t size, size_t count); 18 | virtual size_t Write(const void *buffer, size_t size, size_t count); 19 | virtual bool Seek(int32_t offset, int32_t origin); 20 | virtual int32_t Tell(); 21 | virtual int32_t Size(); 22 | virtual bool Flush(); 23 | virtual bool Eof(); 24 | virtual int32_t Error(); 25 | virtual bool PutC(uint8_t c); 26 | virtual int32_t GetC(); 27 | virtual char * GetS(char *string, int32_t n); 28 | virtual int32_t Scanf(const char *format, void* output); 29 | 30 | protected: 31 | bool Alloc(uint32_t nBytes); 32 | void Free(); 33 | 34 | uint8_t* m_pBuffer; 35 | uint32_t m_Size; 36 | bool m_bFreeOnClose; 37 | int32_t m_Position; //current position 38 | int32_t m_Edge; //buffer size 39 | bool m_bEOF; 40 | }; 41 | 42 | #endif 43 | --------------------------------------------------------------------------------