| 1 |
/* |
| 2 |
Copyright (c) 1993-2008, Cognitive Technologies |
| 3 |
All rights reserved. |
| 4 |
|
| 5 |
Разрешается повторное распространение и использование как в виде исходного кода, |
| 6 |
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий: |
| 7 |
|
| 8 |
* При повторном распространении исходного кода должны оставаться указанное |
| 9 |
выше уведомление об авторском праве, этот список условий и последующий |
| 10 |
отказ от гарантий. |
| 11 |
* При повторном распространении двоичного кода в документации и/или в |
| 12 |
других материалах, поставляемых при распространении, должны сохраняться |
| 13 |
указанная выше информация об авторском праве, этот список условий и |
| 14 |
последующий отказ от гарантий. |
| 15 |
* Ни название Cognitive Technologies, ни имена ее сотрудников не могут |
| 16 |
быть использованы в качестве средства поддержки и/или продвижения |
| 17 |
продуктов, основанных на этом ПО, без предварительного письменного |
| 18 |
разрешения. |
| 19 |
|
| 20 |
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК |
| 21 |
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ, |
| 22 |
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ |
| 23 |
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ |
| 24 |
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ |
| 25 |
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ |
| 26 |
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ |
| 27 |
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ, |
| 28 |
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ |
| 29 |
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ, |
| 30 |
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ |
| 31 |
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ. |
| 32 |
|
| 33 |
Redistribution and use in source and binary forms, with or without modification, |
| 34 |
are permitted provided that the following conditions are met: |
| 35 |
|
| 36 |
* Redistributions of source code must retain the above copyright notice, |
| 37 |
this list of conditions and the following disclaimer. |
| 38 |
* Redistributions in binary form must reproduce the above copyright notice, |
| 39 |
this list of conditions and the following disclaimer in the documentation |
| 40 |
and/or other materials provided with the distribution. |
| 41 |
* Neither the name of the Cognitive Technologies nor the names of its |
| 42 |
contributors may be used to endorse or promote products derived from this |
| 43 |
software without specific prior written permission. |
| 44 |
|
| 45 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 46 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 47 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 48 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 49 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 50 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 51 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 52 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 53 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 54 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 55 |
*/ |
| 56 |
|
| 57 |
#ifndef __IMGACCS_H |
| 58 |
#define __IMGACCS_H |
| 59 |
|
| 60 |
#ifndef __GLOBUS_H |
| 61 |
#include "globus.h" |
| 62 |
#endif |
| 63 |
|
| 64 |
#pragma pack(4) |
| 65 |
|
| 66 |
// |
| 67 |
// Palette entry descriptor: |
| 68 |
|
| 69 |
typedef struct tagImgRGB |
| 70 |
{ |
| 71 |
uchar bRed; |
| 72 |
uchar bGreen; |
| 73 |
uchar bBlue; |
| 74 |
uchar breserved; |
| 75 |
} TImgRGB; |
| 76 |
|
| 77 |
_SETTYPES(TImgRGB) |
| 78 |
// |
| 79 |
// Export/import image descriptor. |
| 80 |
typedef struct tagImgInfo |
| 81 |
{ |
| 82 |
uint16_t wImageHeight; // in pixels |
| 83 |
uint16_t wImageWidth; // in pixels |
| 84 |
uint16_t wImageByteWidth; // in bytes |
| 85 |
uint16_t wImageDisplacement; // in pixels |
| 86 |
|
| 87 |
uint16_t wResolutionX; // in dpi |
| 88 |
uint16_t wResolutionY; // in dpi |
| 89 |
uchar bFotoMetrics; // 1, if white is highest number, |
| 90 |
// 0 -if white is lowest number. |
| 91 |
uchar bCompression; // compression of delivered strips |
| 92 |
#define CM_UNCOMPRESSED 0x0010 |
| 93 |
#define CM_GROUP4 0x0020 |
| 94 |
#define CM_JPEG 0x0040 |
| 95 |
#define CM_2XX 0x0080 |
| 96 |
|
| 97 |
|
| 98 |
uint16_t wAddX; // "real" coordinates of |
| 99 |
uint16_t wAddY; // upper-left corner (in pixels). |
| 100 |
|
| 101 |
uchar bSamplesPerPixel; |
| 102 |
uchar bBitsPerSample; |
| 103 |
uchar bPlanes; |
| 104 |
uchar LinesOrder; // 0 - as DDB, 1 as DIB. |
| 105 |
#define LO_FIRSTFIRST 0 |
| 106 |
#define LO_FIRSTLAST 1 |
| 107 |
int16_t PaletteSize; |
| 108 |
TImgRGB* Palette; |
| 109 |
|
| 110 |
uchar ByteAlign; |
| 111 |
#define BA_COMPACT 1 |
| 112 |
#define BA_TWOBYTE 2 |
| 113 |
#define BA_FOURBYTE 3 |
| 114 |
|
| 115 |
uchar spare[15]; // reserved for future. |
| 116 |
Err16 error; |
| 117 |
int16_t step; // step of sender/receiver conversation. |
| 118 |
#define CS_QUEST 0x0000 // struct has no information; |
| 119 |
// it should be filled. |
| 120 |
//(should be set by receiver when it calls |
| 121 |
// SenderOpenCallback first time). |
| 122 |
|
| 123 |
#define CS_OFFER 0x0001 // struct bears information about |
| 124 |
// available image and possible variations |
| 125 |
// of image representation. |
| 126 |
// (should be set by sender, filling |
| 127 |
// ImageInfo first time.) |
| 128 |
|
| 129 |
#define CS_BID 0x0002 // struct bears a request of receiver to sender. |
| 130 |
|
| 131 |
#define CS_CONFIRM 0x0003 // sender confirms image characteristics |
| 132 |
// (final step of conversation)/ |
| 133 |
// |
| 134 |
// Available: |
| 135 |
uint32_t avFlags; |
| 136 |
// Line numbering |
| 137 |
#define AV_LO_FIRSTFIRST 0x0001 |
| 138 |
#define AV_LO_FIRSTLAST 0x0002 |
| 139 |
// Photometric |
| 140 |
#define AV_PH_WHITEMIN 0x0004 |
| 141 |
#define AV_PH_WHITEMAX 0x0008 |
| 142 |
// Compression |
| 143 |
#define AV_CM_UNCOMPRESSED 0x0010 |
| 144 |
#define AV_CM_GROUP4 0x0020 |
| 145 |
#define AV_CM_JPEG 0x0040 |
| 146 |
#define AV_CM_2XX 0x0080 |
| 147 |
|
| 148 |
// Image transformation |
| 149 |
#define AV_IT_SCALING 0x0100 |
| 150 |
#define AV_IT_GREY 0x0200 |
| 151 |
#define AV_IT_BW 0x0400 |
| 152 |
#define AV_IT_COLOR 0x0800 |
| 153 |
|
| 154 |
// Image presentation |
| 155 |
#define AV_IP_PLANES 0x1000 |
| 156 |
#define AV_IP_SAMPLES 0x2000 |
| 157 |
#define AV_IP_PALETTE 0x4000 |
| 158 |
|
| 159 |
|
| 160 |
// |
| 161 |
// Byte Width Alignment |
| 162 |
#define AV_BA_COMPACT 0x10000l |
| 163 |
#define AV_BA_TWOBYTE 0x20000l |
| 164 |
#define AV_BA_FOURBYTE 0x40000l |
| 165 |
} TImgInfo; |
| 166 |
|
| 167 |
_SETTYPES(TImgInfo) |
| 168 |
|
| 169 |
enum EImageType |
| 170 |
{ ITE_FIRST =0, |
| 171 |
ITE_BW, ITE_Gr16, ITE_Gr256, |
| 172 |
ITE_RGB, ITE_Planes3, |
| 173 |
ITE_Palette2, ITE_Palette16, ITE_Palette256, |
| 174 |
ITE_Unregistered, |
| 175 |
ITE_LAST |
| 176 |
}; |
| 177 |
|
| 178 |
#ifdef __cplusplus |
| 179 |
inline EImageType GetImageType (TImgInfo *info) |
| 180 |
{ |
| 181 |
switch(info ->PaletteSize) // palette image |
| 182 |
{ |
| 183 |
case 2: return ITE_Palette2; |
| 184 |
case 16: return ITE_Palette16; |
| 185 |
case 256: return ITE_Palette256; |
| 186 |
default : return ITE_Unregistered; |
| 187 |
case 0: break; |
| 188 |
} |
| 189 |
// no palette presents |
| 190 |
if (info ->bPlanes >1) |
| 191 |
return (info ->bPlanes ==3)? ITE_Planes3 :ITE_Unregistered; |
| 192 |
if (info ->bPlanes ==0) return ITE_Unregistered; |
| 193 |
|
| 194 |
// one plane images |
| 195 |
if (info ->bSamplesPerPixel >1) |
| 196 |
return (info ->bSamplesPerPixel ==3)? ITE_RGB :ITE_Unregistered; |
| 197 |
if (info ->bSamplesPerPixel ==0) return ITE_Unregistered; |
| 198 |
|
| 199 |
// one sample per pixel images |
| 200 |
switch (info ->bBitsPerSample) |
| 201 |
{ |
| 202 |
case 1: return ITE_BW; |
| 203 |
case 4: return ITE_Gr16; |
| 204 |
case 8: return ITE_Gr256; |
| 205 |
} |
| 206 |
return ITE_Unregistered; |
| 207 |
}; |
| 208 |
#endif |
| 209 |
|
| 210 |
|
| 211 |
// |
| 212 |
// Import callbacks prototypes: |
| 213 |
|
| 214 |
typedef Bool (*TImpImgOpen) (TImgInfo * lpImageInfo); |
| 215 |
typedef int32_t (*TImpImgRead) (uchar* lpImage, int32_t wMaxSize); |
| 216 |
typedef int16_t (*TImpImgGetBlock)(uchar* lpBuff, int16_t fstLine, int16_t nLines); |
| 217 |
typedef Bool (*TImpImgClose)(void); |
| 218 |
|
| 219 |
// |
| 220 |
// Import callbacks complect: |
| 221 |
typedef struct tagImgImport |
| 222 |
{ |
| 223 |
TImpImgOpen Open; |
| 224 |
TImpImgRead Read; // may be NULL |
| 225 |
TImpImgGetBlock Get; // may be NULL |
| 226 |
TImpImgClose Close; |
| 227 |
}TImgImport; |
| 228 |
_SETTYPES(TImgImport) |
| 229 |
// |
| 230 |
// Export callbacks prototypes: |
| 231 |
|
| 232 |
typedef Bool (*TExpImgOpen) (TImgInfo * lpImageInfo); |
| 233 |
typedef int32_t (*TExpImgWrite) (uchar* lpImage, int32_t wMaxSize); |
| 234 |
typedef int16_t (*TExpImgSetBlock)(uchar* lpBuff, int16_t fstLine, int16_t nLines); |
| 235 |
typedef Bool (*TExpImgClose) (void); |
| 236 |
|
| 237 |
// |
| 238 |
// Export callbacl complects: |
| 239 |
|
| 240 |
typedef struct tagImgExport |
| 241 |
{ |
| 242 |
TExpImgOpen Open; |
| 243 |
TExpImgWrite Write; // may be NULL |
| 244 |
TExpImgSetBlock Set; // may be NULL |
| 245 |
TExpImgClose Close; |
| 246 |
} TImgExport; |
| 247 |
|
| 248 |
|
| 249 |
_SETTYPES(TImgExport) |
| 250 |
|
| 251 |
|
| 252 |
typedef struct tagZoneFunc |
| 253 |
{ |
| 254 |
Bool16 (* Get) (Rect16 * zone); |
| 255 |
Bool16 (* Set) (CRect16 * zone); |
| 256 |
Bool16 (* Enable) (Bool16 mode); |
| 257 |
|
| 258 |
} TZoneFunc; _SETTYPES(TZoneFunc); |
| 259 |
// |
| 260 |
// Obsolete image export/import style. (For Tiger compatibilyty.) |
| 261 |
|
| 262 |
typedef struct tagTiger_ImageInfo |
| 263 |
{ |
| 264 |
uint16_t wImageHeight; /* Height of the image in lines */ |
| 265 |
uint16_t wImageWidth; /* Width of the image in pixels */ |
| 266 |
uint16_t wImageByteWidth; /* Size of the image line in bytes */ |
| 267 |
uint16_t wImageDisplacement; /* Displacement of the first pixel of */ |
| 268 |
/* image line in pixels, usually 0 */ |
| 269 |
uint16_t wResolutionX; /* Resolution by X-axe */ |
| 270 |
uint16_t wResolutionY; /* Resolution by Y-axe */ |
| 271 |
uchar bFotoMetrics; /* White pixel */ |
| 272 |
uchar bUnused; /* not used; for alignment purpose only */ |
| 273 |
|
| 274 |
uint16_t wAddX; |
| 275 |
uint16_t wAddY; |
| 276 |
} Tiger_ImageInfo; |
| 277 |
|
| 278 |
#pragma pack() |
| 279 |
|
| 280 |
|
| 281 |
typedef Tiger_ImageInfo TIGER_IMAGEINFO; |
| 282 |
typedef Tiger_ImageInfo* LPTIGER_IMAGEINFO; |
| 283 |
|
| 284 |
#if defined( _MSC_VER ) && ( _MSC_VER == 800 ) /* MSVC 1.5 */ |
| 285 |
typedef Bool16 (_far _pascal _export *TImageOpen )(Tiger_ImageInfo* lpImageInfo); |
| 286 |
typedef int16_t (_far _pascal _export *TImageRead )(uchar* lpImage, uint16_t wMaxSize); |
| 287 |
typedef int16_t (_far _pascal _export *TImageGetBlock )(uchar* lpBuff, int16_t fstLine, int16_t nLines); |
| 288 |
typedef Bool16 (_far _pascal _export *TImageClose )(void); |
| 289 |
#else |
| 290 |
#ifdef __cplusplus |
| 291 |
extern "C" { |
| 292 |
#endif |
| 293 |
typedef int16_t (*TImageGetBlock )(uchar* lpBuff, int16_t fstLine, int16_t nLines); |
| 294 |
typedef Bool16 (*TImageOpen )(Tiger_ImageInfo* lpImageInfo); |
| 295 |
typedef int16_t (*TImageRead )(uchar* lpImage, uint16_t wMaxSize); |
| 296 |
typedef Bool16 (*TImageClose )(void); |
| 297 |
#ifdef __cplusplus |
| 298 |
} |
| 299 |
#endif |
| 300 |
#endif |
| 301 |
|
| 302 |
typedef struct tagImageAccess |
| 303 |
{ |
| 304 |
TImageOpen f_op; |
| 305 |
TImageRead f_re; // may be NULL |
| 306 |
TImageGetBlock f_gb; // may be NULL |
| 307 |
TImageClose f_cl; |
| 308 |
} TImageAccess; |
| 309 |
|
| 310 |
// backward names compatibility |
| 311 |
typedef TImageOpen BWImgOpenFunc ; |
| 312 |
typedef TImageRead BWImgReadFunc ; |
| 313 |
typedef TImageClose BWImgCloseFunc; |
| 314 |
typedef TImageAccess TigerImageFunc; |
| 315 |
|
| 316 |
|
| 317 |
#endif |