2024.8.23
Loading...
Searching...
No Matches
freeimage.inc.php
Go to the documentation of this file.
1<?php
2
3/*******************************************************************************
4
5 WINBINDER - The native Windows binding for PHP for PHP
6
7 Copyright � Hypervisual - see LICENSE.TXT for details
8 Author: Rubem Pechansky (http://winbinder.org/contact.php)
9
10 Some functions to call the FreeImage library directly
11
12*******************************************************************************/
13
14/*
15
16This software uses the FreeImage open source image library. See
17http://freeimage.sourceforge.net for details. FreeImage is used under the
18FIPL version 1.0.
19
20Go to the FreeImage web site (http://freeimage.sourceforge.net) to download
21the FreeImage DLL and documentation.
22
23These functions were successfully tested with the following FreeImage versions:
24
252.3.1 (600 kB, 260 kB zipped)
262.5.4 (670 kB, 290 kB zipped)
273.4.0 (744 kB, 350 kB zipped)
283.5.3 (888 kB, 413 kB zipped)
29
30*/
31
32//-------------------------------------------------------------------- CONSTANTS
33
34// These were taken from FreeImage.h (version 3.5.3)
35
36define("FIF_UNKNOWN", -1);
37define("FIF_BMP", 0);
38define("FIF_ICO", 1);
39define("FIF_JPEG", 2);
40define("FIF_JNG", 3);
41define("FIF_KOALA", 4);
42define("FIF_LBM", 5);
43define("FIF_IFF", FIF_LBM);
44define("FIF_MNG", 6);
45define("FIF_PBM", 7);
46define("FIF_PBMRAW", 8);
47define("FIF_PCD", 9);
48define("FIF_PCX", 10);
49define("FIF_PGM", 11);
50define("FIF_PGMRAW", 12);
51define("FIF_PNG", 13);
52define("FIF_PPM", 14);
53define("FIF_PPMRAW", 15);
54define("FIF_RAS", 16);
55define("FIF_TARGA", 17);
56define("FIF_TIFF", 18);
57define("FIF_WBMP", 19);
58define("FIF_PSD", 20);
59define("FIF_CUT", 21);
60define("FIF_XBM", 22);
61define("FIF_XPM", 23);
62define("FIF_DDS", 24);
63define("FIF_GIF", 25);
64
65//------------------------------------------------------------- GLOBAL VARIABLES
66
67if(!isset($FI)) {
68 $FI = wb_load_library("ext\\freeimage");
69 if(!$FI) {
70 wb_message_box(null, "FreeImage extension could not be loaded.", "Error", WBC_STOP);
71 die();
72 }
73}
74//-------------------------------------------------------------------- FUNCTIONS
75
77{
78 global $FI;
79 static $pfn = null;
80
81 if($pfn === null)
82 $pfn = wb_get_function_address("FreeImage_GetVersion", $FI);
83
84 // Must use wb_peek because this function returns a string pointer
85
86 $version = wb_peek(wb_call_function($pfn));
87 return $version;
88}
89
91{
92 global $FI;
93 static $pfn = null;
94
95 if($pfn === null)
96 $pfn = wb_get_function_address("FreeImage_GetInfoHeader", $FI);
97 return wb_call_function($pfn, array($dib));
98}
99
100function FreeImage_GetBits($dib)
101{
102 global $FI;
103 static $pfn = null;
104
105 if($pfn === null)
106 $pfn = wb_get_function_address("FreeImage_GetBits", $FI);
107 return wb_call_function($pfn, array($dib));
108}
109
110function FreeImage_Allocate($width, $height, $bpp)
111{
112 global $FI;
113 static $pfn = null;
114
115 if($pfn === null)
116 $pfn = wb_get_function_address("FreeImage_Allocate@24", $FI);
117 return wb_call_function($pfn, array($width, $height, $bpp, 0, 0, 0));
118}
119
120function FreeImage_Unload($bmp)
121{
122 global $FI;
123 static $pfn = null;
124
125 if($pfn === null)
126 $pfn = wb_get_function_address("FreeImage_Unload", $FI);
127 return wb_call_function($pfn, array($bmp));
128}
129
130function FreeImage_GetWidth($bmp)
131{
132 global $FI;
133 static $pfn = null;
134
135 if($pfn === null)
136 $pfn = wb_get_function_address("FreeImage_GetWidth", $FI);
137 return wb_call_function($pfn, array($bmp));
138}
139
141{
142 global $FI;
143 static $pfn = null;
144
145 if($pfn === null)
146 $pfn = wb_get_function_address("FreeImage_GetHeight", $FI);
147 return wb_call_function($pfn, array($bmp));
148}
149
150function FreeImage_Load($type, $filename, $flags=0)
151{
152 global $FI;
153 static $pfn = null;
154
155 if($pfn === null)
156 $pfn = wb_get_function_address("FreeImage_Load", $FI);
157 return wb_call_function($pfn, array($type, $filename, $flags));
158}
159
160function FreeImage_Save($type, $dib, $filename, $flags=0)
161{
162 global $FI;
163 static $pfn = null;
164
165 if($pfn === null)
166 $pfn = wb_get_function_address("FreeImage_Save", $FI);
167 return wb_call_function($pfn, array($type, $dib, $filename, $flags));
168}
169
170function FreeImage_Rescale($dib, $dst_width, $dst_height, $filter=0)
171{
172 global $FI;
173 static $pfn = null;
174
175 if($pfn === null)
176 $pfn = wb_get_function_address("FreeImage_Rescale", $FI);
177 return wb_call_function($pfn, array($dib, $dst_width, $dst_height, $filter));
178}
179
180//-------------------------------------------------------------------------- END
181
182?>
FreeImage_GetBits($dib)
const FIF_LBM
FreeImage_GetHeight($bmp)
if(!isset( $FI)) FreeImage_GetVersion()
FreeImage_Rescale($dib, $dst_width, $dst_height, $filter=0)
FreeImage_Unload($bmp)
FreeImage_Save($type, $dib, $filename, $flags=0)
FreeImage_GetWidth($bmp)
FreeImage_Load($type, $filename, $flags=0)
FreeImage_GetInfoHeader($dib)
FreeImage_Allocate($width, $height, $bpp)