Skip to content

Commit 6d2eebc

Browse files
author
fnecati
committed
cleanup
git-svn-id: https://www.ocp.inf.ethz.ch/svn/ocp/trunk@956 ee0346a5-954a-46bf-9309-d26f15615825
1 parent 0e7565a commit 6d2eebc

File tree

2 files changed

+40
-51
lines changed

2 files changed

+40
-51
lines changed

FreeImage/FreeImage.h

+15-15
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ FI_STRUCT (FIMULTIBITMAP) { void *data; };
152152
#include <inttypes.h>
153153
typedef int32_t BOOL;
154154
typedef uint8_t BYTE;
155-
typedef uint16_t SIGNED16;
155+
typedef uint16_t WORD;
156156
typedef uint32_t DWORD;
157157
typedef int32_t LONG;
158158
typedef int64_t INT64;
@@ -161,7 +161,7 @@ typedef uint64_t UINT64;
161161
// MS is not C99 ISO compliant
162162
typedef long BOOL;
163163
typedef unsigned char BYTE;
164-
typedef unsigned short SIGNED16;
164+
typedef unsigned short WORD;
165165
typedef unsigned long DWORD;
166166
typedef long LONG;
167167
typedef signed __int64 INT64;
@@ -209,8 +209,8 @@ typedef struct tagBITMAPINFOHEADER{
209209
DWORD biSize;
210210
LONG biWidth;
211211
LONG biHeight;
212-
SIGNED16 biPlanes;
213-
SIGNED16 biBitCount;
212+
WORD biPlanes;
213+
WORD biBitCount;
214214
DWORD biCompression;
215215
DWORD biSizeImage;
216216
LONG biXPelsPerMeter;
@@ -237,18 +237,18 @@ typedef struct tagBITMAPINFO {
237237
/** 48-bit RGB
238238
*/
239239
typedef struct tagFIRGB16 {
240-
SIGNED16 red;
241-
SIGNED16 green;
242-
SIGNED16 blue;
240+
WORD red;
241+
WORD green;
242+
WORD blue;
243243
} FIRGB16;
244244

245245
/** 64-bit RGBA
246246
*/
247247
typedef struct tagFIRGBA16 {
248-
SIGNED16 red;
249-
SIGNED16 green;
250-
SIGNED16 blue;
251-
SIGNED16 alpha;
248+
WORD red;
249+
WORD green;
250+
WORD blue;
251+
WORD alpha;
252252
} FIRGBA16;
253253

254254
/** 96-bit RGB Float
@@ -268,7 +268,7 @@ typedef struct tagFIRGBAF {
268268
float alpha;
269269
} FIRGBAF;
270270

271-
/** Data structure for COMPLEX32 type (complex number)
271+
/** Data structure for COMPLEX type (complex number)
272272
*/
273273
typedef struct tagFICOMPLEX {
274274
/// real part
@@ -371,7 +371,7 @@ typedef struct tagFICOMPLEX {
371371
#define FIICC_COLOR_IS_CMYK 0x01
372372

373373
FI_STRUCT (FIICCPROFILE) {
374-
SIGNED16 flags; //! info flag
374+
WORD flags; //! info flag
375375
DWORD size; //! profile's size measured in bytes
376376
void *data; //! points to a block of contiguous memory containing the profile
377377
};
@@ -1042,15 +1042,15 @@ DLL_API FITAG *DLL_CALLCONV FreeImage_CloneTag(FITAG *tag);
10421042
// tag getters and setters
10431043
DLL_API const char *DLL_CALLCONV FreeImage_GetTagKey(FITAG *tag);
10441044
DLL_API const char *DLL_CALLCONV FreeImage_GetTagDescription(FITAG *tag);
1045-
DLL_API SIGNED16 DLL_CALLCONV FreeImage_GetTagID(FITAG *tag);
1045+
DLL_API WORD DLL_CALLCONV FreeImage_GetTagID(FITAG *tag);
10461046
DLL_API FREE_IMAGE_MDTYPE DLL_CALLCONV FreeImage_GetTagType(FITAG *tag);
10471047
DLL_API DWORD DLL_CALLCONV FreeImage_GetTagCount(FITAG *tag);
10481048
DLL_API DWORD DLL_CALLCONV FreeImage_GetTagLength(FITAG *tag);
10491049
DLL_API const void *DLL_CALLCONV FreeImage_GetTagValue(FITAG *tag);
10501050

10511051
DLL_API BOOL DLL_CALLCONV FreeImage_SetTagKey(FITAG *tag, const char *key);
10521052
DLL_API BOOL DLL_CALLCONV FreeImage_SetTagDescription(FITAG *tag, const char *description);
1053-
DLL_API BOOL DLL_CALLCONV FreeImage_SetTagID(FITAG *tag, SIGNED16 id);
1053+
DLL_API BOOL DLL_CALLCONV FreeImage_SetTagID(FITAG *tag, WORD id);
10541054
DLL_API BOOL DLL_CALLCONV FreeImage_SetTagType(FITAG *tag, FREE_IMAGE_MDTYPE type);
10551055
DLL_API BOOL DLL_CALLCONV FreeImage_SetTagCount(FITAG *tag, DWORD count);
10561056
DLL_API BOOL DLL_CALLCONV FreeImage_SetTagLength(FITAG *tag, DWORD length);

FreeImage/FreeImageDll.Mod

+25-36
Original file line numberDiff line numberDiff line change
@@ -487,26 +487,26 @@ TYPE
487487

488488
(* ****************************** *)
489489
(*! used for easy accessing to pixels of various image types, see Scanline procs. ( Necati ) *)
490-
PtrLineRGB* = POINTER {UNTRACED, UNSAFE}TO ARRAY OF RGBTRIPLE; (* for accessing 24 bit lines, RGB *)
491-
PtrLineRGBA* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF RGBQUAD; (* for accessing 32 bit lines, RGBA *)
492-
PtrFISINT16* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF SIGNED16; (* for 16 bit integers *)
493-
PtrFIINT32* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF SIGNED32; (* for 32 bit integers *)
494-
PtrFIFLOAT* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF FLOAT32; (* for 32 bit real *)
495-
PtrFIDOUBLE* = POINTER {UNTRACED, UNSAFE}TO ARRAY OF FLOAT64; (* for 64 bit real *)
496-
497-
PtrFICOMPLEX* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF FICOMPLEX; (* 2x64 bits real, Complex *)
498-
PtrFIRGB16* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF FIRGB16; (* for 48-bit RGB, 3x16 bits *)
499-
PtrFIRGBA16* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF FIRGBA16; (* 64-bit RGBA, 4x16 bits *)
500-
PtrFIRGBF* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF FIRGBF; (* 96-bit RGB Float, 3*32 bits *)
501-
PtrFIRGBAF* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF FIRGBAF; (* 128-bit RGBA Float, 4x32 bits *)
490+
PtrLineRGB* = POINTER {UNTRACED, UNSAFE}TO ARRAY MAX(SIZE) OF RGBTRIPLE; (* for accessing 24 bit lines, RGB *)
491+
PtrLineRGBA* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF RGBQUAD; (* for accessing 32 bit lines, RGBA *)
492+
PtrFISINT16* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF SIGNED16; (* for 16 bit integers *)
493+
PtrFIINT32* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF SIGNED32; (* for 32 bit integers *)
494+
PtrFIFLOAT* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF FLOAT32; (* for 32 bit real *)
495+
PtrFIDOUBLE* = POINTER {UNTRACED, UNSAFE}TO ARRAY MAX(SIZE) OF FLOAT64; (* for 64 bit real *)
496+
497+
PtrFICOMPLEX* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF FICOMPLEX; (* 2x64 bits real, Complex *)
498+
PtrFIRGB16* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF FIRGB16; (* for 48-bit RGB, 3x16 bits *)
499+
PtrFIRGBA16* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF FIRGBA16; (* 64-bit RGBA, 4x16 bits *)
500+
PtrFIRGBF* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF FIRGBF; (* 96-bit RGB Float, 3*32 bits *)
501+
PtrFIRGBAF* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF FIRGBAF; (* 128-bit RGBA Float, 4x32 bits *)
502502

503503
Palette* = ARRAY 256 OF RGBQUAD;
504504
PtrPALETTE* = POINTER {UNTRACED, UNSAFE} TO Palette;
505505

506506
(* File IO routines *)
507507
FHandle* = ADDRESS;
508-
PSint* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF SIGNED16;
509-
Pint* = POINTER {UNTRACED, UNSAFE} TO ARRAY OF SIGNED32;
508+
PSint* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF SIGNED16;
509+
Pint* = POINTER {UNTRACED, UNSAFE} TO ARRAY MAX(SIZE) OF SIGNED32;
510510
FI_ReadProc* = PROCEDURE {PlatformCC} (buffer: ADDRESS; size: SIGNED32; count: SIGNED32; handle: FHandle): SIGNED32;
511511
FI_WriteProc* = PROCEDURE {PlatformCC} (buffer: ADDRESS; size: SIGNED32; count: SIGNED32; handle: FHandle): SIGNED32;
512512
FI_SeekProc* = PROCEDURE {PlatformCC} (handle: FHandle; offset: SIGNED32; origin: SIGNED32): PSint;
@@ -526,8 +526,8 @@ TYPE
526526
FIMETADATA* = POINTER {UNTRACED, UNSAFE} TO RECORD END; (* Handle to a metadata model *)
527527
FITAG* = POINTER {UNTRACED, UNSAFE} TO RECORD END; (* Handle to a FreeImage tag *)
528528

529-
OutputMessageFunction* = PROCEDURE {PlatformCC} (fif: IMAGE_FORMAT; msg: POINTER {UNSAFE} TO ARRAY OF CHAR);
530-
OutputMessageFunctionStdCall* = PROCEDURE {PlatformCC} (fif: IMAGE_FORMAT; msg: POINTER {UNSAFE} TO ARRAY OF CHAR);
529+
OutputMessageFunction* = PROCEDURE {PlatformCC} (fif: IMAGE_FORMAT; msg: POINTER {UNSAFE} TO ARRAY 1024 OF CHAR);
530+
OutputMessageFunctionStdCall* = PROCEDURE {PlatformCC} (fif: IMAGE_FORMAT; msg: POINTER {UNSAFE} TO ARRAY 1024 OF CHAR);
531531

532532

533533
CONST
@@ -1452,25 +1452,24 @@ BEGIN
14521452
END OnClose;
14531453

14541454
(* utilities *)
1455-
PROCEDURE GetStringFromAddr*(adr: POINTER {UNSAFE} TO ARRAY OF CHAR ): Strings.String;
1456-
VAR
1455+
(* Get string from address *)
1456+
PROCEDURE GetStringFromAddr*(adr: ADDRESS): Strings.String;
1457+
VAR s: POINTER {UNSAFE} TO ARRAY MAX(SIZE) OF CHAR;
14571458
str: Strings.String;
1458-
pos: SIZE;
1459+
pos: SIGNED32;
14591460
BEGIN
1460-
1461+
s := adr;
14611462
pos := 0;
14621463
IF adr # NIL THEN
1463-
WHILE adr[pos] # 0X DO INC(pos); END;
1464+
WHILE s[pos] # 0X DO INC(pos); END;
14641465
NEW(str, pos + 1);
14651466
pos := 0;
1466-
WHILE adr[pos] # 0X DO str[pos] := adr[pos]; INC(pos); END;
1467+
WHILE s[pos] # 0X DO str[pos] := s[pos]; INC(pos); END;
14671468

14681469
ELSE NEW(str, 1);
14691470
END;
1470-
14711471
str[pos] := 0X;
14721472
RETURN str;
1473-
14741473
END GetStringFromAddr;
14751474

14761475
(** wrapper procedure for getVersion() *)
@@ -1612,21 +1611,11 @@ BEGIN
16121611
END SaveImage;
16131612

16141613
(* called by FreeImage when error occurs *)
1615-
#IF UNIX THEN
1616-
PROCEDURE {C} MyOutputMessageFunction(fif: IMAGE_FORMAT; msg: POINTER {UNSAFE} TO ARRAY OF CHAR);
1617-
#ELSE
1618-
PROCEDURE {WINAPI} MyOutputMessageFunction(fif: IMAGE_FORMAT; msg: POINTER {UNSAFE} TO ARRAY OF CHAR);
1619-
#END
1620-
1621-
VAR
1622-
i: SIGNED32;
1614+
PROCEDURE {PlatformCC} MyOutputMessageFunction(fif: IMAGE_FORMAT; msg: POINTER {UNSAFE} TO ARRAY 1024 OF CHAR);
16231615
BEGIN
16241616
IF msg # NIL THEN
16251617
KernelLog.String("FreeImage ERROR: ");
1626-
i := 0;
1627-
(* limit msg length to 255 *)
1628-
WHILE (i < 255) & (msg[i] # 0X) DO KernelLog.Char( msg[i] ); INC( i ); END;
1629-
1618+
KernelLog.String(msg^);
16301619
KernelLog.String(", FIF_FORMAT= "); KernelLog.Int(fif, 0);
16311620
KernelLog.Ln;
16321621
END;

0 commit comments

Comments
 (0)