1 | //-----------------------------------------------------------------------------
|
---|
2 | // -------------------
|
---|
3 | // File ....: bitmap.h
|
---|
4 | // -------------------
|
---|
5 | // Author...: Tom Hudson
|
---|
6 | // Date ....: Sptember 1994
|
---|
7 | //
|
---|
8 | // History .: Sep, 01 1994 - Started serious coding
|
---|
9 | // Oct, 18 1994 - First major revision for DLLs, restructuring
|
---|
10 | // Jul, 10 1995 - Began working with it (Gus J Grubba)
|
---|
11 | //
|
---|
12 | //-----------------------------------------------------------------------------
|
---|
13 |
|
---|
14 | #ifndef BITMAP_H_DEFINED
|
---|
15 | #define BITMAP_H_DEFINED
|
---|
16 |
|
---|
17 | #define NOAVIFILE
|
---|
18 | #include <vfw.h>
|
---|
19 | #undef NOAVIFILE
|
---|
20 |
|
---|
21 | #include "linklist.h"
|
---|
22 |
|
---|
23 | //-- Defines that may change with compiler
|
---|
24 |
|
---|
25 | #define INTBITS (sizeof(int) * 8)
|
---|
26 |
|
---|
27 | //-- Class ID's for various DLL's
|
---|
28 |
|
---|
29 | #define IMGCLASSID 1
|
---|
30 | #define CYCLECLASSID 2
|
---|
31 | #define FLICCLASSID 5
|
---|
32 | #define TARGACLASSID 6
|
---|
33 | #define YUVCLASSID 7
|
---|
34 | #define FBCLASSID 8
|
---|
35 | #define WSDCLASSID 9
|
---|
36 | #define IFLCLASSID 10
|
---|
37 | #define BMPCLASSID 11
|
---|
38 | #define JPEGCLASSID 12
|
---|
39 | #define TARGAPLSCLASSID 13
|
---|
40 | #define AVICLASSID 14
|
---|
41 | #define RLACLASSID 15
|
---|
42 |
|
---|
43 | //-- local definitions
|
---|
44 |
|
---|
45 | class BitmapManager;
|
---|
46 | class BitmapStorage;
|
---|
47 | class BitmapFilter;
|
---|
48 | class BitmapDither;
|
---|
49 | class BitmapInfo;
|
---|
50 | class BitmapPicker;
|
---|
51 | class BitmapIO;
|
---|
52 | class Bitmap;
|
---|
53 |
|
---|
54 | //-- Temporary definitions to make the compiler happy
|
---|
55 |
|
---|
56 | class GraphicsWindow;
|
---|
57 | class BMMInterface;
|
---|
58 | class DllDir;
|
---|
59 |
|
---|
60 | //-- External data
|
---|
61 |
|
---|
62 | extern int TheSystemFrame; // TO DO: Move to App data structure?
|
---|
63 |
|
---|
64 | //-----------------------------------------------------------------------------
|
---|
65 | //-- The Primary Bitmap Manager Object
|
---|
66 | //
|
---|
67 |
|
---|
68 | extern BMMExport BitmapManager *TheManager; // TO DO: Move to App data structure?
|
---|
69 |
|
---|
70 | //-- Common Macros ------------------------------------------------------------
|
---|
71 |
|
---|
72 | //-- Just to make it shorter
|
---|
73 |
|
---|
74 | #define bVirtual BMMExport virtual
|
---|
75 |
|
---|
76 | //-- Set up a NULL macro
|
---|
77 |
|
---|
78 | #ifndef NULL
|
---|
79 | #define NULL (0)
|
---|
80 | #endif
|
---|
81 |
|
---|
82 | //-- Pixel storage classes ----------------------------------------------------
|
---|
83 |
|
---|
84 | typedef struct {
|
---|
85 | BYTE r,g,b;
|
---|
86 | } BMM_Color_24;
|
---|
87 |
|
---|
88 | typedef struct {
|
---|
89 | BYTE r,g,b,a;
|
---|
90 | } BMM_Color_32;
|
---|
91 |
|
---|
92 | typedef struct {
|
---|
93 | WORD r,g,b;
|
---|
94 | } BMM_Color_48;
|
---|
95 |
|
---|
96 | typedef struct {
|
---|
97 | WORD r,g,b,a;
|
---|
98 | } BMM_Color_64;
|
---|
99 |
|
---|
100 | //-- Generic bitmap information structure -------------------------------------
|
---|
101 |
|
---|
102 | typedef struct {
|
---|
103 | int width,height;
|
---|
104 | float aspect,gamma;
|
---|
105 | DWORD flags;
|
---|
106 | } BMMImageInfo;
|
---|
107 |
|
---|
108 | //-- Basic bitmap types supported by Bitmap Manager
|
---|
109 |
|
---|
110 | #define BMM_NO_TYPE 0 // Not allocated yet
|
---|
111 | #define BMM_LINE_ART 1
|
---|
112 | #define BMM_PALETTED 2
|
---|
113 | #define BMM_GRAY_8 3
|
---|
114 | #define BMM_GRAY_16 4
|
---|
115 | #define BMM_TRUE_16 5
|
---|
116 | #define BMM_TRUE_32 6
|
---|
117 | #define BMM_TRUE_64 7
|
---|
118 |
|
---|
119 | //-- Information Only
|
---|
120 |
|
---|
121 | #define BMM_TRUE_24 8
|
---|
122 | #define BMM_TRUE_48 9
|
---|
123 | #define BMM_YUV_422 10
|
---|
124 | #define BMM_BMP_4 11 //-- Windows BMP 16 color bitmap
|
---|
125 | #define BMM_PAD_24 12 //-- Padded 24 bit (in a 32 bit register)
|
---|
126 |
|
---|
127 | //-- Textual Limits
|
---|
128 |
|
---|
129 | #define MAX_DESCRIPTION 256
|
---|
130 |
|
---|
131 | //-- The number of bitmap formats supported internally
|
---|
132 |
|
---|
133 | //#define BMM_FORMATS 6
|
---|
134 |
|
---|
135 | //-- File types
|
---|
136 |
|
---|
137 | //#define BMM_NOTYPE 0
|
---|
138 | //#define BMM_TARGA 1 // System Targa I/O driver
|
---|
139 | //#define BMM_GIF 2 // System GIF I.O driver
|
---|
140 |
|
---|
141 | //-- Gamma limits
|
---|
142 |
|
---|
143 | #define MINGAMMA 0.2f
|
---|
144 | #define MAXGAMMA 5.0f
|
---|
145 |
|
---|
146 | //-- openMode values
|
---|
147 |
|
---|
148 | #define BMM_NOT_OPEN 0 // Not opened yet
|
---|
149 | #define BMM_OPEN_R 1 // Read-only
|
---|
150 | #define BMM_OPEN_W 2 // Write
|
---|
151 |
|
---|
152 | //-----------------------------------------------------------------------------
|
---|
153 | //-----------------------------------------------------------------------------
|
---|
154 | //-- Error Codes for BMMRES type functions
|
---|
155 |
|
---|
156 | typedef unsigned short BMMRES; // Traps the use of int or BOOL
|
---|
157 |
|
---|
158 | #define BMMRES_SUCCESS 0
|
---|
159 | #define BMMRES_ERRORTAKENCARE 1 // Error - Function has already taken action
|
---|
160 | #define BMMRES_FILENOTFOUND 2
|
---|
161 | #define BMMRES_MEMORYERROR 3
|
---|
162 | #define BMMRES_NODRIVER 4 // Device driver responsible for image not present
|
---|
163 | #define BMMRES_IOERROR 5
|
---|
164 | #define BMMRES_INVALIDFORMAT 6
|
---|
165 | #define BMMRES_CORRUPTFILE 7
|
---|
166 | #define BMMRES_SINGLEFRAME 8 // Goto request on a single frame image
|
---|
167 | #define BMMRES_INVALIDUSAGE 9 // Bad argument passed to function (Developer Mistake)
|
---|
168 | #define BMMRES_ERRORRETRY 10 // User selected "Retry" from error dialogue
|
---|
169 | #define BMMRES_NUMBEREDFILENAMEERROR 11
|
---|
170 | #define BMMRES_INTERNALERROR 12
|
---|
171 | #define BMMRES_BADFILEHEADER 13
|
---|
172 | #define BMMRES_CANTSTORAGE 14
|
---|
173 | #define BMMRES_RETRY 15
|
---|
174 | #define BMMRES_BADFRAME 16 // Invalid Frame Number Requested
|
---|
175 |
|
---|
176 | //-----------------------------------------------------------------------------
|
---|
177 | //-----------------------------------------------------------------------------
|
---|
178 | //-- BitmapIO usage types ( returned by BitmapIO::Capability() )
|
---|
179 |
|
---|
180 | #define BMMIO_NONE 0 // Not defined yet
|
---|
181 |
|
---|
182 | #define BMMIO_READER (1<<0) // Reads images
|
---|
183 | #define BMMIO_WRITER (1<<1) // Writes images
|
---|
184 | #define BMMIO_EXTENSION (1<<2) // Uses file extension (File Filter Type)
|
---|
185 | #define BMMIO_MULTIFRAME (1<<3) // "File" contains multiple frames (i.e. FLC, AVI)
|
---|
186 |
|
---|
187 | #define BMMIO_THREADED (1<<4) // Thread aware plug-in
|
---|
188 | #define BMMIO_RANDOM_ACCESS (1<<5) // Can read and/or write frames in any order
|
---|
189 | #define BMMIO_NON_CONCURRENT_ACCESS (1<<6) // Cannot handle multiple, concurrent requests (FLC, AVI, VTR's, etc)
|
---|
190 |
|
---|
191 | #define BMMIO_OWN_VIEWER (1<<7) // Driver has its own image viewer for its image type.
|
---|
192 |
|
---|
193 | //-- Frame Buffers
|
---|
194 |
|
---|
195 | #define BMMIO_FRAMEBUFFER (1<<7) // Frame Buffer Driver
|
---|
196 | #define BMMIO_GRABBER (1<<8) // Device Grabs Video
|
---|
197 |
|
---|
198 | //-- If the device is able to show its own image info dialogue this flag will be
|
---|
199 | // set. Otherwise, the host must use BitmapManager::GetImageInfo() and display
|
---|
200 | // a generic info dialogue.
|
---|
201 |
|
---|
202 | #define BMMIO_INFODLG (1<<9) // Has Info Dialog
|
---|
203 |
|
---|
204 |
|
---|
205 | //-- Special IFL device
|
---|
206 |
|
---|
207 | #define BMMIO_IFL (1<<28)
|
---|
208 |
|
---|
209 | //-- There is only a single call to the plug-in's control panel but the call specifies
|
---|
210 | // the nature of the operation going on. It's up to the plug-in to provide different
|
---|
211 | // interfaces if needed. If one control serves two or more services, all the pertinent
|
---|
212 | // flags should be set.
|
---|
213 |
|
---|
214 | #define BMMIO_CONTROLREAD (1<<29) // Device Driver has Control Panel for Read Operations
|
---|
215 | #define BMMIO_CONTROLWRITE (1<<30) // Device Driver has Control Panel for Write Operations
|
---|
216 | #define BMMIO_CONTROLGENERIC (1<<31) // Device Driver has a generic Control Panel
|
---|
217 |
|
---|
218 | //-----------------------------------------------------------------------------
|
---|
219 | //-- Bitmap close options
|
---|
220 |
|
---|
221 | #define BMM_CLOSE_COMPLETE 0
|
---|
222 | #define BMM_CLOSE_ABANDON 1
|
---|
223 |
|
---|
224 | //-- Filter Types
|
---|
225 |
|
---|
226 | #define BMM_FILTER_NONE 0
|
---|
227 | #define BMM_FILTER_DUMMY 1
|
---|
228 | #define BMM_FILTER_SUM 2
|
---|
229 | #define BMM_FILTER_PYRAMID 3
|
---|
230 |
|
---|
231 | //-- Filter Flag values
|
---|
232 |
|
---|
233 | #define BMM_FILTER_NOFLAGS ((DWORD)0)
|
---|
234 | #define BMM_FILTER_LERP_WRAP ((DWORD)(1<<0))
|
---|
235 |
|
---|
236 | //-- Dither Types
|
---|
237 |
|
---|
238 | #define BMM_DITHER_NONE 0
|
---|
239 | #define BMM_DITHER_FLOYD 1
|
---|
240 |
|
---|
241 | //-- Pyramidal filter information
|
---|
242 |
|
---|
243 | #define MAX_PYRAMID_DEPTH 12
|
---|
244 | #define LAYER_DIM MAX_PYRAMID_DEPTH+1
|
---|
245 |
|
---|
246 | typedef struct {
|
---|
247 | WORD dmax;
|
---|
248 | void *map[LAYER_DIM];
|
---|
249 | void *alpha[LAYER_DIM];
|
---|
250 | } BMM_Pyramid;
|
---|
251 |
|
---|
252 | //-- Summed-area table information
|
---|
253 |
|
---|
254 | typedef struct {
|
---|
255 | DWORD *sat_r,*sat_g,*sat_b,*sat_a;
|
---|
256 | } BMM_SAT;
|
---|
257 |
|
---|
258 | //-- Bitmap::CopyImage options
|
---|
259 |
|
---|
260 | #define COPY_IMAGE_CROP 0 // Copy image to current map size w/cropping if necessary
|
---|
261 | #define COPY_IMAGE_RESIZE_LO_QUALITY 1 // Resize source image to destination map size (draft)
|
---|
262 | #define COPY_IMAGE_RESIZE_HI_QUALITY 2 // Resize source image to destination map size (final)
|
---|
263 | #define COPY_IMAGE_USE_CUSTOM 3 // Based on Image Input Options (BitmapInfo *)
|
---|
264 |
|
---|
265 | // Class for storing a linked list of file extension strings
|
---|
266 | MakeLinkedList(TSTR);
|
---|
267 |
|
---|
268 |
|
---|
269 |
|
---|
270 |
|
---|
271 | //-----------------------------------------------------------------------------
|
---|
272 | //-- GBuffer defines
|
---|
273 | //
|
---|
274 |
|
---|
275 | // Recognized types of channels
|
---|
276 | #define BMM_CHAN_TYPE_UNKNOWN 0
|
---|
277 | #define BMM_CHAN_TYPE_1 1 // 1 bit per pixel
|
---|
278 | #define BMM_CHAN_TYPE_8 2 // 1 byte per pixel
|
---|
279 | #define BMM_CHAN_TYPE_16 3 // 1 word per pixel
|
---|
280 | #define BMM_CHAN_TYPE_32 4 // 2 words per pixel
|
---|
281 | #define BMM_CHAN_TYPE_48 5 // 3 words per pixel
|
---|
282 | #define BMM_CHAN_TYPE_64 6 // 4 words per pixel
|
---|
283 |
|
---|
284 | // Recognized channel ID's (number of bits in parentheses in comments)
|
---|
285 |
|
---|
286 | #define BMM_CHAN_NONE 0
|
---|
287 | #define BMM_CHAN_Z (1<<0) // (32) Z-buffer depth, float
|
---|
288 | #define BMM_CHAN_MTL_ID (1<<1) // ( 8) ID assigned to mtl via mtl editor
|
---|
289 | #define BMM_CHAN_NODE_ID (1<<2) // (16) ID assigned to node via properties
|
---|
290 | #define BMM_CHAN_UV (1<<3) // (64) UV coordinates - Point2
|
---|
291 | #define BMM_CHAN_NORMAL (1<<4) // (32) Normal vector in view space, compressed
|
---|
292 | #define BMM_CHAN_REALPIX (1<<5) // (32) Non clamped colors in "RealPixel" format
|
---|
293 |
|
---|
294 | //-----------------------------------------------------------------------------
|
---|
295 | //-- I/O Handler
|
---|
296 | //
|
---|
297 |
|
---|
298 | class BMM_IOHandler {
|
---|
299 |
|
---|
300 | //-- Name and Capabilities ------------------------
|
---|
301 |
|
---|
302 | TCHAR ioShortDesc[MAX_DESCRIPTION];
|
---|
303 | TCHAR ioLongDesc[MAX_DESCRIPTION];
|
---|
304 | DWORD ioCapabilities;
|
---|
305 |
|
---|
306 | //-- Extension for file types
|
---|
307 |
|
---|
308 | TSTRList ioExtension;
|
---|
309 |
|
---|
310 | //-- DLL Handler ----------------------------------
|
---|
311 |
|
---|
312 | ClassDesc *cd;
|
---|
313 |
|
---|
314 | public:
|
---|
315 |
|
---|
316 | BMMExport BMM_IOHandler();
|
---|
317 |
|
---|
318 | BMMExport TCHAR *ShortDescription ( const TCHAR *d = NULL );
|
---|
319 | BMMExport TCHAR *LongDescription ( const TCHAR *d = NULL );
|
---|
320 | BMMExport TCHAR *Extension ( int index, const TCHAR *e = NULL );
|
---|
321 | BMMExport int NumExtensions ( ) { return ioExtension.Count(); }
|
---|
322 |
|
---|
323 | BMMExport void SetCD ( ClassDesc *dll ) { cd = dll;};
|
---|
324 | BMMExport ClassDesc *GetCD ( ) { return cd;};
|
---|
325 |
|
---|
326 | BMMExport void SetCapabilities ( DWORD cap ) { ioCapabilities |= cap;};
|
---|
327 | BMMExport DWORD GetCapabilities ( ) { return (ioCapabilities);};
|
---|
328 | BMMExport BOOL TestCapabilities ( DWORD cap ) { return (ioCapabilities & cap);};
|
---|
329 | BMMExport BMM_IOHandler& operator=(BMM_IOHandler &from);
|
---|
330 | };
|
---|
331 |
|
---|
332 | //-----------------------------------------------------------------------------
|
---|
333 | //-- List of I/O Handlers
|
---|
334 | //
|
---|
335 |
|
---|
336 | // Class for storing a linked list of Bitmap Manager BMM_IOHandler objects
|
---|
337 | MakeLinkedList(BMM_IOHandler);
|
---|
338 |
|
---|
339 | class BMM_IOList: public BMM_IOHandlerList {
|
---|
340 |
|
---|
341 | BOOL listed;
|
---|
342 |
|
---|
343 | public:
|
---|
344 |
|
---|
345 | BMM_IOList ( ) { listed = FALSE; }
|
---|
346 |
|
---|
347 | BOOL Listed ( BOOL f) { listed = f; return (listed);};
|
---|
348 | BOOL Listed ( ) { return (listed);};
|
---|
349 |
|
---|
350 | BMMExport int FindDevice ( const TCHAR *name);
|
---|
351 | BMMExport int FindDeviceFromFilename ( const TCHAR *name);
|
---|
352 | BMMExport int ResolveDevice ( BitmapInfo *bi );
|
---|
353 | BMMExport DWORD GetDeviceCapabilities ( const TCHAR *name);
|
---|
354 |
|
---|
355 | //-- This Creates an Instance - Make sure to "delete" it after use.
|
---|
356 |
|
---|
357 | BMMExport BitmapIO *CreateDevInstance( const TCHAR *d );
|
---|
358 | BMMExport BitmapIO *CreateDevInstance( int idx );
|
---|
359 |
|
---|
360 | };
|
---|
361 |
|
---|
362 |
|
---|
363 |
|
---|
364 | //-----------------------------------------------------------------------------
|
---|
365 | //-- RenderInfo Class
|
---|
366 | //
|
---|
367 |
|
---|
368 | enum ProjectionType { ProjPerspective=0, ProjParallel=1 };
|
---|
369 |
|
---|
370 | class RenderInfo {
|
---|
371 | public:
|
---|
372 | RenderInfo();
|
---|
373 | ProjectionType projType;
|
---|
374 | float kx,ky; // 3D to 2D projection scale factor
|
---|
375 | float xc,yc; // screen origin
|
---|
376 | BOOL fieldRender; // field rendered?
|
---|
377 | BOOL fieldOdd; // if true, the first field is Odd lines
|
---|
378 | // Render time and tranformations for the 2 fields, if field rendering.
|
---|
379 | // If not, use renderTime[0], etc.
|
---|
380 | TimeValue renderTime[2];
|
---|
381 | Matrix3 worldToCam[2];
|
---|
382 | Matrix3 camToWorld[2];
|
---|
383 | BMMExport Point2 MapWorldToScreen(Point3 p, int field=0) { return MapCamToScreen(worldToCam[field]*p);}
|
---|
384 | BMMExport Point2 MapCamToScreen(Point3 p); // map point in camera space to screen
|
---|
385 | BMMExport Ray MapScreenToCamRay(Point2 p); // get viewing ray through screen point, in camera space
|
---|
386 | BMMExport Ray MapScreenToWorldRay(Point2 p, int field=0); // get viewing ray through screen point, in world space
|
---|
387 | };
|
---|
388 |
|
---|
389 | //-----------------------------------------------------------------------------
|
---|
390 | //-- Bitmap Info Class
|
---|
391 | //
|
---|
392 |
|
---|
393 | //-- Bitmap flags
|
---|
394 |
|
---|
395 | #define MAP_NOFLAGS ((DWORD)0)
|
---|
396 | #define MAP_READY ((DWORD)(1<<0))
|
---|
397 | #define MAP_HAS_ALPHA ((DWORD)(1<<1))
|
---|
398 | #define MAP_ALPHA_PREMULTIPLIED ((DWORD)(1<<2))
|
---|
399 | #define MAP_PALETTED ((DWORD)(1<<3))
|
---|
400 | #define MAP_FRAME_SYSTEM_LOCKED ((DWORD)(1<<4))
|
---|
401 | #define MAP_DITHERED ((DWORD)(1<<5))
|
---|
402 | #define MAP_FLIPPED ((DWORD)(1<<6)) // Flipped horizontally
|
---|
403 | #define MAP_INVERTED ((DWORD)(1<<7)) // Flipped vertically
|
---|
404 |
|
---|
405 | //#define MAP_CUSTOMSIZE ((DWORD)(1<<8)) // Custom size for input
|
---|
406 | //#define MAP_RESIZE ((DWORD)(1<<9)) // Resize when input
|
---|
407 |
|
---|
408 | #define MAP_VIEW_FILTERED ((DWORD)(1<<31)) // Test stuff
|
---|
409 |
|
---|
410 | #define MAP_ALL_FLAGS 0xFFFFFFFF
|
---|
411 |
|
---|
412 | //-----------------------------------------------------------------------------
|
---|
413 | //-- Messages sent back by various (client) methods
|
---|
414 |
|
---|
415 | //-- Sent by the plug-in to notify host of current progress. The host should
|
---|
416 | // return TRUE if it's ok to continue or FALSE to abort process.
|
---|
417 |
|
---|
418 | #define BMM_PROGRESS WM_USER + 0x120 //-- wParam: Current lParam: Total
|
---|
419 |
|
---|
420 | //-- Sent by the plug-in to check for process interruption. The host should
|
---|
421 | // return FALSE (by setting lParam) if it's ok to continue or TRUE to abort
|
---|
422 | // process.
|
---|
423 |
|
---|
424 | #define BMM_CHECKABORT WM_USER + 0x121 //-- wParam: 0 lParam: *BOOL
|
---|
425 |
|
---|
426 | //-- Sent by the plug-in to display an optional textual message (for progress
|
---|
427 | // report).
|
---|
428 |
|
---|
429 | #define BMM_TEXTMSG WM_USER + 0x122 //-- wParam: 0 lParam: LPCTSTR
|
---|
430 |
|
---|
431 | class BitmapInfo {
|
---|
432 |
|
---|
433 | //-- Image name in case of named images such as files -------
|
---|
434 |
|
---|
435 | TCHAR name[MAX_PATH];
|
---|
436 |
|
---|
437 | //-- Device name gotten from BMM_IOHandler::LongDescription()
|
---|
438 |
|
---|
439 | TCHAR device[MAX_DESCRIPTION];
|
---|
440 |
|
---|
441 | //-- Window Handle to send BMM_UPDATE messages --------------
|
---|
442 |
|
---|
443 | HWND hWnd;
|
---|
444 |
|
---|
445 | //-- Plug-In Parameter Block --------------------------------
|
---|
446 |
|
---|
447 | void *pidata;
|
---|
448 | DWORD pisize;
|
---|
449 |
|
---|
450 | //-- Basic Image Data ---------------------------------------
|
---|
451 | //
|
---|
452 | // When reading an image, or asking for image info, these
|
---|
453 | // fields will tell the user what the image is like.
|
---|
454 | //
|
---|
455 | // When creating an image the user will set these fields to
|
---|
456 | // the desired parameters.
|
---|
457 | //
|
---|
458 |
|
---|
459 | WORD width,height;
|
---|
460 | float aspect,gamma;
|
---|
461 | int fstart,fend;
|
---|
462 | DWORD flags,type;
|
---|
463 |
|
---|
464 | //-- User data (what user wants) ----------------------------
|
---|
465 | //
|
---|
466 | // Custom dimmensions, custom start and end point when
|
---|
467 | // reading sequence of imges, frame to fetch/save, etc.
|
---|
468 | //
|
---|
469 |
|
---|
470 | WORD cwidth,cheight;
|
---|
471 | int custxpos,custypos;
|
---|
472 | int start,end;
|
---|
473 | int step,preset_al;
|
---|
474 | float custgamma;
|
---|
475 |
|
---|
476 | #define BMM_CUSTOM_GAMMA ((DWORD)(1 << 0))
|
---|
477 | #define BMM_CUSTOM_SIZE ((DWORD)(1 << 1))
|
---|
478 | #define BMM_CUSTOM_RESFIT ((DWORD)(1 << 2))
|
---|
479 | #define BMM_CUSTOM_POS ((DWORD)(1 << 3))
|
---|
480 | #define BMM_CUSTOM_FILEGAMMA ((DWORD)(1 << 4))
|
---|
481 |
|
---|
482 | #define BMM_CUSTOM_POSNW 0
|
---|
483 | #define BMM_CUSTOM_POSN 1
|
---|
484 | #define BMM_CUSTOM_POSNE 2
|
---|
485 | #define BMM_CUSTOM_POSW 3
|
---|
486 | #define BMM_CUSTOM_POSCN 4
|
---|
487 | #define BMM_CUSTOM_POSE 5
|
---|
488 | #define BMM_CUSTOM_POSSW 6
|
---|
489 | #define BMM_CUSTOM_POSS 7
|
---|
490 | #define BMM_CUSTOM_POSSE 8
|
---|
491 |
|
---|
492 | DWORD customflags;
|
---|
493 |
|
---|
494 | int fnumber; //-- Defines frame to
|
---|
495 | // read or write.
|
---|
496 |
|
---|
497 | //-- When reading a sequence of frames, loopflag indicates what to
|
---|
498 | // do when reading beyond the end of available frames. It
|
---|
499 | // defaults to BMM_SEQ_WRAP.
|
---|
500 |
|
---|
501 | #define BMM_SEQ_WRAP 0 //-- Wraps around back to start point
|
---|
502 | #define BMM_SEQ_ERROR 1 //-- Generates an error
|
---|
503 | #define BMM_SEQ_HOLD 2 //-- Holds last frame when done
|
---|
504 |
|
---|
505 | WORD loopflag;
|
---|
506 |
|
---|
507 | void doConstruct ( );
|
---|
508 |
|
---|
509 | public:
|
---|
510 |
|
---|
511 | BMMExport BitmapInfo ( );
|
---|
512 | BMMExport BitmapInfo ( TCHAR *n );
|
---|
513 | BMMExport ~BitmapInfo ( );
|
---|
514 |
|
---|
515 | //-- Bitmap Flags
|
---|
516 |
|
---|
517 | BMMExport DWORD Flags ( ) { return (flags); }
|
---|
518 | BMMExport DWORD SetFlags ( DWORD f ) { flags |= f; return (flags); }
|
---|
519 | BMMExport DWORD ResetFlags ( DWORD f ) { flags &= ~f; return (flags); }
|
---|
520 | BMMExport BOOL TestFlags ( DWORD f ) { return (flags & f); }
|
---|
521 |
|
---|
522 | //-- Generic Read
|
---|
523 |
|
---|
524 | BMMExport WORD Width ( ) { return (width); }
|
---|
525 | BMMExport WORD Height ( ) { return (height); }
|
---|
526 | BMMExport float Gamma ( ) { return (gamma); }
|
---|
527 | BMMExport float Aspect ( ) { return (aspect);}
|
---|
528 | BMMExport int Type ( ) { return (type); }
|
---|
529 | BMMExport int FirstFrame ( ) { return (fstart); }
|
---|
530 | BMMExport int LastFrame ( ) { return (fend); }
|
---|
531 | BMMExport int NumberFrames ( ) { return (fend - fstart + 1); }
|
---|
532 | BMMExport int CurrentFrame ( ) { return (fnumber); }
|
---|
533 | BMMExport WORD SequenceOutBound ( ) { return (loopflag); }
|
---|
534 |
|
---|
535 | //-- "Name" returns full path of image file
|
---|
536 |
|
---|
537 | BMMExport const TCHAR *Name ( ) { return (const TCHAR *)name; }
|
---|
538 |
|
---|
539 | //-- "Filename" returns just the name of image file
|
---|
540 |
|
---|
541 | BMMExport const TCHAR *Filename ( );
|
---|
542 |
|
---|
543 | //-- "Device" is the device reponsible for producing this image.
|
---|
544 | // For file types, this is just informative. For non file types
|
---|
545 | // this is the way this image is identified. Therefore, it is
|
---|
546 | // important to save both name and device in order to properly
|
---|
547 | // identify an image.
|
---|
548 |
|
---|
549 | BMMExport const TCHAR *Device ( ) { return (const TCHAR *)device; }
|
---|
550 |
|
---|
551 | //-- Compare Two Bitmaps
|
---|
552 |
|
---|
553 | BMMExport BOOL CompareName ( BitmapInfo *bi );
|
---|
554 |
|
---|
555 | //-- Copy Image info. Only name, device and image characteristics are
|
---|
556 | // copied. User info, such as Custom Width, etc. is not copied.
|
---|
557 |
|
---|
558 | BMMExport void CopyImageInfo ( BitmapInfo *from );
|
---|
559 |
|
---|
560 | //-- Generic Write
|
---|
561 |
|
---|
562 | BMMExport int SetFirstFrame ( int m ) { int o = fstart; fstart = m; return (o);}
|
---|
563 | BMMExport int SetLastFrame ( int s ) { int o = fend; fend = s; return (o);}
|
---|
564 | BMMExport int SetCurrentFrame ( int v ) { int o = fnumber; fnumber = v; return (o);}
|
---|
565 | BMMExport WORD SetSequenceOutBound ( WORD c ) { WORD o = loopflag; loopflag = c; return (o);}
|
---|
566 |
|
---|
567 | BMMExport WORD SetWidth ( WORD s ) { WORD o = width; width = s; return (o);}
|
---|
568 | BMMExport WORD SetHeight ( WORD u ) { WORD o = height; height = u; return (o);}
|
---|
569 | BMMExport float SetGamma ( float c ) { float o = gamma; gamma = c; return (o);}
|
---|
570 | BMMExport float SetAspect ( float k ) { float o = aspect; aspect = k; return (o);}
|
---|
571 | BMMExport int SetType ( int s ) { int o = type; type = s; return (o);}
|
---|
572 |
|
---|
573 | BMMExport const TCHAR *SetName ( const TCHAR *n );
|
---|
574 | BMMExport const TCHAR *SetDevice ( const TCHAR *d );
|
---|
575 |
|
---|
576 | //-- Custom Input Processing
|
---|
577 |
|
---|
578 | BMMExport WORD CustWidth ( ) { return (cwidth); }
|
---|
579 | BMMExport WORD CustHeight ( ) { return (cheight); }
|
---|
580 | BMMExport void SetCustWidth ( WORD w ) { cwidth = w; }
|
---|
581 | BMMExport void SetCustHeight ( WORD h ) { cheight = h; }
|
---|
582 | BMMExport int StartFrame ( ) { return (start); }
|
---|
583 | BMMExport int EndFrame ( ) { return (end); }
|
---|
584 | BMMExport void SetStartFrame ( int s ) { start = s; }
|
---|
585 | BMMExport void SetEndFrame ( int e ) { end = e; }
|
---|
586 | BMMExport void SetCustomX ( int x ) { custxpos = x; }
|
---|
587 | BMMExport void SetCustomY ( int y ) { custypos = y; }
|
---|
588 | BMMExport int GetCustomX ( ) { return custxpos; }
|
---|
589 | BMMExport int GetCustomY ( ) { return custypos; }
|
---|
590 | BMMExport void SetCustomGamma ( float g ) { custgamma = g; }
|
---|
591 | BMMExport float GetCustomGamma ( ) { return custgamma; }
|
---|
592 | BMMExport void SetCustomStep ( int s ) { step = s; }
|
---|
593 | BMMExport int GetCustomStep ( ) { return step; }
|
---|
594 | BMMExport void SetPresetAlignment ( int p ) { preset_al = p; }
|
---|
595 | BMMExport int GetPresetAlignment ( ) { return preset_al; }
|
---|
596 |
|
---|
597 | //-- Custom Input Flags
|
---|
598 |
|
---|
599 | BMMExport DWORD GetCustomFlags ( ) { return (customflags); }
|
---|
600 | BMMExport void SetCustomFlag ( DWORD f ) { customflags |= f; }
|
---|
601 | BMMExport void ResetCustomFlag ( DWORD f ) { customflags &= ~f; }
|
---|
602 | BMMExport BOOL TestCustomFlags ( DWORD f ) { return (customflags & f); }
|
---|
603 |
|
---|
604 | //-- Plug-In Parameter Block
|
---|
605 |
|
---|
606 | BMMExport void *GetPiData ( ) { return pidata; }
|
---|
607 | BMMExport void SetPiData ( void *ptr ) { pidata = ptr; }
|
---|
608 | BMMExport DWORD GetPiDataSize ( ) { return pisize; }
|
---|
609 | BMMExport void SetPiDataSize ( DWORD s ) { pisize = s; }
|
---|
610 | BMMExport void ResetPiData ( );
|
---|
611 | BMMExport BOOL AllocPiData ( DWORD size );
|
---|
612 |
|
---|
613 | BMMExport void Copy ( BitmapInfo *from ); //\\-- OBSOLETE --\\//
|
---|
614 | BMMExport BitmapInfo &operator= ( BitmapInfo &from );
|
---|
615 |
|
---|
616 | //-- Load/Save
|
---|
617 |
|
---|
618 | BMMExport IOResult Save ( ISave *isave );
|
---|
619 | BMMExport IOResult Load ( ILoad *iload );
|
---|
620 | BMMExport void EnumAuxFiles ( NameEnumCallback& nameEnum, DWORD flags);
|
---|
621 |
|
---|
622 | //-- Miscelaneous
|
---|
623 |
|
---|
624 | BMMExport BOOL Validate ( );
|
---|
625 | BMMExport HWND GetUpdateWindow ( ) { return hWnd; }
|
---|
626 | BMMExport void SetUpdateWindow ( HWND hwnd ) { hWnd = hwnd; }
|
---|
627 | BMMExport DWORD GetGChannels ( );
|
---|
628 | BMMExport DWORD GetDeviceFlags ( );
|
---|
629 |
|
---|
630 | };
|
---|
631 |
|
---|
632 | //-----------------------------------------------------------------------------
|
---|
633 | //-- Bitmap I/O Class
|
---|
634 | //
|
---|
635 | // None of these methods are to be used directly. Use the BitmapManager for
|
---|
636 | // any image I/O.
|
---|
637 | //
|
---|
638 |
|
---|
639 |
|
---|
640 | class BitmapIO {
|
---|
641 | private:
|
---|
642 | UWORD* outputGammaTab; // this may be owned by gammaMgr
|
---|
643 | UWORD* privGammaTab; // private gamma table owned by the BitmapIO.
|
---|
644 |
|
---|
645 | protected:
|
---|
646 | float gamma;
|
---|
647 | Bitmap *map; // The bitmap using this OUTPUT handler
|
---|
648 | BitmapStorage *storage; // The storage used by this INPUT handler
|
---|
649 |
|
---|
650 | int openMode; // See above
|
---|
651 |
|
---|
652 | //-- Linked list pointers for multiple output of a single bitmap
|
---|
653 |
|
---|
654 | BitmapIO *prevIO;
|
---|
655 | BitmapIO *nextIO;
|
---|
656 |
|
---|
657 | public:
|
---|
658 |
|
---|
659 | // Used by the subclassed BitmapIO's to get pixels for output with
|
---|
660 | // the appropriate output gamma correction.
|
---|
661 | BMMExport int GetOutputPixels ( int x,int y,int pixels,BMM_Color_64 *ptr);
|
---|
662 |
|
---|
663 | // Used by the subclassed BitmapIO's to get 32 bit pixels for output with
|
---|
664 | // the appropriate output gamma correction and dither.
|
---|
665 | BMMExport int GetDitheredOutputPixels ( int x,int y,int pixels,BMM_Color_32 *ptr);
|
---|
666 |
|
---|
667 | // Used by the subclassed BitmapIO's to get a DIB for output with
|
---|
668 | // the appropriate output gamma correction.
|
---|
669 | BMMExport PBITMAPINFO GetOutputDib ( int depth = 24 );
|
---|
670 |
|
---|
671 | // Used by the subclassed BitmapIO's to get a DIB for output with
|
---|
672 | // the appropriate output gamma correction and dither
|
---|
673 | BMMExport PBITMAPINFO GetDitheredOutputDib ( int depth = 24 );
|
---|
674 |
|
---|
675 | BMMExport float OutputGamma();
|
---|
676 |
|
---|
677 | // If a BitmapIO wants to do its own dithering, it should call
|
---|
678 | // these to find out if dithering is wanted. If it is a 24 bit or
|
---|
679 | // 32 bit format, it would usually just call GetDitheredOutputPixels instead.
|
---|
680 | BMMExport BOOL DitherTrueColor();
|
---|
681 | BMMExport BOOL DitherPaletted();
|
---|
682 |
|
---|
683 | // Calculate a color palette for output color packing: gamma corrects
|
---|
684 | BMMExport int CalcOutputPalette(int palsize, BMM_Color_48 *pal);
|
---|
685 |
|
---|
686 | BMMExport BitmapIO ( );
|
---|
687 | bVirtual ~BitmapIO ( );
|
---|
688 |
|
---|
689 | BitmapInfo bi;
|
---|
690 |
|
---|
691 | inline int OpenMode ( ) { return (openMode); }
|
---|
692 | inline void SetPrev ( BitmapIO *prev) { prevIO = prev; };
|
---|
693 | inline void SetNext ( BitmapIO *next) { nextIO = next; };
|
---|
694 | inline BitmapIO *Prev ( ) { return prevIO; };
|
---|
695 | inline BitmapIO *Next ( ) { return nextIO; };
|
---|
696 |
|
---|
697 | BMMExport BitmapStorage *Storage ( );
|
---|
698 | inline Bitmap *Map ( ) { return map; };
|
---|
699 |
|
---|
700 | bVirtual int ExtCount ( ) = 0; // Number of extemsions supported
|
---|
701 | bVirtual const TCHAR *Ext ( int n ) = 0; // Extension #n (i.e. "3DS")
|
---|
702 | bVirtual const TCHAR *LongDesc ( ) = 0; // Long ASCII description (i.e. "Targa 2.0 Image File")
|
---|
703 | bVirtual const TCHAR *ShortDesc ( ) = 0; // Short ASCII description (i.e. "Targa")
|
---|
704 | bVirtual const TCHAR *AuthorName ( ) = 0; // ASCII Author name
|
---|
705 | bVirtual const TCHAR *CopyrightMessage ( ) = 0; // ASCII Copyright message
|
---|
706 | bVirtual UINT Version ( ) = 0; // Version number * 100 (i.e. v3.01 = 301)
|
---|
707 |
|
---|
708 | bVirtual int Capability ( ) = 0; // Returns IO module ability flags (see above)
|
---|
709 | bVirtual void ShowAbout ( HWND hWnd ) = 0; // Show DLL's "About..." box
|
---|
710 |
|
---|
711 | //-- If the BMMIO_OWN_VIEWER flag is set, this method will be called
|
---|
712 | // whenever the user wants to view an image for this device. This
|
---|
713 | // is for devices which can "play" image sequences such as AVI's, FLIC's, etc.
|
---|
714 | //-- TH 2/26/96 -- Added BOOL return to indicate if view worked. If it didn't,
|
---|
715 | // it returns FALSE and the caller can view by the normal mechanism.
|
---|
716 |
|
---|
717 | bVirtual BOOL ShowImage ( HWND hWnd, BitmapInfo *bi ) { return FALSE; }
|
---|
718 |
|
---|
719 | //-- Show DLL's Control Panel
|
---|
720 | //
|
---|
721 | // If the user exists through an Ok, this function will return TRUE.
|
---|
722 | // If the user cancels out, it will return FALSE. False indicates
|
---|
723 | // nothing has changed so the system won't bother asking the plug-in
|
---|
724 | // if it wants to save data.
|
---|
725 | //
|
---|
726 | // This function is only called if the plug-in has defined it supports
|
---|
727 | // it (through the Capability flag above). The flag will indicate to
|
---|
728 | // the plug-in what operation is this control for (read, write, or
|
---|
729 | // generic).
|
---|
730 | //
|
---|
731 |
|
---|
732 | bVirtual BOOL ShowControl ( HWND hWnd, DWORD flag ) { return FALSE; }
|
---|
733 |
|
---|
734 | //-- Parameter Block Load and Save ------------------------------------
|
---|
735 | //
|
---|
736 | // The host will call EvaluateConfigure() to determine the buffer size
|
---|
737 | // required by the plug-in.
|
---|
738 | //
|
---|
739 | // SaveConfigure() will be called so the plug-in can transfer its
|
---|
740 | // parameter block to the host ( ptr is a pre-allocated buffer).
|
---|
741 | //
|
---|
742 | // LoadConfigure() will be called so the plug-in can load its
|
---|
743 | // parameter block back.
|
---|
744 | //
|
---|
745 | // Memory management is performed by the host using standard
|
---|
746 | // LocalAlloc() and LocalFree().
|
---|
747 | //
|
---|
748 |
|
---|
749 | bVirtual DWORD EvaluateConfigure ( ) = 0;
|
---|
750 | bVirtual BOOL LoadConfigure ( void *ptr ) = 0;
|
---|
751 | bVirtual BOOL SaveConfigure ( void *ptr ) = 0;
|
---|
752 |
|
---|
753 | //-- Used internaly to make sure current block belongs to Plug-In
|
---|
754 |
|
---|
755 | bVirtual BOOL ValidatePiData ( BitmapInfo *bi );
|
---|
756 |
|
---|
757 | //-- System Interface
|
---|
758 |
|
---|
759 | BMMExport BOOL SilentMode ( );
|
---|
760 |
|
---|
761 | //-- Calculate Desired Frame
|
---|
762 | //
|
---|
763 | // This is for multiframe sequences. It processes the desired frame
|
---|
764 | // based on user options. It is used at the Load() function to find
|
---|
765 | // out which frame to load.
|
---|
766 | //
|
---|
767 | // "fbi" is the one passed to Load()
|
---|
768 | // "frame" is a pointer to an integer to receive the frame number
|
---|
769 |
|
---|
770 | BMMExport BMMRES GetFrame ( BitmapInfo *fbi, int *frame);
|
---|
771 |
|
---|
772 | //-- Critical Error Handling
|
---|
773 |
|
---|
774 | BMMExport BMMRES ProcessImageIOError ( BitmapInfo *bi, TCHAR *string = NULL);
|
---|
775 | BMMExport BMMRES ProcessImageIOError ( BitmapInfo *bi, int errorcode);
|
---|
776 |
|
---|
777 | //---------------------------------------------------------------------
|
---|
778 | //-- Channels Required (for Output)
|
---|
779 | //
|
---|
780 | // By setting this flag, the plug-in can request the host to generate
|
---|
781 | // the given channels. Prior to Rendering, the host will scan the
|
---|
782 | // plug-ins in the chain of events and list all types of channels
|
---|
783 | // being requested. The plug-in, at the time of the Write() call, will
|
---|
784 | // have access to these channels through the channel interface
|
---|
785 | // described below in BitmapStorage().
|
---|
786 | //
|
---|
787 | // The generation of these channels should not, normally, be a
|
---|
788 | // default setting for a plug-in. These channels are memory hungry and
|
---|
789 | // if the plug-in won't use it, it should not ask for it. Normally
|
---|
790 | // the plug-in would ask the user which channels to save and set only
|
---|
791 | // the proper flags.
|
---|
792 | //
|
---|
793 |
|
---|
794 | bVirtual DWORD ChannelsRequired ( ) { return BMM_CHAN_NONE; }
|
---|
795 |
|
---|
796 | //-- Image Info
|
---|
797 |
|
---|
798 | bVirtual BMMRES GetImageInfoDlg ( HWND hWnd, BitmapInfo *bi, const TCHAR *filename = NULL ) {return BMMRES_NODRIVER;}
|
---|
799 | bVirtual BMMRES GetImageInfo ( BitmapInfo *bi ) = 0;
|
---|
800 |
|
---|
801 | //-- Image File Loaders (IFL handlers)
|
---|
802 |
|
---|
803 | bVirtual BMMRES GetImageName ( BitmapInfo *bi, TCHAR *filename) {filename[0]=0; return (BMMRES_SUCCESS);}
|
---|
804 |
|
---|
805 | //-- Image I/O (Not to use directly)
|
---|
806 |
|
---|
807 | bVirtual BitmapStorage *Load ( BitmapInfo *bi, Bitmap *map, BMMRES *status ) = 0;
|
---|
808 |
|
---|
809 | bVirtual BMMRES OpenOutput ( BitmapInfo *bi, Bitmap *map );
|
---|
810 | bVirtual BMMRES Write ( int frame );
|
---|
811 | bVirtual int Close ( int flag );
|
---|
812 | bVirtual PAVIFILE GetPaviFile ( ) { return NULL; }
|
---|
813 |
|
---|
814 | // used internally to build output gamma table
|
---|
815 | BMMExport void InitOutputGammaTable(BitmapInfo*bi);
|
---|
816 | };
|
---|
817 |
|
---|
818 | //-----------------------------------------------------------------------------
|
---|
819 | //-- Bitmap Storage Class
|
---|
820 | //
|
---|
821 | // None of these methods are to be used directly. Use the Bitmap class for
|
---|
822 | // any image read/write.
|
---|
823 | //
|
---|
824 |
|
---|
825 | //-- Channel Operations (for Get/Put16Channel)
|
---|
826 |
|
---|
827 | #define BMM_CHANNEL_RED 0 //-- Get/Put only Red
|
---|
828 | #define BMM_CHANNEL_GREEN 1 //-- Get/Put only Green
|
---|
829 | #define BMM_CHANNEL_BLUE 3 //-- Get/Put only Blue
|
---|
830 | #define BMM_CHANNEL_ALPHA 4 //-- Get/Put only Alpha
|
---|
831 | #define BMM_CHANNEL_Z 5 //-- Get/Put only Z
|
---|
832 | #define BMM_CHANNEL_LUMINANCE 6 //-- Get (R+G+B)/3
|
---|
833 |
|
---|
834 | class BitmapStorage {
|
---|
835 |
|
---|
836 | protected:
|
---|
837 |
|
---|
838 | int openMode; // See above
|
---|
839 | UINT usageCount; // Number of Bitmaps using this storage
|
---|
840 | BitmapManager *manager;
|
---|
841 |
|
---|
842 | int flags;
|
---|
843 | int type; // See "Basic bitmap types", below
|
---|
844 |
|
---|
845 | BMM_Color_48 palette[256]; // 256 palette entries max
|
---|
846 | int paletteSlots;
|
---|
847 | UWORD *gammaTable; // Gamma correction table
|
---|
848 |
|
---|
849 | RenderInfo *rendInfo;
|
---|
850 | public:
|
---|
851 |
|
---|
852 | BMMExport BitmapStorage ( );
|
---|
853 | bVirtual ~BitmapStorage ( );
|
---|
854 |
|
---|
855 | BitmapInfo bi;
|
---|
856 |
|
---|
857 | // gamma
|
---|
858 | BMMExport float SetGamma(float gam);
|
---|
859 | inline int HasGamma ( ) { return (gammaTable!=NULL) ? 1:0; };
|
---|
860 | BMMExport void SetHasGamma(BOOL onOff);
|
---|
861 | void UpdateGammaTable();
|
---|
862 | BMMExport UWORD *GetInputGammaTable();
|
---|
863 |
|
---|
864 | inline BitmapManager *Manager ( ) { return manager; }
|
---|
865 | inline int OpenMode ( ) { return openMode; }
|
---|
866 | inline int Width ( ) { return bi.Width(); }
|
---|
867 | inline int Height ( ) { return bi.Height(); }
|
---|
868 | inline float Aspect ( ) { return bi.Aspect(); }
|
---|
869 | inline float Gamma ( ) { return bi.Gamma(); }
|
---|
870 |
|
---|
871 | inline int Paletted ( ) { return (flags & MAP_PALETTED) ? paletteSlots:0; }
|
---|
872 | inline int IsDithered ( ) { return (flags & MAP_DITHERED) ? 1:0; };
|
---|
873 | inline int PreMultipliedAlpha ( ) { return (flags & MAP_ALPHA_PREMULTIPLIED) ? 1:0; };
|
---|
874 | inline int HasAlpha ( ) { return (flags & MAP_HAS_ALPHA) ? 1:0; };
|
---|
875 |
|
---|
876 | inline int UsageCount ( ) { return usageCount; };
|
---|
877 | inline int Type ( ) { return type; };
|
---|
878 | inline int Flags ( ) { return flags; };
|
---|
879 | inline void SetFlags ( DWORD f ) { flags |= f; }
|
---|
880 |
|
---|
881 | bVirtual int MaxRGBLevel ( ) = 0;
|
---|
882 | bVirtual int MaxAlphaLevel ( ) = 0;
|
---|
883 |
|
---|
884 | //-- Scaling Tools
|
---|
885 |
|
---|
886 | bVirtual void Scale ( WORD *, int, WORD *, int );
|
---|
887 | bVirtual BOOL GetSRow ( WORD *, int, WORD *, int );
|
---|
888 | bVirtual BOOL PutSRow ( WORD *, int, WORD *, int );
|
---|
889 | bVirtual BOOL GetSCol ( WORD *, WORD *, int, int );
|
---|
890 | bVirtual BOOL PutSCol ( WORD *, WORD *, int, int );
|
---|
891 | bVirtual BOOL ScaleY ( Bitmap *, BMM_Color_64 *, WORD *, WORD *, HWND, int cw = 0, int ch = 0 );
|
---|
892 | bVirtual BOOL ScaleX ( Bitmap *, BMM_Color_64 *, WORD *, WORD *, HWND, int cw = 0, int ch = 0 );
|
---|
893 |
|
---|
894 | //-- This method will try to get a pointer to the begining of the image
|
---|
895 | // storage. Not all storage types can return a valid pointer. In those
|
---|
896 | // cases, this call will fail and the user should use some other method
|
---|
897 | // described below (GG);
|
---|
898 | //
|
---|
899 |
|
---|
900 | bVirtual void *GetStoragePtr ( int *type ) { *type = BMM_NO_TYPE; return (NULL); }
|
---|
901 |
|
---|
902 | //-- These methods will handle a single, 16 bit channel. See BMM_CHANNEL above
|
---|
903 | // for the different options (GG)
|
---|
904 |
|
---|
905 | // bVirtual int Get16Channel ( int x,int y,int pixels,unsigned short *ptr, int channel) = 0;
|
---|
906 | // bVirtual int Put16Channel ( int x,int y,int pixels,unsigned short *ptr, int channel) = 0;
|
---|
907 |
|
---|
908 | //-- These are the standard methods for accessing image pixels
|
---|
909 |
|
---|
910 | bVirtual int Get16Gray ( int x,int y,int pixels,WORD *ptr) = 0;
|
---|
911 | bVirtual int Put16Gray ( int x,int y,int pixels,WORD *ptr) = 0;
|
---|
912 | bVirtual int GetLinearPixels ( int x,int y,int pixels,BMM_Color_64 *ptr) = 0;
|
---|
913 | bVirtual int GetPixels ( int x,int y,int pixels,BMM_Color_64 *ptr) = 0;
|
---|
914 | bVirtual int PutPixels ( int x,int y,int pixels,BMM_Color_64 *ptr) = 0;
|
---|
915 | bVirtual int GetIndexPixels ( int x,int y,int pixels,unsigned char *ptr) = 0;
|
---|
916 | bVirtual int PutIndexPixels ( int x,int y,int pixels,unsigned char *ptr) = 0;
|
---|
917 |
|
---|
918 | bVirtual int CropImage ( int width,int height,BMM_Color_64 fillcolor) = 0;
|
---|
919 | bVirtual int CropImage ( int width,int height,int fillindex) = 0;
|
---|
920 | bVirtual int ResizeImage ( int width,int height,int newpalette) = 0;
|
---|
921 |
|
---|
922 | bVirtual int CopyCrop ( Bitmap *from, BMM_Color_64 fillcolor );
|
---|
923 | bVirtual int CopyScaleLow ( Bitmap *from );
|
---|
924 | bVirtual int CopyScaleHigh ( Bitmap *from, HWND hWnd, BMM_Color_64 **buf = NULL, int w=0, int h=0 );
|
---|
925 |
|
---|
926 | bVirtual int CopyImage ( Bitmap *from,int operation,BMM_Color_64 fillcolor, BitmapInfo *bi = NULL);
|
---|
927 | bVirtual int CopyImage ( Bitmap *from,int operation,int fillindex);
|
---|
928 | bVirtual int GetPalette ( int start,int count,BMM_Color_48 *ptr) = 0;
|
---|
929 | bVirtual int SetPalette ( int start,int count,BMM_Color_48 *ptr) = 0;
|
---|
930 | bVirtual int GetFiltered ( float u,float v,float du,float dv,BMM_Color_64 *ptr) = 0;
|
---|
931 |
|
---|
932 | //-- User Interface
|
---|
933 |
|
---|
934 | bVirtual int Allocate ( BitmapInfo *bi,BitmapManager *manager,int openMode) = 0;
|
---|
935 | bVirtual int Connect ( ) = 0;
|
---|
936 | bVirtual int Disconnect ( ) = 0;
|
---|
937 | bVirtual int MapReady ( ) = 0;
|
---|
938 | bVirtual int ClosestColor ( BMM_Color_48 color);
|
---|
939 | bVirtual int ClosestColor ( int r,int g,int b);
|
---|
940 |
|
---|
941 | // GBuffer methods ----------------------
|
---|
942 | // get a pointer to specified channel: also determine its type for check
|
---|
943 | bVirtual void* GetChannel(ULONG channelID, ULONG& chanType) { return NULL;}
|
---|
944 |
|
---|
945 | // create the specified channels -- return channels present:
|
---|
946 | bVirtual ULONG CreateChannels(ULONG channelIDs) { return 0;}
|
---|
947 |
|
---|
948 | // delete all the channels in channelIDs
|
---|
949 | bVirtual void DeleteChannels(ULONG channelIDs) {}
|
---|
950 |
|
---|
951 | // query which channels are present
|
---|
952 | bVirtual ULONG ChannelsPresent() { return 0; }
|
---|
953 |
|
---|
954 | // For output bitmaps, can get RenderInfo, which is written by the
|
---|
955 | // renderer
|
---|
956 | // AllocRenderInfo will alloc only if RenderInfo doesn't yet exist.
|
---|
957 | BMMExport RenderInfo* AllocRenderInfo();
|
---|
958 | // GetRenderInfo just hands back RenderInfo pointer
|
---|
959 | BMMExport RenderInfo* GetRenderInfo();
|
---|
960 |
|
---|
961 | };
|
---|
962 |
|
---|
963 | //-----------------------------------------------------------------------------
|
---|
964 | //-- Bitmap Filter Class
|
---|
965 | //
|
---|
966 | // Private class not to be documented
|
---|
967 | //
|
---|
968 |
|
---|
969 | class BitmapFilter {
|
---|
970 |
|
---|
971 | protected:
|
---|
972 |
|
---|
973 | UINT usageCount; // Number of Bitmaps using this storage
|
---|
974 | BitmapManager *manager; // Pointer to bitmap manager
|
---|
975 | BitmapStorage *storage; // Pointer to storage itself
|
---|
976 | DWORD flags; // Filter flags
|
---|
977 | int dirty; // Needs updating flag
|
---|
978 | UINT type; // Type index of filter
|
---|
979 |
|
---|
980 | public:
|
---|
981 |
|
---|
982 | BMMExport BitmapFilter();
|
---|
983 | bVirtual ~BitmapFilter();
|
---|
984 |
|
---|
985 | inline DWORD Flags ( ) { return flags; };
|
---|
986 | inline void SetFlag ( DWORD flag) { flags |= flag; dirty = 1; };
|
---|
987 | inline void ToggleFlag ( DWORD flag) { flags ^= flag; dirty = 1; };
|
---|
988 | inline void ClearFlag ( DWORD flag) { flags &= (~flag); dirty = 1; };
|
---|
989 | inline UINT Type ( ) { return type; };
|
---|
990 | inline void SetType ( UINT t) { type = t; };
|
---|
991 | BMMExport int Initialize ( BitmapManager *m,BitmapStorage *s);
|
---|
992 |
|
---|
993 | virtual int GetFiltered ( float u,float v,float du,float dv,BMM_Color_64 *ptr) = 0;
|
---|
994 | virtual void Free ( ) {};
|
---|
995 |
|
---|
996 | BMMExport int Connect ( );
|
---|
997 | BMMExport int Disconnect ( );
|
---|
998 | BMMExport int SetStorage ( BitmapStorage *storage);
|
---|
999 | inline BitmapStorage *GetStorage ( ) { return storage; };
|
---|
1000 | inline void MakeDirty ( ) { dirty = 1; };
|
---|
1001 |
|
---|
1002 | };
|
---|
1003 |
|
---|
1004 | //-----------------------------------------------------------------------------
|
---|
1005 | //-- Bitmap Dither Class
|
---|
1006 | //
|
---|
1007 | // Private class not to be documented
|
---|
1008 |
|
---|
1009 | class BitmapDither {
|
---|
1010 |
|
---|
1011 | protected:
|
---|
1012 |
|
---|
1013 | BitmapStorage *storage; // Pointer to storage itself
|
---|
1014 | int type; // Type index of filter
|
---|
1015 |
|
---|
1016 | public:
|
---|
1017 |
|
---|
1018 | BMMExport BitmapDither ( );
|
---|
1019 | bVirtual ~BitmapDither ( );
|
---|
1020 | inline UINT Type ( ) { return type; };
|
---|
1021 | inline void SetType ( UINT t) { type = t; };
|
---|
1022 | BMMExport int Initialize ( BitmapStorage *s);
|
---|
1023 | virtual int PutPixels ( int x,int y,int pixels,BMM_Color_64 *ptr) = 0;
|
---|
1024 | virtual void Free ( ) {};
|
---|
1025 | BMMExport int SetStorage ( BitmapStorage *storage);
|
---|
1026 |
|
---|
1027 | };
|
---|
1028 |
|
---|
1029 | //-----------------------------------------------------------------------------
|
---|
1030 | //-- Bitmap Picker Class
|
---|
1031 | //
|
---|
1032 |
|
---|
1033 | /*
|
---|
1034 | class BitmapPicker {
|
---|
1035 |
|
---|
1036 | protected:
|
---|
1037 |
|
---|
1038 | BitmapManager *manager;
|
---|
1039 |
|
---|
1040 | public:
|
---|
1041 |
|
---|
1042 | bVirtual BitmapPicker ( ) {};
|
---|
1043 | bVirtual ~BitmapPicker ( ) {};
|
---|
1044 |
|
---|
1045 | bVirtual SetManager ( BitmapManager *m ) { manager = m; }
|
---|
1046 | bVirtual BitmapManager *GetManager ( ) { return (manager); }
|
---|
1047 |
|
---|
1048 | bVirtual BOOL ImageInputOptions ( BitmapInfo *bi, HWND hWnd )=0;
|
---|
1049 | bVirtual BOOL SelectDeviceInput ( BitmapInfo *bi, HWND hWnd )=0;
|
---|
1050 | bVirtual BOOL SelectDeviceOutput ( BitmapInfo *bi, HWND hWnd )=0;
|
---|
1051 |
|
---|
1052 | bVirtual BOOL SelectFileOutput ( BitmapInfo *bi,
|
---|
1053 | HWND hWnd,
|
---|
1054 | TCHAR *title = NULL)=0;
|
---|
1055 |
|
---|
1056 | bVirtual BOOL SelectFileInput ( BitmapInfo *bi,
|
---|
1057 | HWND hWnd,
|
---|
1058 | TCHAR *title = NULL)=0;
|
---|
1059 |
|
---|
1060 | bVirtual BOOL SelectFileInputEx ( BitmapInfo *bi,
|
---|
1061 | HWND hWnd,
|
---|
1062 | TCHAR *title = NULL)=0;
|
---|
1063 |
|
---|
1064 | };
|
---|
1065 | */
|
---|
1066 |
|
---|
1067 | //-----------------------------------------------------------------------------
|
---|
1068 | //-- Basic Bitmap Class
|
---|
1069 | //
|
---|
1070 | //
|
---|
1071 |
|
---|
1072 | #define BMM_SINGLEFRAME -2000000L
|
---|
1073 |
|
---|
1074 | class Bitmap {
|
---|
1075 |
|
---|
1076 | private:
|
---|
1077 |
|
---|
1078 | DWORD flags; // See above
|
---|
1079 |
|
---|
1080 | BitmapManager *manager; // Manager of this bitmap
|
---|
1081 | BitmapIO *output; // Head of output handler list
|
---|
1082 | BitmapFilter *filter; // Filtered access methods
|
---|
1083 | BitmapDither *dither; // Dither methods
|
---|
1084 | BitmapStorage *storage; // Actual storage
|
---|
1085 |
|
---|
1086 | ICustToolbar *iTool; // Display Window Toolbar
|
---|
1087 | HWND hWnd,hTool; // Window handle (Display and Toolbar)
|
---|
1088 | UINT filterType; // Filtered access type
|
---|
1089 | UINT ditherType; // Dither type
|
---|
1090 | int currentBits; // Device Context NUMBITS (Display())
|
---|
1091 |
|
---|
1092 | int Free();
|
---|
1093 |
|
---|
1094 | HWND hList;
|
---|
1095 | ICustButton *iR,*iG,*iB,*iA;
|
---|
1096 | ICustStatus *iText;
|
---|
1097 | ICustButton *iClear,*iSave;
|
---|
1098 | TCHAR curTitle[128];
|
---|
1099 | int curPosition;
|
---|
1100 | int bitx,bity;
|
---|
1101 | BOOL autonomous;
|
---|
1102 |
|
---|
1103 | //-- Channel Display in VFB
|
---|
1104 |
|
---|
1105 | #define BMM_MASK_R 0x1
|
---|
1106 | #define BMM_MASK_G 0x2
|
---|
1107 | #define BMM_MASK_B 0x4
|
---|
1108 | #define BMM_MASK_A 0x8
|
---|
1109 |
|
---|
1110 | #define BMM_MODE_RGBA 0
|
---|
1111 | #define BMM_MODE_Z 1
|
---|
1112 | #define BMM_MODE_MTL 2
|
---|
1113 | #define BMM_MODE_NODE 3
|
---|
1114 | #define BMM_MODE_UV 4
|
---|
1115 | #define BMM_MODE_NORMAL 5
|
---|
1116 | #define BMM_MODE_NONCLAMP 6
|
---|
1117 |
|
---|
1118 | WORD channelMode;
|
---|
1119 | WORD channelMask;
|
---|
1120 |
|
---|
1121 | friend LRESULT CALLBACK InputWndProc ( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
|
---|
1122 |
|
---|
1123 | public:
|
---|
1124 |
|
---|
1125 | BMMExport Bitmap ( BitmapManager *manager = TheManager );
|
---|
1126 | BMMExport ~Bitmap ( );
|
---|
1127 |
|
---|
1128 | inline BitmapManager *Manager ( ) { return manager; };
|
---|
1129 |
|
---|
1130 | //-- Don't use these unless you know what you're doing ----------------
|
---|
1131 |
|
---|
1132 | BMMExport int Create ( BitmapInfo *bi );
|
---|
1133 | BMMExport BOOL FixDeviceName ( BitmapInfo *bi );
|
---|
1134 | inline int MapReady ( ) { if (storage) return storage->MapReady(); return 0; };
|
---|
1135 | BMMExport void AddOutput ( BitmapIO *out );
|
---|
1136 | BMMExport void RemoveOutput ( BitmapIO *out );
|
---|
1137 | BMMExport BitmapIO * FindOutput ( BitmapInfo *bi );
|
---|
1138 | BMMExport PAVIFILE GetPaviFile ( BitmapInfo *bi );
|
---|
1139 |
|
---|
1140 | //-- Display Bitmap (Data and Methods) - Internal Use Only ------------
|
---|
1141 |
|
---|
1142 | HDRAWDIB dispHDR;
|
---|
1143 | HANDLE dispDIB;
|
---|
1144 | LRESULT Command ( WORD notify, WORD id, HWND hCtrl );
|
---|
1145 | LRESULT WMNotify ( LPNMHDR hdr );
|
---|
1146 | LRESULT BimpWndProc ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
---|
1147 | void UpdateToolBar ( );
|
---|
1148 | BOOL InitBuffer ( );
|
---|
1149 | BOOL VfbFit ( int *w, int *h );
|
---|
1150 |
|
---|
1151 | //-- Public Interface -------------------------------------------------
|
---|
1152 |
|
---|
1153 | inline DWORD Flags ( ) { return flags; };
|
---|
1154 | inline void SetFlag ( DWORD flag ) { flags |= flag; };
|
---|
1155 | inline void ToggleFlag ( DWORD flag ) { flags ^= flag; };
|
---|
1156 | inline void ClearFlag ( DWORD flag ) { flags &= (~flag); };
|
---|
1157 |
|
---|
1158 | inline int Width ( ) { if (storage) return storage->Width(); return 0; };
|
---|
1159 | inline int Height ( ) { if (storage) return storage->Height(); return 0; };
|
---|
1160 | inline float Aspect ( ) { if (storage) return storage->Aspect(); return (float)0.0; };
|
---|
1161 | inline float Gamma ( ) { if (storage) return storage->Gamma(); return (float)0.0; };
|
---|
1162 | inline int Paletted ( ) { if (storage) return storage->Paletted(); return 0; };
|
---|
1163 | inline int IsDithered ( ) { if (storage) return storage->IsDithered(); return 0; };
|
---|
1164 | inline int PreMultipliedAlpha ( ) { if (storage) return storage->PreMultipliedAlpha(); return 0; };
|
---|
1165 | inline int HasAlpha ( ) { if (storage) return storage->HasAlpha(); return 0; };
|
---|
1166 | inline int MaxRGBLevel ( ) { if (storage) return storage->MaxRGBLevel(); return 0; };
|
---|
1167 | inline int MaxAlphaLevel ( ) { if (storage) return storage->MaxAlphaLevel(); return 0; };
|
---|
1168 |
|
---|
1169 | int Put16Gray ( int x,int y,int pixels,WORD *ptr )
|
---|
1170 | { if (storage) return storage->Put16Gray(x,y,pixels,ptr); return 0; };
|
---|
1171 | inline void *GetStoragePtr ( int *type )
|
---|
1172 | { if (storage) return storage->GetStoragePtr(type); return NULL; };
|
---|
1173 | inline int Get16Gray ( int x,int y,int pixels,WORD *ptr )
|
---|
1174 | { if (storage) return storage->Get16Gray(x,y,pixels,ptr); return 0; };
|
---|
1175 | inline int GetPixels ( int x,int y,int pixels,BMM_Color_64 *ptr )
|
---|
1176 | { if (storage) return storage->GetPixels(x,y,pixels,ptr); return 0; };
|
---|
1177 | BMMExport int PutPixels ( int x,int y,int pixels,BMM_Color_64 *ptr );
|
---|
1178 | inline int GetLinearPixels ( int x,int y,int pixels,BMM_Color_64 *ptr )
|
---|
1179 | { if (storage) return storage->GetLinearPixels(x,y,pixels,ptr); return 0; };
|
---|
1180 | inline int GetIndexPixels ( int x,int y,int pixels,BYTE *ptr )
|
---|
1181 | { if (storage) return storage->GetIndexPixels(x,y,pixels,ptr); return 0; };
|
---|
1182 | inline int PutIndexPixels ( int x,int y,int pixels,BYTE *ptr )
|
---|
1183 | { if (storage) return storage->PutIndexPixels(x,y,pixels,ptr); return 0; };
|
---|
1184 | inline int CropImage ( int width,int height,BMM_Color_64 fillcolor)
|
---|
1185 | { if (storage) return storage->CropImage(width,height,fillcolor); return 0; };
|
---|
1186 | inline int CropImage ( int width,int height,int fillindex)
|
---|
1187 | { if (storage) return storage->CropImage(width,height,fillindex); return 0; };
|
---|
1188 | inline int ResizeImage ( int width,int height,int newpalette)
|
---|
1189 | { if (storage) return storage->ResizeImage(width,height,newpalette);return 0; };
|
---|
1190 | inline int CopyImage ( Bitmap *from,int operation,BMM_Color_64 fillcolor, BitmapInfo *bi = NULL)
|
---|
1191 | { if (storage) return storage->CopyImage(from,operation,fillcolor,bi); return 0; };
|
---|
1192 | inline int CopyImage ( Bitmap *from,int operation,int fillindex)
|
---|
1193 | { if (storage) return storage->CopyImage(from,operation,fillindex); return 0; };
|
---|
1194 | inline int GetPalette ( int start,int count,BMM_Color_48 *ptr)
|
---|
1195 | { if (storage) return storage->GetPalette(start,count,ptr); return 0; };
|
---|
1196 | inline int SetPalette ( int start,int count,BMM_Color_48 *ptr)
|
---|
1197 | { if (storage) return storage->SetPalette(start,count,ptr); return 0; };
|
---|
1198 |
|
---|
1199 | // GBuffer methods ---------------------
|
---|
1200 |
|
---|
1201 | inline void *GetChannel ( ULONG channelID, ULONG& chanType )
|
---|
1202 | { if (storage) return storage->GetChannel(channelID, chanType); return NULL; }
|
---|
1203 | inline ULONG CreateChannels ( ULONG channelIDs )
|
---|
1204 | { if (storage) return storage->CreateChannels(channelIDs); return 0; }
|
---|
1205 | inline void DeleteChannels ( ULONG channelIDs )
|
---|
1206 | { if (storage) storage->DeleteChannels(channelIDs); }
|
---|
1207 | inline ULONG ChannelsPresent ( )
|
---|
1208 | { if (storage) return storage->ChannelsPresent(); return 0; }
|
---|
1209 | inline RenderInfo* GetRenderInfo() { if (storage) return storage->GetRenderInfo(); return NULL; }
|
---|
1210 |
|
---|
1211 | inline RenderInfo* AllocRenderInfo() { if (storage) return storage->AllocRenderInfo(); return NULL; }
|
---|
1212 |
|
---|
1213 | //---------------------------------------------------------------------
|
---|
1214 | //
|
---|
1215 | // This call will check with the plug-in (file or device) defined in
|
---|
1216 | // the given BitmapInfo and prepare (create) the proper channels. If
|
---|
1217 | // a given channel already exists, no new channel will be created.
|
---|
1218 | //
|
---|
1219 | // After creating a bitmap, use this function to define the optional
|
---|
1220 | // channels that may be required by the given handler.
|
---|
1221 | //
|
---|
1222 |
|
---|
1223 | BMMExport BOOL PrepareGChannels ( BitmapInfo *bi );
|
---|
1224 | BMMExport BOOL PrepareGChannels ( DWORD channels );
|
---|
1225 |
|
---|
1226 |
|
---|
1227 | BMMExport int GetFiltered ( float u,float v,float du,float dv,BMM_Color_64 *ptr );
|
---|
1228 | BMMExport int SetDither ( UINT ditherType );
|
---|
1229 | BMMExport int SetFilter ( UINT filterType );
|
---|
1230 | inline int HasFilter ( ) { return (filter) ? 1:0; };
|
---|
1231 | inline BitmapFilter *Filter ( ) { return filter; };
|
---|
1232 | BMMExport int SetStorage ( BitmapStorage *storage);
|
---|
1233 | inline BitmapStorage *Storage ( ) { return storage; };
|
---|
1234 | inline void NullStorage ( ) { storage = NULL; };
|
---|
1235 |
|
---|
1236 | //-- Windows DIB Conversion -------------------------------------------
|
---|
1237 | //
|
---|
1238 | // Where depth is either 24 (BGR) or 32 (BGR0)
|
---|
1239 | //
|
---|
1240 |
|
---|
1241 | BMMExport PBITMAPINFO ToDib ( int depth = 24, UWORD *gam=NULL, BOOL dither=FALSE);
|
---|
1242 |
|
---|
1243 | //-- Do not use this directly. Instead, use BitmapManager::Create(PBITMAPINFO)
|
---|
1244 |
|
---|
1245 | BMMExport BOOL FromDib ( PBITMAPINFO pbmi );
|
---|
1246 |
|
---|
1247 | //-- Image output operations ------------------------------------------
|
---|
1248 | //
|
---|
1249 | // To write a single image to a file/device:
|
---|
1250 | //
|
---|
1251 | // *> Create BitmapInfo class: BitmapInfo bi;
|
---|
1252 | //
|
---|
1253 | // *> Define output file/device:
|
---|
1254 | //
|
---|
1255 | // Directly: bi.SetName("file.tga");
|
---|
1256 | // or
|
---|
1257 | // User Interface: BitmapManager::SelectFileOutput( ... &bi ...)
|
---|
1258 | //
|
---|
1259 | // *> Define bitmap:
|
---|
1260 | //
|
---|
1261 | // bi.SetWidth(x)
|
---|
1262 | // bi.SetHeight(y)
|
---|
1263 | // etc...
|
---|
1264 | //
|
---|
1265 | // *> Create bitmap: Bitmap *map = BitmapManager::Create(&bi);
|
---|
1266 | //
|
---|
1267 | //
|
---|
1268 | // *> Do something: map->Fill({0,0,0});
|
---|
1269 | //
|
---|
1270 | // *> OpenOutput: map->OpenOutput(&bi);
|
---|
1271 | //
|
---|
1272 | // *> Write: map->Write(&bi)
|
---|
1273 | //
|
---|
1274 | // *> Close: map->Close(&bi)
|
---|
1275 | //
|
---|
1276 | // To write a multiframe file, just keep doing something different to
|
---|
1277 | // the bimap and keep writting.
|
---|
1278 | //
|
---|
1279 | // To write a sequence of images to a file/device:
|
---|
1280 | //
|
---|
1281 | // *> Create BitmapInfo class: BitmapInfo bi;
|
---|
1282 | //
|
---|
1283 | // *> Define output file/device:
|
---|
1284 | //
|
---|
1285 | // Directly: bi.SetName("file.tga");
|
---|
1286 | // or
|
---|
1287 | // User Interface: BitmapManager::SelectFileOutput( ... &bi ...)
|
---|
1288 | //
|
---|
1289 | // *> Define bitmap:
|
---|
1290 | //
|
---|
1291 | // bi.SetWidth(x)
|
---|
1292 | // bi.SetHeight(y)
|
---|
1293 | //
|
---|
1294 | // bi.SetFirstFrame(0)
|
---|
1295 | // bi.SetLastFrame(29)
|
---|
1296 | //
|
---|
1297 | // etc...
|
---|
1298 | //
|
---|
1299 | // *> Create bitmap: Bitmap *map = BitmapManager::Create(&bi);
|
---|
1300 | //
|
---|
1301 | //
|
---|
1302 | // *> OpenOutput: map->OpenOutput(&bi);
|
---|
1303 | //
|
---|
1304 | // for (x = 0 to 29) {
|
---|
1305 | // *> Do something to image...
|
---|
1306 | // *> Write: map->Write(&bi,x);
|
---|
1307 | // }
|
---|
1308 | //
|
---|
1309 | // *> Close: map->Close(&bi)
|
---|
1310 | //
|
---|
1311 | //
|
---|
1312 | // Note: You can add any number of outputs to a bitmap. Just keep
|
---|
1313 | // calling map->OpenInput() with different outputs (Targa file AND
|
---|
1314 | // Frame Buffer for instance). To write or close a specific output,
|
---|
1315 | // use Write() and Close(). To write and close them all at once,
|
---|
1316 | // use WriteAll() and CloseAll().
|
---|
1317 | //
|
---|
1318 | // It is ok to use WriteAll() and CloseAll() if you have just one
|
---|
1319 | // output defined.
|
---|
1320 | //
|
---|
1321 |
|
---|
1322 | BMMExport BMMRES OpenOutput ( BitmapInfo *bi ); // Open output
|
---|
1323 | BMMExport BMMRES Write ( BitmapInfo *bi, int frame = BMM_SINGLEFRAME ); // Write frame to file
|
---|
1324 | BMMExport BMMRES WriteAll ( int frame = BMM_SINGLEFRAME ); // Write all open outputs
|
---|
1325 | BMMExport int Close ( BitmapInfo *bi, int flag = BMM_CLOSE_COMPLETE ); // Close an open output
|
---|
1326 | BMMExport int CloseAll ( int flag = BMM_CLOSE_COMPLETE); // Close all open outputs
|
---|
1327 |
|
---|
1328 | //-- Window gravity
|
---|
1329 |
|
---|
1330 | #define BMM_UL 1 //-- Upper Left
|
---|
1331 | #define BMM_LL 2 //-- Lower Left
|
---|
1332 | #define BMM_UR 3 //-- Upper Right
|
---|
1333 | #define BMM_LR 4 //-- Upper Left
|
---|
1334 | #define BMM_CN 5 //-- Center
|
---|
1335 |
|
---|
1336 | #define BMM_RND 10 //-- Renderer (Save/Restore)
|
---|
1337 | #define BMM_VPP 11 //-- Video Post Primary (Save/Restore)
|
---|
1338 | #define BMM_VPS 12 //-- Video Post Secondary (Save/Restore)
|
---|
1339 |
|
---|
1340 | BMMExport int Display ( TCHAR *title = NULL, int position = BMM_CN, BOOL autonomous = FALSE );
|
---|
1341 | BMMExport int UnDisplay ( );
|
---|
1342 | BMMExport HWND GetWindow ( );
|
---|
1343 | BMMExport void RefreshWindow ( RECT *rect = NULL );
|
---|
1344 | BMMExport void SetWindowTitle ( TCHAR *title );
|
---|
1345 |
|
---|
1346 | //-- Get a Different Frame -------------------------------------------
|
---|
1347 | //
|
---|
1348 | // For multifrane bitmaps (FLI's, AVI's, DDR devices, etc.), if you
|
---|
1349 | // simply want to load another frame replacing a previously "Load"ed
|
---|
1350 | // image.
|
---|
1351 | //
|
---|
1352 | // If used with single frame drivers or if the driver doesn't support
|
---|
1353 | // this function, it returns BMMRES_SINGLEFRAME. If the return value
|
---|
1354 | // is BMMRES_SUCCESS, a new frame has been loaded into the given
|
---|
1355 | // bitmap.
|
---|
1356 | //
|
---|
1357 | // To define desired frame, use bi->SetCurrentFrame( frame );
|
---|
1358 | //
|
---|
1359 |
|
---|
1360 | BMMExport BMMRES GoTo ( BitmapInfo *bi );
|
---|
1361 |
|
---|
1362 | //-- Handy built-in functions
|
---|
1363 |
|
---|
1364 | BMMExport int Fill ( int r,int g,int b,int alpha);
|
---|
1365 |
|
---|
1366 |
|
---|
1367 |
|
---|
1368 |
|
---|
1369 | };
|
---|
1370 |
|
---|
1371 | //-- Various Bitmap In-Memory Lists -------------------------------------------
|
---|
1372 |
|
---|
1373 | typedef struct {
|
---|
1374 | BitmapStorage *ptr;
|
---|
1375 | void *next;
|
---|
1376 | } BMMStorageList;
|
---|
1377 |
|
---|
1378 | typedef struct {
|
---|
1379 | BitmapFilter *ptr;
|
---|
1380 | void *next;
|
---|
1381 | } BMMFilterList;
|
---|
1382 |
|
---|
1383 | typedef struct {
|
---|
1384 | Bitmap *ptr;
|
---|
1385 | void *next;
|
---|
1386 | } BMMBitmapList;
|
---|
1387 |
|
---|
1388 | typedef struct tag_BMMGammaSettings {
|
---|
1389 | BitmapManager *mgr;
|
---|
1390 | BitmapInfo *bi;
|
---|
1391 | BOOL out;
|
---|
1392 | } BMMGammaSettings;
|
---|
1393 |
|
---|
1394 | typedef struct tag_BMMVfbPalette {
|
---|
1395 | BYTE r,g,b;
|
---|
1396 | } BMMVfbPalette;
|
---|
1397 |
|
---|
1398 | //-----------------------------------------------------------------------------
|
---|
1399 | //-- Main Bitmap Manager Class
|
---|
1400 | //
|
---|
1401 |
|
---|
1402 | class BitmapManager {
|
---|
1403 |
|
---|
1404 | BitmapInfo *bi;
|
---|
1405 | BMMInterface *iface;
|
---|
1406 | Interface *max;
|
---|
1407 | TCHAR name[MAX_DESCRIPTION];
|
---|
1408 | BMMStorageList *storageList;
|
---|
1409 | BMMFilterList *filterList;
|
---|
1410 | BMMBitmapList *bitmapList;
|
---|
1411 | TCHAR *windowTitle;
|
---|
1412 | int storageCount;
|
---|
1413 | int filterCount;
|
---|
1414 | int bitmapCount;
|
---|
1415 | BOOL listdevices;
|
---|
1416 | BOOL viewonly;
|
---|
1417 | BOOL silentmode;
|
---|
1418 | DWORD loglevel;
|
---|
1419 | HWND hWnd;
|
---|
1420 |
|
---|
1421 | void DoConstruct ( BMMInterface *i, const TCHAR *n );
|
---|
1422 |
|
---|
1423 | void BrowseInput ( HWND hWnd, TCHAR *device );
|
---|
1424 | void BrowseOutput ( HWND hWnd, TCHAR *device );
|
---|
1425 |
|
---|
1426 | public:
|
---|
1427 |
|
---|
1428 | int channelMagn;
|
---|
1429 | BMMVfbPalette *pal;
|
---|
1430 |
|
---|
1431 | //-- Construction/Destruction
|
---|
1432 |
|
---|
1433 | BMMExport BitmapManager ( BMMInterface *i);
|
---|
1434 | BMMExport BitmapManager ( BMMInterface *i,const TCHAR *name);
|
---|
1435 | BMMExport ~BitmapManager ( );
|
---|
1436 | friend void DoConstruct ( BitmapManager *m, BMMInterface *i, const TCHAR *name);
|
---|
1437 |
|
---|
1438 | //-- These are for internal use only
|
---|
1439 |
|
---|
1440 | BMMExport int DeleteAllMaps ( );
|
---|
1441 | BMMExport int AddStorage ( BitmapStorage *s);
|
---|
1442 | BMMExport int AddFilter ( BitmapFilter *a);
|
---|
1443 | BMMExport int AddBitmap ( Bitmap *b);
|
---|
1444 | BMMExport int DelStorage ( BitmapStorage *s);
|
---|
1445 | BMMExport int DelFilter ( BitmapFilter *a);
|
---|
1446 | BMMExport int DelBitmap ( Bitmap *b);
|
---|
1447 | BMMExport BitmapFilter *FindFilter ( BitmapStorage *s,UINT type);
|
---|
1448 | BMMExport BitmapStorage *FindStorage ( BitmapInfo *bi, int openMode);
|
---|
1449 | BMMExport int FnametoBitMapInfo ( BitmapInfo *bi );
|
---|
1450 | BMMExport void FixFileExt ( OPENFILENAME &ofn, const TCHAR *extension);
|
---|
1451 | BMMExport void MakeVfbPalette ( );
|
---|
1452 |
|
---|
1453 | BMM_IOList ioList;
|
---|
1454 | BMMExport void ListIO ( );
|
---|
1455 |
|
---|
1456 | //-- File Read/Write Processes (internal use only)
|
---|
1457 |
|
---|
1458 | BOOL InputOptionsControl ( HWND,UINT,WPARAM,LPARAM );
|
---|
1459 | BOOL DeviceInputControl ( HWND,UINT,WPARAM,LPARAM );
|
---|
1460 | BOOL DeviceOutputControl ( HWND,UINT,WPARAM,LPARAM );
|
---|
1461 | BOOL ImageInfoDlg ( HWND,UINT,WPARAM,LPARAM );
|
---|
1462 | BOOL BrowseFiles ( BitmapInfo *, HWND, TCHAR *);
|
---|
1463 | BOOL OpenFileHook ( HWND,UINT,WPARAM,LPARAM );
|
---|
1464 | BOOL WriteFileHook ( HWND,UINT,WPARAM,LPARAM );
|
---|
1465 | BOOL GammaControl ( HWND,UINT,WPARAM,LPARAM, BMMGammaSettings *gs);
|
---|
1466 | void BuildIFL ( BitmapInfo *bi );
|
---|
1467 |
|
---|
1468 | //---------------------------------------------------------------------
|
---|
1469 | //-- Public Interface -------------------------------------------------
|
---|
1470 |
|
---|
1471 | //-- Host Interface
|
---|
1472 |
|
---|
1473 | BMMExport HINSTANCE AppInst ( );
|
---|
1474 | BMMExport HWND AppWnd ( );
|
---|
1475 | BMMExport DllDir *AppDllDir ( );
|
---|
1476 | BMMExport TCHAR *GetDir (int i);
|
---|
1477 | BMMExport BOOL AddMapDir (TCHAR *dir,int update);
|
---|
1478 | BMMExport int GetMapDirCount ( );
|
---|
1479 | BMMExport TCHAR *GetMapDir (int i);
|
---|
1480 | BMMExport Interface *Max () { return max; }
|
---|
1481 |
|
---|
1482 | //-- These won't stay here. Error handling will be dealt in a couple of
|
---|
1483 | // different ways. There will be a "Silent" flag that will be set by
|
---|
1484 | // the client and tested here in order to know if an error dialog should
|
---|
1485 | // go up. Normally, if the user is sitting in front of the computer
|
---|
1486 | // this flag will be FALSE. When rendering in the background, or network
|
---|
1487 | // rendering, etc., this flag will be TRUE. There should be some kind of
|
---|
1488 | // "preferences" configuration for this behavior.
|
---|
1489 | //
|
---|
1490 | // There also will be a method for logging errors. This method will check
|
---|
1491 | // for a "loggin on/off" flag and either add the entry or ignore it. The
|
---|
1492 | // bitmap manager and its devices will log everything that goes wrong.
|
---|
1493 | // When silent mode is on and logging is also on, this is the method to
|
---|
1494 | // check what went bad. Having each device logging its own error will
|
---|
1495 | // enable a more accurate description of the problem (as opposed to "I/O
|
---|
1496 | // error").
|
---|
1497 | //
|
---|
1498 | // Gus
|
---|
1499 | //
|
---|
1500 |
|
---|
1501 | BMMExport int Status ( int *sCount, int *aCount, int *bCount);
|
---|
1502 | BMMExport int Error ( const TCHAR *string);
|
---|
1503 |
|
---|
1504 | //-- Error handling ---------------------------------------------------
|
---|
1505 | //
|
---|
1506 | //
|
---|
1507 |
|
---|
1508 | //-- Max Interface (means no logging)
|
---|
1509 |
|
---|
1510 | #define LG_NOLOG 0
|
---|
1511 |
|
---|
1512 | //-- User Interface
|
---|
1513 |
|
---|
1514 | #define LG_FATAL ((DWORD)(1 << 0))
|
---|
1515 | #define LG_INFO ((DWORD)(1 << 1))
|
---|
1516 | #define LG_DEBUG ((DWORD)(1 << 2))
|
---|
1517 | #define LG_WARN ((DWORD)(1 << 3))
|
---|
1518 |
|
---|
1519 | //-- User Interface
|
---|
1520 |
|
---|
1521 | BMMExport BOOL SilentMode ( ) { return silentmode; }
|
---|
1522 | BMMExport void SysLog ( int type, char *format, ... );
|
---|
1523 |
|
---|
1524 | //-- Max Interface (used internally)
|
---|
1525 |
|
---|
1526 | BMMExport BOOL SetSilentMode ( BOOL s );
|
---|
1527 | BMMExport void SetLogLevel ( DWORD level ) { loglevel = level; }
|
---|
1528 | BMMExport DWORD GetLogLevel ( ) { return (loglevel); }
|
---|
1529 |
|
---|
1530 | //-- Creating a new bitmap from scracth -------------------------------
|
---|
1531 | //
|
---|
1532 | // Make sure the given BitmapInfo class has the proper data for the
|
---|
1533 | // creation of the bitmap. If you used the BitmapManager function to
|
---|
1534 | // define the bitmap (SelectBitmapOutput()), both filename and device
|
---|
1535 | // driver have been defined for you.
|
---|
1536 | //
|
---|
1537 | // Make sure to set the type of bimap using bi.SetType(). This will
|
---|
1538 | // define the storage type as in (so far):
|
---|
1539 | //
|
---|
1540 | // BMM_LINE_ART
|
---|
1541 | // BMM_PALETTED
|
---|
1542 | // BMM_GRAY_8
|
---|
1543 | // BMM_GRAY_16
|
---|
1544 | // BMM_TRUE_16
|
---|
1545 | // BMM_TRUE_32
|
---|
1546 | // BMM_TRUE_64
|
---|
1547 | //
|
---|
1548 | // Do NOT use BMM_TRUE_24 nor BMM_TRUE_48. These are read only types.
|
---|
1549 | //
|
---|
1550 | // Example code is in src/app/vpexecut.cpp
|
---|
1551 | //
|
---|
1552 | //
|
---|
1553 | // Once a bitmap has been created, use its own methods for adding
|
---|
1554 | // outputs and writing it (i.e. map->OpenOutput(), map->Write() and
|
---|
1555 | // map->Close()).
|
---|
1556 | //
|
---|
1557 | // Gus
|
---|
1558 | //
|
---|
1559 |
|
---|
1560 | BMMExport Bitmap *Create ( BitmapInfo *bi );
|
---|
1561 |
|
---|
1562 | //-- Creating a new bitmap from an existing Windows DIB ---------------
|
---|
1563 | //
|
---|
1564 | // To Convert a Bitmap to a Windows DIB check Bitmap::ToDib()
|
---|
1565 | //
|
---|
1566 |
|
---|
1567 | BMMExport Bitmap *Create ( PBITMAPINFO pbmi );
|
---|
1568 |
|
---|
1569 | //-- Loads Bitmap -----------------------------------------------------
|
---|
1570 | //
|
---|
1571 | // Loads a bitmap.
|
---|
1572 | //
|
---|
1573 | // Like most other bitmap functions, you should define the image to
|
---|
1574 | // to load (either setting the name/device directly in BitmapInfo bi,
|
---|
1575 | // or having SelectFileInput() do it for you). Once bi has the name
|
---|
1576 | // of the image you want to load, call Load() to create a new Bitmap
|
---|
1577 | // which contains the image. Additional options may be set by calling
|
---|
1578 | // ImageInputOptions() before calling Load(). That will as the user
|
---|
1579 | // for special details such as positioning of smaller/larger images,
|
---|
1580 | // etc. All this does is to set the proper fields in BitmapInfo. It's
|
---|
1581 | // up to you to use those.
|
---|
1582 | //
|
---|
1583 | // BitmapInfo defaults to frame "zero". For multifrane files, such as
|
---|
1584 | // *.avi, *.ifl, *.flc, etc. you should specify the frame number you
|
---|
1585 | // want. Do it by using bi.SetCurrentFrame(f) before calling Load().
|
---|
1586 | //
|
---|
1587 | //
|
---|
1588 | // Note: If loading images from a device, make sure bi.Name() is
|
---|
1589 | // empty (bi.SetName(_T(""));). This is automatic if you use
|
---|
1590 | // SelectDeviceInput(). If you just create a BitmapInfo
|
---|
1591 | // instance and set the device name by hand (bi.SetDevice()),
|
---|
1592 | // this is also automatic as both name and device names are
|
---|
1593 | // by default empty. This should only be a concern if you
|
---|
1594 | // reuse a BitmapInfo class previously used for image files.
|
---|
1595 | //
|
---|
1596 | //
|
---|
1597 | // One of the methods in BitmapInfo returns a window handle to send
|
---|
1598 | // progress report messages. If you want to receive these messages,
|
---|
1599 | // set the window handle ( bi->SetUpdateWindow(hWnd) ) and process
|
---|
1600 | // BMM_PROGRESS messages (see above).
|
---|
1601 | //
|
---|
1602 | // Gus
|
---|
1603 | //
|
---|
1604 |
|
---|
1605 | BMMExport Bitmap *Load ( BitmapInfo *bi, BMMRES *status = NULL);
|
---|
1606 |
|
---|
1607 | //-- Load Image into an existing Bitmap (Internal Use) ----------------
|
---|
1608 |
|
---|
1609 | BMMExport BMMRES LoadInto ( BitmapInfo *bi, Bitmap **map );
|
---|
1610 |
|
---|
1611 | //-- General User Interface -------------------------------------------
|
---|
1612 |
|
---|
1613 | BMMExport BMMRES GetImageInfoDlg ( HWND hWnd, BitmapInfo *bi, const TCHAR *filename = NULL );
|
---|
1614 | BMMExport BMMRES GetImageInfo ( BitmapInfo *bi, const TCHAR *filename = NULL );
|
---|
1615 | BMMExport BOOL ImageInputOptions ( BitmapInfo *bi, HWND hWnd );
|
---|
1616 | BMMExport BOOL SelectDeviceInput ( BitmapInfo *bi, HWND hWnd );
|
---|
1617 | BMMExport BOOL SelectDeviceOutput ( BitmapInfo *bi, HWND hWnd );
|
---|
1618 |
|
---|
1619 | BMMExport BOOL SelectFileOutput ( BitmapInfo *bi,
|
---|
1620 | HWND hWnd,
|
---|
1621 | TCHAR *title = NULL);
|
---|
1622 |
|
---|
1623 | BMMExport BOOL SelectFileInput ( BitmapInfo *bi,
|
---|
1624 | HWND hWnd,
|
---|
1625 | TCHAR *title = NULL);
|
---|
1626 |
|
---|
1627 | BMMExport BOOL SelectFileInputEx ( BitmapInfo *bi,
|
---|
1628 | HWND hWnd,
|
---|
1629 | TCHAR *title = NULL,
|
---|
1630 | BOOL viewonly = FALSE);
|
---|
1631 |
|
---|
1632 |
|
---|
1633 |
|
---|
1634 | };
|
---|
1635 |
|
---|
1636 | //-----------------------------------------------------------------------------
|
---|
1637 | //-- Forward References for Bitmap Functions
|
---|
1638 | //
|
---|
1639 | // Internal Use
|
---|
1640 | //
|
---|
1641 |
|
---|
1642 | extern int ValidBitmapType ( int type );
|
---|
1643 | extern BMMExport BitmapStorage *BMMCreateStorage ( BitmapManager *manager,UINT type );
|
---|
1644 | extern BMMExport BitmapFilter *BMMCreateFilter ( BitmapManager *manager,UINT type );
|
---|
1645 | extern BMMExport BitmapDither *BMMCreateDither ( BitmapManager *manager,UINT type );
|
---|
1646 | extern BMMExport int BMMCalcPalette ( Bitmap *map,int colors,BMM_Color_48 *palette );
|
---|
1647 | extern BMMExport BYTE BMMClosestColor ( BMM_Color_64 *color,BMM_Color_48 *palette,int colors );
|
---|
1648 |
|
---|
1649 | extern BMMExport void OpenBMM ( BMMInterface *i );
|
---|
1650 | extern BMMExport void CloseBMM ( );
|
---|
1651 | extern BOOL CALLBACK BMMGammaDlgProc (HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
|
---|
1652 | extern void ExtractExtension ( TCHAR *string, TCHAR *ext );
|
---|
1653 |
|
---|
1654 | //-----------------------------------------------------------------------------
|
---|
1655 | //-- Handy-dandy pixel buffer class
|
---|
1656 | //
|
---|
1657 |
|
---|
1658 | class PixelBuf {
|
---|
1659 |
|
---|
1660 | private:
|
---|
1661 |
|
---|
1662 | BMM_Color_64 *buf;
|
---|
1663 | int width;
|
---|
1664 |
|
---|
1665 | public:
|
---|
1666 |
|
---|
1667 | inline PixelBuf ( int width) { buf = (BMM_Color_64 *)calloc(width,sizeof(BMM_Color_64)); this->width=width; };
|
---|
1668 | inline ~PixelBuf ( ) { if(buf) free(buf); };
|
---|
1669 | inline BMM_Color_64 *Ptr ( ) { return buf; };
|
---|
1670 |
|
---|
1671 | int Fill ( int start, int count, BMM_Color_64 color ) {
|
---|
1672 | int ix,jx=start+count;
|
---|
1673 | if (jx > width)
|
---|
1674 | return 0;
|
---|
1675 | for(ix=start; ix<jx; buf[ix++]=color);
|
---|
1676 | return 1;
|
---|
1677 | };
|
---|
1678 | };
|
---|
1679 |
|
---|
1680 | //-- Public Utilities ---------------------------------------------------------
|
---|
1681 |
|
---|
1682 | BMMExport int BMMCreateNumberedFilename ( const TCHAR *namein,int frame,TCHAR *nameout );
|
---|
1683 | BMMExport int BMMGetFullFilename ( BitmapInfo *bi );
|
---|
1684 | BMMExport BOOL BMMIsFile ( const TCHAR *filename );
|
---|
1685 | BMMExport void BMMSplitFilename ( const TCHAR *name,TCHAR *p,TCHAR *f,TCHAR *e );
|
---|
1686 | BMMExport void BMMAppendSlash ( TCHAR *path );
|
---|
1687 | BMMExport BOOL BMMGetUniversalName ( TCHAR *szUniv, const TCHAR *szDrive );
|
---|
1688 | BMMExport LPTSTR BMMGetLastErrorText ( LPTSTR lpszBuf, DWORD dwSize );
|
---|
1689 |
|
---|
1690 | //-- 256 color dithering-----------------------------------------------------
|
---|
1691 | // For packing colors into 256 color paletted representation.
|
---|
1692 | // Create one with BMMNewColorPacker
|
---|
1693 | class ColorPacker {
|
---|
1694 | public:
|
---|
1695 | virtual void EnableDither(BOOL onoff)=0; // default: MAX default
|
---|
1696 | virtual void PropogateErrorBetweenLines(BOOL onoff)=0; // default ON;
|
---|
1697 | virtual void PackLine( BMM_Color_64* in, BYTE *out, int w)=0;
|
---|
1698 | virtual void PackLine( BMM_Color_48* in, BYTE *out, int w)=0;
|
---|
1699 | virtual void DeleteThis()=0;
|
---|
1700 | };
|
---|
1701 |
|
---|
1702 | // Get a color packer. When done, be sure to call its DeleteThis();
|
---|
1703 | BMMExport ColorPacker *BMMNewColorPacker(
|
---|
1704 | int w, // width of bitmap to be packed
|
---|
1705 | BMM_Color_48 *pal, // palette to use
|
---|
1706 | int npal, // number of entries in the palette
|
---|
1707 | BYTE* remap=NULL // optional remap done at last stage.
|
---|
1708 | );
|
---|
1709 |
|
---|
1710 | //---------------------------------------------------------------------
|
---|
1711 | // Color quantizer, for doing true-color to paletted conversion
|
---|
1712 | //
|
---|
1713 | class Quantizer {
|
---|
1714 | public:
|
---|
1715 | virtual int AllocHistogram(void)=0;
|
---|
1716 | virtual int Partition(BMM_Color_48 *pal, int palsize, BMM_Color_64 *forceCol)=0;
|
---|
1717 | virtual void AddToHistogram(BMM_Color_64 *image, int npix)=0;
|
---|
1718 | virtual void AddToHistogram(BMM_Color_48 *image, int npix)=0;
|
---|
1719 | virtual void AddToHistogram(BMM_Color_24 *image, int npix)=0;
|
---|
1720 | virtual void DeleteThis()=0;
|
---|
1721 | };
|
---|
1722 |
|
---|
1723 | BMMExport Quantizer *BMMNewQuantizer();
|
---|
1724 |
|
---|
1725 | // Rearrange palette "pal" ( which has colors 0..ncols-1 occupied,
|
---|
1726 | // in descending order of frequency), into "newpal" so that the colors 10-245 are
|
---|
1727 | // populated first, then 0-9, then 246-255. Sets optional array "remap" to map the
|
---|
1728 | // old palette index values to the new ones
|
---|
1729 | BMMExport void FixPaletteForWindows(BMM_Color_48 *pal, BMM_Color_48 *newpal,int ncols, BYTE *remap=NULL);
|
---|
1730 |
|
---|
1731 | //-- Cleanup ------------------------------------------------------------------
|
---|
1732 |
|
---|
1733 | #undef bVirtual
|
---|
1734 |
|
---|
1735 |
|
---|
1736 | #endif BITMAP_H_DEFINED
|
---|
1737 |
|
---|
1738 | //-- EOF: bitmap.h ------------------------------------------------------------
|
---|