1 /*****************************************************************************\
2 ernieplatform.h : Interface for ernie
4 Copyright (c) 1996 - 2001, Hewlett-Packard Co.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
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 3. Neither the name of Hewlett-Packard nor the names of its
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
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
22 NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24 TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 \*****************************************************************************/
34 // Endianess of the architecture we're on
35 #ifdef APDK_LITTLE_ENDIAN
37 #define littleEndian 1
38 #define GetRed(x) (((x >> 16) & 0x0FF))
39 #define GetGreen(x) (((x >> 8) & 0x0FF))
40 #define GetBlue(x) ((x & 0x0FF))
43 #define littleEndian 0
44 #define GetRed(x) (((x >> 24) & 0x0FF))
45 #define GetGreen(x) (((x >> 16) & 0x0FF))
46 #define GetBlue(x) (((x >> 8) & 0x0FF))
49 /*#define GetRed(x) (((x >> 24) & 0x0FF))
50 #define GetGreen(x) (((x >> 16) & 0x0FF))
51 #define GetBlue(x) (((x >> 8) & 0x0FF))*/
53 // Slow down the system and gather stats or not.
54 #define kGatherStats 0
55 #define kDecompressStats 0
57 // ********** THIS IS NOT TRUE **************
58 // While it may seem like the need to be both
59 // big endian and little endian versions of
60 // these macros, due to the face that the
61 // shift command in general knows about the
62 // endian order, you get the same result
63 // from these commands no matter what order
64 // the bytes are in. Strange isn't it.
65 //#define GetRed(x) (((x >> 16) & 0x0FF))
66 //#define GetRed(x) (((x >> 24) & 0x0FF))
67 //#define GetGreen(x) (((x >> 8) & 0x0FF))
68 //#define GetGreen(x) (((x >> 16) & 0x0FF))
69 //#define GetBlue(x) ((x & 0x0FF))
70 //#define GetBlue(x) (((x >> 8) & 0x0FF))
71 // ******************************************
74 #define MIN(a,b) (((a)>=(b))?(b):(a))
77 #define MAX(a,b) (((a)<=(b))?(b):(a))
80 #define kWhite 0x00FFFFFE
82 //inline unsigned int get4Pixel(unsigned char *pixAddress);
83 //inline unsigned int get4Pixel(unsigned char *pixAddress)
84 //inline uint32_t get4Pixel(unsigned char *pixAddress);
86 inline uint32_t get4Pixel(unsigned char *pixAddress)
89 // unsigned int toReturn = *((unsigned int*)pixAddress); // load toReturn with XRGB
90 // toReturn &= kWhite; // Strip off unwanted X. EGW stripped lsb blue.
94 #ifdef APDK_LITTLE_ENDIAN
95 return (((unsigned int*)pixAddress)[0]) & kWhite;
97 return (((unsigned int*)pixAddress)[0]) & 0xFFFFFF00;
102 //inline unsigned int get4Pixel(unsigned char *pixAddress, int pixelOffset);
103 //inline unsigned int get4Pixel(unsigned char *pixAddress, int pixelOffset)
104 //inline uint32_t get4Pixel(unsigned char *pixAddress, int pixelOffset);
106 inline uint32_t get4Pixel(unsigned char *pixAddress, int pixelOffset)
108 // slower simple code
109 // unsigned int *uLongPtr = (unsigned int *)pixAddress;
110 // uLongPtr += pixelOffset;
112 // return *uLongPtr & kWhite;
114 #ifdef APDK_LITTLE_ENDIAN
115 return ((unsigned int*)pixAddress)[pixelOffset] & kWhite;
117 return ((unsigned int*)pixAddress)[pixelOffset] & 0xFFFFFF00;
121 //void put3Pixel(unsigned char *pixAddress, int pixelOffset, unsigned int pixel);
122 void put3Pixel(unsigned char *pixAddress, int pixelOffset, uint32_t pixel);
124 //inline void put4Pixel(unsigned char *pixAddress, int pixelOffset, unsigned int pixel);
125 //inline void put4Pixel(unsigned char *pixAddress, int pixelOffset, unsigned int pixel)
126 //inline void put4Pixel(unsigned char *pixAddress, int pixelOffset, uint32_t pixel);
128 inline void put4Pixel(unsigned char *pixAddress, int pixelOffset, uint32_t pixel)
130 #ifdef APDK_LITTLE_ENDIAN
131 (((unsigned int*)pixAddress)[pixelOffset] = pixel & kWhite);
133 (((unsigned int*)pixAddress)[pixelOffset] = pixel & 0xFFFFFF00);