bitmap.h

Go to the documentation of this file.
00001 //**************************************************************************/
00002 // Copyright (c) 1998-2006 Autodesk, Inc.
00003 // All rights reserved.
00004 //
00005 // These coded instructions, statements, and computer programs contain
00006 // unpublished proprietary information written by Autodesk, Inc., and are
00007 // protected by Federal copyright law. They may not be disclosed to third
00008 // parties or copied or duplicated in any form, in whole or in part, without
00009 // the prior written consent of Autodesk, Inc.
00010 //**************************************************************************/
00011 // FILE:        bitmap.h
00012 // DESCRIPTION: 
00013 // AUTHOR:      Tom Hudson
00014 // HISTORY:     Sep, 01 1994 - Started serious coding
00015 //            Oct, 18 1994 - First major revision for DLLs, restructuring
00016 //            Jul, 10 1995 - Began working with it (Gus J Grubba)
00017 //**************************************************************************/
00018 
00019 #pragma once
00020 #include "BMMExport.h"
00021 #include <WTypes.h>
00022 #include <vfw.h>
00023 #include <CommDlg.h>
00024 #include "maxheap.h"
00025 #include "palutil.h"
00026 #include "linklist.h"
00027 #include "gbuf.h"
00028 #include "pixelbuf.h"
00029 #include "path.h"
00030 #include "containers\array.h"
00031 #include "assetmanagement\AssetType.h"
00032 #include "assetmanagement\IAssetAccessor.h"
00033 #include "assetmanagement\AssetUser.h"
00034 #include "matrix3.h"
00035 #include "GetCOREInterface.h"
00036 #include "box2.h"
00037 
00038 //-- Defines that may change with compiler
00039 #define INTBITS (sizeof(int) * 8)
00040 
00041 //-- Class ID's for various DLL's
00042 #define IMGCLASSID      1
00043 #define CYCLECLASSID    2
00044 #define FLICCLASSID     5
00045 #define TARGACLASSID    6
00046 #define YUVCLASSID      7
00047 #define FBCLASSID       8
00048 #define WSDCLASSID      9
00049 #define IFLCLASSID      10
00050 #define BMPCLASSID      11
00051 #define JPEGCLASSID     12
00052 #define TARGAPLSCLASSID 13
00053 #define AVICLASSID      14
00054 #define RLACLASSID      15
00055 #define RPFCLASSID      16
00056 #define MPGCLASSID      17
00057 // Class ID for the OpenEXR I/O plugin
00058 #define MAXOPENEXR_CLASSID      Class_ID(0x12f95b5e, 0x62a60b57)
00059 
00060 //-- local definitions
00061 
00062 class BitmapManager;
00063 class BitmapManagerImp;
00064 class BitmapProxyManager;
00065 class BitmapStorage;
00066 class BitmapFilter;
00067 class BitmapDither;
00068 class BitmapInfo;
00069 class BitmapPicker;
00070 class BitmapIO;
00071 class Bitmap;
00072 
00073 //-- Temporary definitions to make the compiler happy
00074 
00075 class GraphicsWindow;
00076 class BMMInterface;
00077 class DllDir;
00078 
00079 //-- External data 
00080 
00081 extern int  TheSystemFrame;         // TO DO: Move to App data structure?
00082 
00083 //-----------------------------------------------------------------------------
00084 //-- The Primary Bitmap Manager Object
00085 //
00086 
00087 extern BMMExport BitmapManager *TheManager; // TO DO: Move to App data structure?
00088 
00089 //-- Common Macros ------------------------------------------------------------
00090 
00091 //-- Set up a NULL macro
00092 
00093 #ifndef NULL
00094 #define NULL (0)
00095 #endif
00096 
00097 //-----------------------------------------------------------------------------
00098 //-- Image I/O History (Used by the File Picker Dialog ------------------------
00099 //
00100 class bmmHistoryList: public MaxHeapOperators {
00101 
00102     protected:
00103 
00104         MCHAR   title[MAX_PATH];
00105         MCHAR   initDir[MAX_PATH];
00106         HWND    hParent,hChild;
00107         int     listID;
00108 
00109         BMMExport void  StripSpaces (MCHAR *string);
00110 
00111     public:
00112 
00113         BMMExport void  Init        ( const MCHAR *title );
00114         BMMExport void  SetDlgInfo  ( HWND hParent, HWND hChild, int ListID );
00115         BMMExport void  LoadDefaults( );
00116         BMMExport void  LoadList    ( );
00117         BMMExport void  SaveList    ( );
00118         BMMExport void  SetPath     ( bool first = false );
00119         BMMExport void  NewPath     ( const MCHAR *path );
00120         BMMExport MCHAR*DefaultPath ( ) { return initDir; }
00121         BMMExport void  SetPath     ( const MCHAR *path );
00122         BMMExport int   Count       ( );
00123 
00124 };
00125 
00126 //-- Generic bitmap information structure -------------------------------------
00127 
00128 struct BMMImageInfo : public MaxHeapOperators {
00129    int   width,height;
00130    float aspect,gamma;
00131    DWORD flags;
00132 };
00133 
00134 //-- Basic bitmap types supported by Bitmap Manager
00139 #define BMM_NO_TYPE              0   //!<  Not allocated yet
00140 #define BMM_LINE_ART             1   //!<  1-bit monochrome image
00141 #define BMM_PALETTED             2   //!<  8-bit paletted image. Each pixel value is an index into the color table.
00142 #define BMM_GRAY_8               3   //!<  8-bit grayscale bitmap.
00143 #define BMM_GRAY_16              4   //!<  16-bit grayscale bitmap.
00144 #define BMM_TRUE_16              5   //!<  16-bit true color image.
00145 #define BMM_TRUE_32              6   //!<  32-bit color: 8 bits each for Red, Green, Blue, and Alpha.
00146 #define BMM_TRUE_64              7   //!<  64-bit color: 16 bits each for Red, Green, Blue, and Alpha.
00147 
00150 #define BMM_LOGLUV_32            13
00151 
00153 #define BMM_LOGLUV_24            14
00154 
00156 #define BMM_LOGLUV_24A           15
00157 #define BMM_REALPIX_32           16   //!<  The "Real Pixel" format.
00158 #define BMM_FLOAT_RGBA_32        17   //!<  32-bit floating-point per component (non-compressed), RGB with or without alpha
00159 #define BMM_FLOAT_GRAY_32        18   //!<  32-bit floating-point (non-compressed), monochrome/grayscale
00160 
00161 //-- Information Only
00162 
00163 #define BMM_TRUE_24              8    //!< 24-bit color: 8 bits each for Red, Green, and Blue. Cannot be written to.
00164 #define BMM_TRUE_48              9    //!< 48-bit color: 16 bits each for Red, Green, and Blue. Cannot be written to.
00165 #define BMM_YUV_422              10   //!< This is the YUV format - CCIR 601. Cannot be written to.
00166 #define BMM_BMP_4                11   //!< Windows BMP 16-bit color bitmap.  Cannot be written to.
00167 #define BMM_PAD_24               12   //!< Padded 24-bit (in a 32 bit register).  Cannot be written to.
00168 
00171 #define BMM_FLOAT_RGB_32         19
00172 
00175 #define BMM_FLOAT_A_32           20
00176 
00177 
00178 //-- Textual Limits
00179 
00180 #define MAX_DESCRIPTION          256
00181 
00182 //-- The number of bitmap formats supported internally
00183 
00184 //#define BMM_FORMATS            6
00185 
00186 //-- File types
00187 
00188 //#define BMM_NOTYPE             0
00189 //#define BMM_TARGA              1       // System Targa I/O driver
00190 //#define BMM_GIF                2       // System GIF I.O driver
00191 
00192 //-- Gamma limits
00193 
00194 #define MINGAMMA                 0.2f
00195 #define MAXGAMMA                 5.0f
00196 
00199 #define BMM_NOT_OPEN             0  //!< Not opened yet
00200 #define BMM_OPEN_R               1  //!< Read-only
00201 #define BMM_OPEN_W               2  //!< Write-only. No reads will occur.
00202 
00203 
00204 //-----------------------------------------------------------------------------
00205 //-----------------------------------------------------------------------------
00209 typedef unsigned short BMMRES;              
00210 
00211 #define BMMRES_SUCCESS                0     //!< Success - No error occurred.
00212 #define BMMRES_ERRORTAKENCARE         1     //!< Error - Function has already taken action to process the error.
00213 #define BMMRES_FILENOTFOUND           2     //!< The file being accessed was not found.
00214 #define BMMRES_MEMORYERROR            3     //!< Insufficient memory for the requested operation.
00215 #define BMMRES_NODRIVER               4     //!< Device driver responsible for image not present
00216 #define BMMRES_IOERROR                5     //!< Input / Output error.
00217 #define BMMRES_INVALIDFORMAT          6     //!< The file being access was not of the proper format for the requested operation.
00218 #define BMMRES_CORRUPTFILE            7     //!< The file being accessed was corrupt.       
00219 #define BMMRES_SINGLEFRAME            8     //!< Results from a goto request on a single frame image
00220 #define BMMRES_INVALIDUSAGE           9     //!< Bad argument passed to function (Developer Mistake)
00221 
00223 #define BMMRES_RETRY                  10    //!< User selected "Retry" from error dialogue.
00224 #define BMMRES_NUMBEREDFILENAMEERROR  11    //!< This can be passed as an errorcode to BitmapIO::ProcessImageIOError().
00225 #define BMMRES_INTERNALERROR          12    //!< An internal error occurred.
00226 #define BMMRES_BADFILEHEADER          13    //!< A file header error occurred.
00227 #define BMMRES_CANTSTORAGE            14    //!< This is used internally.
00228 #define BMMRES_BADFRAME               15    //!< Invalid Frame Number Requested
00229 
00230 //-----------------------------------------------------------------------------
00231 //-----------------------------------------------------------------------------
00235 #define BMMIO_NONE                         0   //!< Not defined yet
00236 
00237 #define BMMIO_READER                   (1<<0)  //!< Reads image files
00238 #define BMMIO_WRITER                   (1<<1)  //!< Writes image files
00239 #define BMMIO_EXTENSION                (1<<2)  //!< Uses file extension (File Filter Type)
00240 #define BMMIO_MULTIFRAME               (1<<3)  //!< "File" contains multiple frames (i.e. FLC, AVI)
00241 
00242 #define BMMIO_THREADED                 (1<<4)  //!< Not used. All plugin are expected to be "thread aware".
00243 #define BMMIO_RANDOM_ACCESS            (1<<5)  //!< Can read and/or write frames in any order
00244 #define BMMIO_NON_CONCURRENT_ACCESS    (1<<6)  //!< Device cannot handle multiple, concurrent requests (FLC, AVI, VTR's, etc)
00245 
00246 #define BMMIO_OWN_VIEWER               (1<<7)  //!< Driver has its own image viewer for its image type as opposed to using the generic Virtual Frame Buffer.
00247 
00248 //-- Frame Buffers
00249 
00250 #define BMMIO_FRAMEBUFFER              (1<<7)  //!< Frame Buffer Driver
00251 #define BMMIO_GRABBER                  (1<<8)  //!< Device Grabs Video
00252 
00255 #define BMMIO_INFODLG                   (1<<9) //!< Has Info Dialog
00256 
00259 #define BMMIO_UNINTERRUPTIBLE           (1<<10) //!< Uninterruptible Driver
00260 
00263 #define BMMIO_EVALMATCH         (1<<11) //!< EvalMatch() method has been implemented.
00264 
00270 #define BMMIO_IFL                (1<<28) //!< Special IFL device
00271 
00275 #define BMMIO_CONTROLREAD        (1<<29) //!< Device Driver has Control Panel for Read Operations
00276 #define BMMIO_CONTROLWRITE       (1<<30) //!< Device Driver has Control Panel for Write Operations
00277 #define BMMIO_CONTROLGENERIC     (1<<31) //!< Device Driver has a generic Control Panel
00278 
00279 
00280 //-----------------------------------------------------------------------------
00281 
00286 #define BMM_CLOSE_COMPLETE       0  //!< Close and save the image.
00287 
00291 #define BMM_CLOSE_ABANDON        1  //!< Close but abandon the image.
00292 
00293 
00294 //-- Filter Types
00295 
00312 #define BMM_FILTER_NONE          0  //!< Specifies no filtering should be performed.
00313 #define BMM_FILTER_DUMMY         1  //!< No longer used.
00314 #define BMM_FILTER_SUM           2  //!< Specifies summed area filtering.
00315 #define BMM_FILTER_PYRAMID       3  //!< Specifies pyramidal filtering.
00316 
00317 
00318 //-- Filter Flag values
00319 
00320 #define BMM_FILTER_NOFLAGS       ((DWORD)0)
00321 #define BMM_FILTER_LERP_WRAP     ((DWORD)(1<<0))
00322 // Set when when the filter fails to build its lookup table, cleared otherwise
00323 #define BMM_FILTER_BUILD_FAILED  ((DWORD)(1<<1))
00324 
00325 //-- Dither Types
00326 
00327 #define BMM_DITHER_NONE          0
00328 #define BMM_DITHER_FLOYD         1
00329 
00330 //-- Pyramidal filter information
00331 
00332 #define MAX_PYRAMID_DEPTH        12
00333 #define LAYER_DIM                MAX_PYRAMID_DEPTH+1
00334 
00335 struct BMM_Pyramid: public MaxHeapOperators {
00336    WORD  dmax;
00337    void  *map[LAYER_DIM];
00338    void  *alpha[LAYER_DIM]; 
00339 };
00340 
00341 //-- Summed-area table information
00342 
00343 struct BMM_SAT: public MaxHeapOperators {
00344    DWORD *sat_r,*sat_g,*sat_b,*sat_a;
00345 };
00346 
00349 #define COPY_IMAGE_CROP                 0  //!< Copy image to current map size w/cropping if necessary
00350 
00352 #define COPY_IMAGE_RESIZE_LO_QUALITY    1  //!< Resize source image to destination map size (draft)
00353 
00355 #define COPY_IMAGE_RESIZE_HI_QUALITY    2  //!< Resize source image to destination map size (final)
00356 #define COPY_IMAGE_USE_CUSTOM           3  //!< Resize based on Image Input Options (BitmapInfo *)
00357 
00358 
00359 // Class for storing a linked list of file extension strings
00360 typedef LinkedEntryT<MSTR> MSTREntry; 
00361 typedef LinkedListT<MSTR,MSTREntry> MSTRList;
00362 
00363 //-- GRAINSTART
00364 //-- Callback for Bitmap Effects
00365 typedef BOOL (WINAPI* PBITMAP_FX_CALLBACK)( LPVOID lpparam, int done, int total, MCHAR* msg );
00366 //-- GRAINEND
00367 
00368 //-----------------------------------------------------------------------------
00369 //-- I/O Handler
00370 //
00371    
00376 class BMM_IOHandler : public MaxHeapOperators 
00377 {
00378    private:
00379       //-- Name and Capabilities ------------------------
00380       
00381       MCHAR      ioShortDesc[MAX_DESCRIPTION]; 
00382       MCHAR      ioLongDesc[MAX_DESCRIPTION];
00383       DWORD      ioCapabilities;
00384 
00385       //-- Extension for file types
00386       
00387       MSTRList   ioExtension;
00388       
00389       //-- DLL Handler ----------------------------------
00390       
00391       int      dllNumber;
00392       // the classID of the Class Descriptor that this points to.
00393       Class_ID mClassID;
00394       // the superclassID of the Class Descriptor that this points to.
00395       SClass_ID mSuperID;
00396       
00397    public:
00398 
00401       BMMExport BMM_IOHandler();
00402       
00408       BMMExport MCHAR*           ShortDescription ( const MCHAR*  d = NULL );
00414       BMMExport MCHAR*           LongDescription  ( const MCHAR*  d = NULL );
00422       BMMExport MCHAR*           Extension        ( int index, const MCHAR*  e = NULL );
00425       BMMExport int              NumExtensions    ( )                { return ioExtension.Count(); }
00426 
00430       BMMExport void             SetCD            ( ClassDesc* dll );
00432       BMMExport ClassDesc*       GetCD            ( );
00433       BMMExport Class_ID         GetClassID       ( );
00434       BMMExport SClass_ID        GetSuperID       ( );
00435       BMMExport void             SetDllNumber     ( int num )        { dllNumber = num; }
00436       BMMExport int              GetDllNum        ( )                { return dllNumber; }
00437 
00442       BMMExport void             SetCapabilities  ( DWORD cap )      { ioCapabilities |= cap;};
00445       BMMExport DWORD            GetCapabilities  ( )                { return (ioCapabilities);};
00453       BMMExport BOOL             TestCapabilities ( DWORD cap )      { return ((ioCapabilities& cap) != 0);};
00455       BMMExport BMM_IOHandler&   operator=(BMM_IOHandler& from);
00456 };
00457 
00458 //-----------------------------------------------------------------------------
00459 //-- List of I/O Handlers
00460 //
00461 
00462 // Class for storing a linked list of Bitmap Manager BMM_IOHandler objects
00463 typedef LinkedEntryT<BMM_IOHandler> BMM_IOHandlerEntry; 
00464 typedef LinkedListT<BMM_IOHandler,BMM_IOHandlerEntry> BMM_IOHandlerList;
00465 
00470 class BMM_IOList: public BMM_IOHandlerList {
00471 
00472       BOOL     listed;
00473        
00474    public:
00475 
00478       BMM_IOList          ( )                { listed = FALSE; }
00479 
00485       BOOL     Listed     ( BOOL f)          { listed = f; return (listed);};
00488       BOOL     Listed     ( )                { return (listed);};
00489 
00497       BMMExport int   FindDevice             ( const MCHAR *name);
00504       BMMExport int   FindDeviceFromFilename ( const MCHAR *name);
00519       BMMExport int   ResolveDevice          ( BitmapInfo *bi   );
00526       BMMExport DWORD GetDeviceCapabilities  ( const MCHAR *name);
00527 
00528       //-- This Creates an Instance - Make sure to "delete" it after use.
00529 
00537       BMMExport BitmapIO *CreateDevInstance( const MCHAR *d );
00545       BMMExport BitmapIO *CreateDevInstance( int idx );
00546 
00547 };
00548 
00549 
00550 
00551 //-----------------------------------------------------------------------------
00552 //-- RenderInfo Class
00553 //
00554 
00555 enum ProjectionType { ProjPerspective=0, ProjParallel=1 };
00556 
00557 // WARNING: IF YOU CHANGE the RenderInfo data structure, the RPF writing code (rla.cpp ) has to
00558 // be modified to read the old version as well as the new.  DS 9/7/00
00559 
00593 class RenderInfo: public MaxHeapOperators {
00594    public:
00605    RenderInfo();
00606    ProjectionType projType;  
00607    float kx,ky;            // 3D to 2D projection scale factor 
00608    float xc,yc;           // screen origin
00609    BOOL fieldRender;    // field rendered?
00610    BOOL fieldOdd;         // if true, the first field is Odd lines
00611    // Render time and tranformations for the 2 fields, if field rendering. 
00612    // If not, use renderTime[0], etc.
00613    TimeValue renderTime[2]; 
00614    Matrix3 worldToCam[2];     
00615    Matrix3 camToWorld[2];
00616    Rect region;  // sub-region in image that was rendered if last render was a region render. Empty if not a region render. -- DS--7/13/00
00625    BMMExport Point2 MapWorldToScreen(Point3 p, int field=0) { return MapCamToScreen(worldToCam[field]*p);}
00631    BMMExport Point2 MapCamToScreen(Point3 p);  // map point in camera space to screen
00637    BMMExport Ray MapScreenToCamRay(Point2 p);  // get viewing ray through screen point, in camera space
00646    BMMExport Ray MapScreenToWorldRay(Point2 p, int field=0); // get viewing ray through screen point, in world space
00647    };
00648 
00649 //-----------------------------------------------------------------------------
00650 //-- Bitmap Info Class
00651 //
00652 
00656 #define MAP_NOFLAGS              ((DWORD)0)         //!< The bitmap has none of the characteristics below.
00657 #define MAP_READY                ((DWORD)(1<<0))    //!< This bitmap has had memory allocated to it, or is accessible directly.
00658 
00661 #define MAP_HAS_ALPHA            ((DWORD)(1<<1))    //!< The bitmap has an alpha channel.
00662 #define MAP_ALPHA_PREMULTIPLIED  ((DWORD)(1<<2))    //!< The bitmap has pre-multiplied alpha.
00663 #define MAP_PALETTED             ((DWORD)(1<<3))    //!< The bitmap uses a palette (not true color).
00664 #define MAP_FRAME_SYSTEM_LOCKED  ((DWORD)(1<<4))    //!< This flag is no longer used.
00665 #define MAP_DITHERED             ((DWORD)(1<<5))    //!< The bitmap is dithered.
00666 #define MAP_FLIPPED              ((DWORD)(1<<6))    //!< The bitmap is flipped horizontally
00667 #define MAP_INVERTED             ((DWORD)(1<<7))    //!< The bitmap is flipped vertically
00668 
00669 //#define MAP_CUSTOMSIZE           ((DWORD)(1<<8))     // Custom size for input
00670 //#define MAP_RESIZE               ((DWORD)(1<<9))     // Resize when input
00671 
00672 #define MAP_USE_SCALE_COLORS     ((DWORD)(1<<10))   //!< Scale colors when high dynamic range values are out of gamut
00673 
00678 #define MAP_PROXY                ((DWORD)(1<<11))   //!< Indicates a proxy bitmap, reduced from original size / bit depth
00679 
00683 #define MAP_PROXYREQUEST         ((DWORD)(1<<12))   //!< Indicates a request to load proxy bitmap, reduced from original size / bit depth
00684 
00685 #ifdef _ENABLE_BITMAP_PRINTING_
00686 #define MAP_HAS_BGIMAGE          ((DWORD)(1<<29))    //!< internal use only
00687 #endif
00688 #define MAP_LEGAL_DELETE         ((DWORD)(1<<30))    //!< internal use only
00689 #define MAP_VIEW_FILTERED        ((DWORD)(1<<31))    //!< Test stuff
00690 
00691 #define MAP_ALL_FLAGS            0xFFFFFFFF
00692 
00693 
00694 //-----------------------------------------------------------------------------
00695 //-- Messages sent back by various (client) methods
00696 
00697 //-- Sent by the plug-in to notify host of current progress. The host should
00698 //   return TRUE if it's ok to continue or FALSE to abort process.
00699 
00700 #define BMM_PROGRESS   WM_USER + 0x120   //-- wParam: Current lParam: Total
00701 
00702 //-- Sent by the plug-in to check for process interruption. The host should
00703 //   return FALSE (by setting lParam) if it's ok to continue or TRUE to abort 
00704 //   process.
00705 
00706 #define BMM_CHECKABORT WM_USER + 0x121   //-- wParam: 0       lParam: *BOOL
00707 
00708 //-- Sent by the plug-in to display an optional textual message (for progress
00709 //   report).
00710 
00711 #define BMM_TEXTMSG    WM_USER + 0x122   //-- wParam: 0       lParam: LPCMSTR
00712 
00723 class BitmapInfo: public MaxHeapOperators {
00724    
00725         //-- Image name in case of named images such as files -------
00726 
00727         MaxSDK::Util::Path mFilename;
00728         MaxSDK::AssetManagement::AssetUser mAssetUser;
00729 
00730         //-- Device name gotten from BMM_IOHandler::LongDescription() 
00731 
00732         MCHAR                    device[MAX_DESCRIPTION];
00733 
00734         //-- Window Handle to send BMM_UPDATE messages --------------
00735 
00736         HWND                     hWnd;
00737 
00738         //-- Plug-In Parameter Block --------------------------------
00739 
00740         void                    *pidata;
00741         DWORD                    pisize;
00742 
00743         //-- Proxy subject info -------------------------------------
00744 
00746 
00747         BitmapInfo              *proxysubject;
00748 
00749         //-- Basic Image Data ---------------------------------------
00750         //
00751         //   When reading an image, or asking for image info, these
00752         //   fields will tell the user what the image is like.
00753         //
00754         //   When creating an image the user will set these fields to
00755         //   the desired parameters.
00756         //
00757 
00758         WORD                     width,height;
00759         float                    aspect,gamma;
00760         int                      fstart,fend;
00761         DWORD                    flags,type;
00762 
00763         //-- User data (what user wants) ----------------------------
00764         //
00765         //   Custom dimmensions, custom start and end point when
00766         //   reading sequence of imges, frame to fetch/save, etc.
00767         //
00768 
00769         WORD                     cwidth,cheight;   
00770         int                      custxpos,custypos;
00771         int                      start,end;        
00772         int                      step,preset_al;
00773         float                    custgamma;        
00774 
00775         #define BMM_UNDEF_FRAME   0x7FFF0000
00776 
00780         #define BMM_CUSTOM_GAMMA        ((DWORD)(1 << 0))   //!< Custom gamma setting
00781         #define BMM_CUSTOM_SIZE         ((DWORD)(1 << 1))   //!< Custom size setting
00782         #define BMM_CUSTOM_RESFIT       ((DWORD)(1 << 2))   //!< Bitmap is to be resized
00783         #define BMM_CUSTOM_POS          ((DWORD)(1 << 3))   //!< Bitmap has a custom positioning
00784         #define BMM_CUSTOM_FILEGAMMA    ((DWORD)(1 << 4))   //!< Bitmap has a custom file gamma setting
00785         #define BMM_CUSTOM_IFLENUMFILES ((DWORD)(1 << 5))   //!< 
00786         #define BMM_CUSTOM_HDR_TYPE ((DWORD)(1 << 6))   //!< Internal Use Only.  Bitmap has custom hdr type that reads storage infor from BitMap Info and not from UI.  
00787 
00789 
00795         #define BMM_CUSTOM_POSNW  0 //!< Top Left
00796         #define BMM_CUSTOM_POSN   1 //!< Top Center
00797         #define BMM_CUSTOM_POSNE  2 //!< Top Right
00798         #define BMM_CUSTOM_POSW   3 //!< Middle Left
00799         #define BMM_CUSTOM_POSCN  4 //!< Center
00800         #define BMM_CUSTOM_POSE   5 //!< Middle Right
00801         #define BMM_CUSTOM_POSSW  6 //!< Bottom Left
00802         #define BMM_CUSTOM_POSS   7 //!< Bottom Center
00803         #define BMM_CUSTOM_POSSE  8 //!< Bottom Right
00804 
00805         DWORD                    customflags;
00806 
00807         int                      fnumber;           //-- Defines frame to
00808                                                   //   read or write.
00809 
00810         //-- When reading a sequence of frames, loopflag indicates what to
00811         //   do when reading beyond the end of available frames. It 
00812         //   defaults to BMM_SEQ_WRAP.
00813 
00814         #define  BMM_SEQ_WRAP     0                  //-- Wraps around back to start point
00815         #define  BMM_SEQ_ERROR    1                  //-- Generates an error
00816         #define  BMM_SEQ_HOLD     2                  //-- Holds last frame when done
00817                 
00818         WORD                     loopflag;         
00819 
00820         void                     doConstruct                 ( );
00821       
00822    public:
00823 
00837         BMMExport                BitmapInfo                  ( );
00843         BMMExport                BitmapInfo                  ( const MCHAR *n );
00849         BMMExport                BitmapInfo                  ( const MaxSDK::AssetManagement::AssetUser &asset );
00856         BMMExport                BitmapInfo                  ( const BitmapInfo &bi );
00857         BMMExport               ~BitmapInfo                  ( );
00858 
00859         //-- Bitmap Flags
00860 
00862         BMMExport DWORD          Flags                       ( ) { return (flags); }
00869         BMMExport DWORD          SetFlags                    ( DWORD f ) { flags |=  f; return (flags); }
00870         BMMExport DWORD          ResetFlags                  ( DWORD f ) { flags &= ~f; return (flags); }
00876         BMMExport BOOL           TestFlags                   ( DWORD f ) { return (flags & f); }
00877 
00878         //-- Generic Read
00879 
00882         BMMExport WORD           Width                       ( ) { return (width); }
00885         BMMExport WORD           Height                      ( ) { return (height); }
00887         BMMExport float          Gamma                       ( ) { return (gamma); }
00889         BMMExport float          Aspect                      ( ) { return (aspect);}
00891         BMMExport int            Type                        ( ) { return (type); }
00895         BMMExport int            FirstFrame                  ( ) { return (fstart); }
00897         BMMExport int            LastFrame                   ( ) { return (fend); }
00900         BMMExport int            NumberFrames                ( ) { return (fend - fstart + 1); }
00902         BMMExport int            CurrentFrame                ( ) { return (fnumber); }
00917         BMMExport WORD           SequenceOutBound            ( ) { return (loopflag); }
00918 
00926         BMMExport const MCHAR   *Name                        ( ) const;
00927 
00933         BMMExport MaxSDK::Util::Path GetPathEx() const;
00934 
00935         //-- "Filename" returns just the name of image file
00936 
00939         BMMExport const MCHAR   *Filename                    ( );
00940 
00941         //-- "Device" is the device reponsible for producing this image.
00942         //   For file types, this is just informative. For non file types
00943         //   this is the way this image is identified. Therefore, it is
00944         //   important to save both name and device in order to properly
00945         //   identify an image.
00946 
00952         BMMExport const MCHAR   *Device                      ( ) { return (const MCHAR *)device; }
00953 
00954         //-- Compare Two Bitmaps
00955 
00965         BMMExport BOOL           CompareName                 ( BitmapInfo *bi );
00966 
00967         //-- Copy Image info. Only name, device and image characteristics are
00968         //   copied. User info, such as Custom Width, etc. is not copied. 
00969 
00982         BMMExport void           CopyImageInfo               ( BitmapInfo *from );
00983 
00984         //-- Generic Write
00985 
00991         BMMExport int            SetFirstFrame               ( int m ) { int o = fstart;   fstart   = m; return (o);}
00997         BMMExport int            SetLastFrame                ( int s ) { int o = fend;     fend     = s; return (o);}
01003         BMMExport int            SetCurrentFrame             ( int v ) { int o = fnumber;  fnumber  = v; return (o);}
01020         BMMExport WORD           SetSequenceOutBound         ( WORD  c ) { WORD  o = loopflag; loopflag = c; return (o);}
01021 
01028         BMMExport WORD           SetWidth                    ( WORD  s ) { WORD  o = width;    width    = s; return (o);}
01035         BMMExport WORD           SetHeight                   ( WORD  u ) { WORD  o = height;   height   = u; return (o);}
01042         BMMExport float          SetGamma                    ( float c ) { float o = gamma;    gamma    = c; return (o);}
01049         BMMExport float          SetAspect                   ( float k ) { float o = aspect;   aspect   = k; return (o);}
01056         BMMExport int            SetType                     ( int   s ) { int   o = type;     type     = s; return (o);}
01057 
01063         BMMExport void SetPath(const MaxSDK::Util::Path &path);
01064 
01087         BMMExport const MCHAR   *SetName        ( const MCHAR *n );
01088         
01090         BMMExport const MaxSDK::AssetManagement::AssetUser& GetAsset() const;
01091 
01096         BMMExport void SetAsset( const MaxSDK::AssetManagement::AssetUser& assetUser ) ;
01097 
01103         BMMExport const MCHAR   *SetDevice                   ( const MCHAR *d );
01104 
01105         //-- Custom Input Processing
01106 
01108         BMMExport WORD           CustWidth                   ( ) { return (cwidth);        }
01110         BMMExport WORD           CustHeight                  ( ) { return (cheight);       }
01115         BMMExport void           SetCustWidth                ( WORD w ) { cwidth  = w;     }
01120         BMMExport void           SetCustHeight               ( WORD h ) { cheight = h;     }
01123         BMMExport int            StartFrame                  ( ) { return (start);         }
01126         BMMExport int            EndFrame                    ( ) { return (end);           }
01132         BMMExport void           SetStartFrame               ( int s )  { start = s;      }
01137         BMMExport void           SetEndFrame                 ( int e )  { end   = e;      }
01144         BMMExport void           SetCustomX                  ( int x ) { custxpos = x;    }
01151         BMMExport void           SetCustomY                  ( int y ) { custypos = y;    }
01153         BMMExport int            GetCustomX                  ( ) { return custxpos;        }
01155         BMMExport int            GetCustomY                  ( ) { return custypos;        }
01161         BMMExport void           SetCustomGamma              ( float g ) { custgamma = g;  }
01163         BMMExport float          GetCustomGamma              ( ) { return custgamma;       }
01166         BMMExport float          GetEffectiveGamma           ( );
01172         BMMExport void           SetCustomStep               ( int s ) { step = s;         }
01175         BMMExport int            GetCustomStep               ( ) { return step;            }
01184         BMMExport void           SetPresetAlignment          ( int p ) { preset_al = p;    }
01189         BMMExport int            GetPresetAlignment          ( ) { return preset_al;       }
01190 
01191         //-- Custom Input Flags
01192 
01195         BMMExport DWORD          GetCustomFlags              ( ) { return (customflags);             }
01200         BMMExport void           SetCustomFlag               ( DWORD f ) { customflags |=  f;        }
01205         BMMExport void           ResetCustomFlag             ( DWORD f ) { customflags &= ~f;        }
01212         BMMExport BOOL           TestCustomFlags             ( DWORD f ) { return (customflags & f); }
01213 
01214         //-- Plug-In Parameter Block
01215 
01216         BMMExport void*         GetPiData                   ( ) { return pidata;          }
01217         BMMExport void          SetPiData                   ( void *ptr ) { pidata = ptr; }
01218         BMMExport DWORD         GetPiDataSize               ( ) { return pisize;          }
01219         BMMExport void          SetPiDataSize               ( DWORD s ) { pisize = s;     }
01220         BMMExport void          ResetPiData                 ( );
01221         BMMExport BOOL          AllocPiData                 ( DWORD size );
01222 
01223         //-- Proxy Subject info
01224 
01232 
01233         BMMExport BitmapInfo*   GetProxySubject             ( BOOL create=FALSE );
01234         BMMExport void          ResetProxySubject           ( ); 
01235         BMMExport BOOL          AllocProxySubject           ( ); 
01236 
01237 
01238         //-- Used to create Format Specific Parameter Block. Name and/or Device must be defined before using it.
01239 
01260         BMMExport void*         CreateFmtSpecBlock          ( void );
01261 
01263         BMMExport void          Copy                        ( const BitmapInfo *from, BOOL copyProxySubject );
01264         BMMExport void          Copy                        ( const BitmapInfo *from ); //\\-- OBSOLETE --\\//
01270         BMMExport BitmapInfo    &operator=                  ( const BitmapInfo &from );
01271 
01272         //-- Load/Save
01273 
01274         BMMExport IOResult       Save                        ( ISave *isave );
01275         BMMExport IOResult       Load                        ( ILoad *iload );
01276 
01277         BMMExport void           EnumAuxFiles                ( AssetEnumCallback& assetEnum, DWORD flags);
01278           
01279         //-- Miscelaneous
01280 
01298         BMMExport BOOL           Validate                    ( );
01301         BMMExport HWND           GetUpdateWindow             ( )           { return hWnd; }
01305         BMMExport void           SetUpdateWindow             ( HWND hwnd ) { hWnd = hwnd; }
01306         BMMExport DWORD          GetGChannels                ( );
01307         BMMExport DWORD          GetDeviceFlags              ( );
01308         BMMExport BOOL           FixDeviceName               ( ); 
01309 
01310 };
01311 
01312 //-----------------------------------------------------------------------------
01313 //-- Bitmap I/O Class
01314 //
01315 //   None of these methods are to be used directly. Use the BitmapManager for
01316 //   any image I/O.
01317 //
01318 
01319 
01360 #pragma warning(push)
01361 #pragma warning(disable:4100)
01362 class BitmapIO : public BaseInterfaceServer {
01363     private:
01364       UWORD* outputGammaTab;   // this may be owned by gammaMgr
01365       UWORD* privGammaTab;     // private gamma table owned by the BitmapIO.
01366            
01367    protected:
01368       float                   gamma;     
01369       Bitmap                  *map;                        // The bitmap using this OUTPUT handler
01370       BitmapStorage           *storage;                    // The storage used by this INPUT handler
01371 
01372       int                      openMode;                   // See above
01373       
01374       //-- Linked list pointers for multiple output of a single bitmap
01375 
01376       BitmapIO                *prevIO;                     
01377       BitmapIO                *nextIO;
01378 
01379    public:
01380 
01381       // Used by the subclassed BitmapIO's to get pixels for output with
01382       // the appropriate output gamma correction.
01401       BMMExport  int           GetOutputPixels          ( int x,int y,int pixels,BMM_Color_64  *ptr, BOOL preMultAlpha=TRUE);
01402       
01403       // Used by the subclassed BitmapIO's to get pixels for output with
01404       // the appropriate output gamma correction.
01405       BMMExport  int           GetOutputPixels          ( int x,int y,int pixels,BMM_Color_fl  *ptr, BOOL preMultAlpha=TRUE);
01406       
01407       // Used by the subclassed BitmapIO's to get 32 bit pixels for output with
01408       // the appropriate output gamma correction and dither. 
01428       BMMExport  int           GetDitheredOutputPixels  ( int x,int y,int pixels,BMM_Color_32  *ptr, BOOL preMultAlpha=TRUE);
01429 
01430       // Used by the subclassed BitmapIO's to get a DIB  for output with
01431       // the appropriate output gamma correction. 
01438       BMMExport  PBITMAPINFO   GetOutputDib             ( int depth = 24   );
01439 
01440       // Used by the subclassed BitmapIO's to get a DIB  for output with
01441       // the appropriate output gamma correction and dither
01448       BMMExport  PBITMAPINFO   GetDitheredOutputDib      ( int depth = 24   );
01449 
01452       BMMExport  float         OutputGamma();
01453 
01454       // If a BitmapIO wants to do its own dithering, it should call
01455       // these to find out if dithering is wanted.  If it is a 24 bit or
01456       // 32 bit format, it would usually just call GetDitheredOutputPixels instead.
01463       BMMExport  BOOL          DitherTrueColor();
01468       BMMExport  BOOL          DitherPaletted();
01469 
01470       // Calculate a color palette for output color packing: gamma corrects
01481       BMMExport  int           CalcOutputPalette(int palsize, BMM_Color_48 *pal);
01482    
01483       BMMExport                BitmapIO                    ( );
01484       BMMExport virtual                ~BitmapIO                    ( );
01485       
01486       BitmapInfo               bi;
01487    
01491       inline    int            OpenMode                    ( ) { return (openMode); }
01494       inline    void           SetPrev                     ( BitmapIO *prev) { prevIO = prev; };
01497       inline    void           SetNext                     ( BitmapIO *next) { nextIO = next; };
01500       inline    BitmapIO      *Prev                        ( ) { return prevIO; };
01503       inline    BitmapIO      *Next                        ( ) { return nextIO; };
01504       
01507       BMMExport BitmapStorage *Storage                     ( );
01510       inline    Bitmap        *Map                         ( ) { return map; };
01511 
01515       BMMExport virtual  int            ExtCount                    ( ) = 0;                                // Number of extemsions supported
01521       BMMExport virtual  const MCHAR   *Ext                         ( int n ) = 0;                          // Extension #n (i.e. "3DS")
01524       BMMExport virtual  const MCHAR   *LongDesc                    ( ) = 0;                                // Long ASCII description (i.e. "Targa 2.0 Image File")
01526       BMMExport virtual  const MCHAR   *ShortDesc                   ( ) = 0;                                // Short ASCII description (i.e. "Targa")
01528       BMMExport virtual  const MCHAR   *AuthorName                  ( ) = 0;                                // ASCII Author name
01530       BMMExport virtual  const MCHAR   *CopyrightMessage            ( ) = 0;                                // ASCII Copyright message
01532       BMMExport virtual  UINT           Version                     ( ) = 0;                                // Version number * 100 (i.e. v3.01 = 301)
01533       
01538       BMMExport virtual  int            Capability                  ( ) = 0;                                // Returns IO module ability flags (see above)
01545       BMMExport virtual  void           ShowAbout                   ( HWND hWnd ) = 0;                      // Show DLL's "About..." box
01546 
01547       //-- If the BMMIO_OWN_VIEWER flag is set, this method will be called
01548       //   whenever the user wants to view an image for this device. This
01549       //   is for devices which can "play" image sequences such as AVI's, FLIC's, etc.
01550       //-- TH 2/26/96 -- Added BOOL return to indicate if view worked.  If it didn't,
01551       //   it returns FALSE and the caller can view by the normal mechanism.
01552 
01565       BMMExport virtual  BOOL           ShowImage                   ( HWND hWnd, BitmapInfo *bi ) { return FALSE; }
01566 
01567       //-- Show DLL's Control Panel
01568       //
01569       //   If the user exists through an Ok, this function will return TRUE.
01570       //   If the user cancels out, it will return FALSE. False indicates
01571       //   nothing has changed so the system won't bother asking the plug-in
01572       //   if it wants to save data.
01573       //
01574       //   This function is only called if the plug-in has defined it supports
01575       //   it (through the Capability  flag above).  The flag will indicate to
01576       //   the plug-in what operation is this control for (read, write, or
01577       //   generic).
01578       //
01579       
01596       BMMExport virtual  BOOL           ShowControl                 ( HWND hWnd, DWORD flag ) { return FALSE; }
01597       
01598       //-- Parameter Block Load and Save ------------------------------------
01599       //
01600       //  The host will call EvaluateConfigure() to determine the buffer size
01601       //  required by the plug-in.
01602       //
01603       //  SaveConfigure() will be called so the plug-in can transfer its
01604       //  parameter block to the host ( ptr is a pre-allocated buffer).
01605       //
01606       //  LoadConfigure() will be called so the plug-in can load its 
01607       //  parameter block back.
01608       //  
01609       //  Memory management is performed by the host using standard
01610       //  LocalAlloc() and LocalFree().
01611       //  
01612       
01617       BMMExport virtual  DWORD          EvaluateConfigure           ( ) = 0;
01625       BMMExport virtual  BOOL           LoadConfigure               ( void *ptr ) = 0;
01633       BMMExport virtual  BOOL           SaveConfigure               ( void *ptr ) = 0;
01634 
01635       //  Cfg methods provide access to the plug-in's default options, as saved in its .cfg file
01636       //  ReadCfg() loads the default options into the parameter block
01637       //  WriteCfg() saves the parameter block as the defaults
01638 
01641       BMMExport virtual  void           GetCfgFilename              ( MCHAR *filename ) {}
01644       BMMExport virtual  BOOL           ReadCfg                     ( ) { return TRUE; }
01646       BMMExport virtual  void           WriteCfg                    ( ) {}
01647 
01648 
01649       //-- Used internaly to make sure current block belongs to Plug-In
01650       
01651       BMMExport virtual  BOOL           ValidatePiData              ( BitmapInfo *bi );
01652 
01653       //-- System Interface
01654       
01658       BMMExport BOOL           SilentMode                  ( );
01659 
01660 
01661       //-- Calculate Desired Frame
01662       //
01663       //   This is for multiframe sequences. It processes the desired frame
01664       //   based on user options. It is used at the Load() function to find
01665       //   out which frame to load.
01666       //
01667       //   "fbi"    is the one passed to Load()
01668       //   "frame"  is a pointer to an integer to receive the frame number
01669       
01686       BMMExport BMMRES         GetFrame                    ( BitmapInfo *fbi, int *frame);
01687       
01688       //-- Critical Error Handling
01689       
01716       BMMExport BMMRES         ProcessImageIOError         ( BitmapInfo *bi, MCHAR *string = NULL);
01765       BMMExport BMMRES         ProcessImageIOError         ( BitmapInfo *bi, int errorcode);
01766       
01767       //---------------------------------------------------------------------
01768       //-- Channels Required (for Output)
01769       //
01770       //   By setting this flag, the plug-in can request the host to generate
01771       //   the given channels. Prior to Rendering, the host will scan the
01772       //   plug-ins in the chain of events and list all types of channels
01773       //   being requested. The plug-in, at the time of the Write() call, will
01774       //   have access to these channels through the channel interface
01775       //   described below in BitmapStorage().
01776       //
01777       //   The generation of these channels should not, normally, be a 
01778       //   default setting for a plug-in. These channels are memory hungry and
01779       //   if the plug-in won't use it, it should not ask for it. Normally
01780       //   the plug-in would ask the user which channels to save and set only
01781       //   the proper flags.
01782       //
01783       
01793       BMMExport virtual  DWORD          ChannelsRequired            ( ) { return BMM_CHAN_NONE; }
01794       
01795       //-- Image Info
01796       
01813       BMMExport virtual  BMMRES         GetImageInfoDlg             ( HWND hWnd, BitmapInfo *bi, const MCHAR *filename = NULL ) {return BMMRES_NODRIVER;}
01837               BMMExport virtual  BMMRES         GetImageInfo                (            BitmapInfo *bi ) = 0;
01838       
01839       //-- Image File Loaders (IFL handlers)
01840       
01851       BMMExport virtual  BMMRES         GetImageName                ( BitmapInfo *bi, MCHAR *filename) {filename[0]=0; return (BMMRES_SUCCESS);}
01852 
01853       //-- Image I/O (Not to use directly)
01854       
01872       BMMExport virtual  BitmapStorage *Load                        ( BitmapInfo *bi, Bitmap *map, BMMRES *status ) = 0;      
01886       BMMExport virtual  BMMRES         OpenOutput                  ( BitmapInfo *bi, Bitmap *map );
01897       BMMExport virtual  BMMRES         Write                       ( int frame );
01907       BMMExport virtual  int            Close                       ( int flag );
01912       BMMExport virtual  PAVIFILE       GetPaviFile                 ( ) { return NULL; }
01913 
01914       // used internally to build output gamma table
01915 
01918       BMMExport void            InitOutputGammaTable(BitmapInfo*bi);
01919 
01920       //-- Evaluate Matching Frame (R2)
01921 
01961       BMMExport virtual  void           EvalMatch                   ( MCHAR *matchString ) { matchString[0] = 0; }
01962 
01963 
01964 
01965 
01966 };
01967 
01968 #pragma warning(pop)
01969 //-----------------------------------------------------------------------------
01970 //-- Bitmap Storage Class
01971 //
01972 //   None of these methods are to be used directly. Use the Bitmap class for
01973 //   any image read/write.
01974 //
01975 
01976 //-- Channel Operations (for Get/Put16Channel)
01977 
01978 #define BMM_CHANNEL_RED          0    //-- Get/Put only Red
01979 #define BMM_CHANNEL_GREEN        1    //-- Get/Put only Green
01980 #define BMM_CHANNEL_BLUE         3    //-- Get/Put only Blue
01981 #define BMM_CHANNEL_ALPHA        4    //-- Get/Put only Alpha
01982 #define BMM_CHANNEL_Z            5    //-- Get/Put only Z
01983 #define BMM_CHANNEL_LUMINANCE    6    //-- Get (R+G+B)/3
01984 
02003 class BitmapStorage : public BaseInterfaceServer {
02004 
02005    friend class GcsBitmap; // Used in VIZ only
02006 
02007    protected:
02008    
02009       int                      openMode;                   // See above
02010       UINT                     usageCount;                 // Number of Bitmaps using this storage
02011       BitmapManager           *manager;
02012 
02013       int                      flags;
02014       int                      type;                       // See "Basic bitmap types", below
02015 
02016       BMM_Color_48             palette[256];               // 256 palette entries max
02017       int                      paletteSlots;
02018       UWORD                    *gammaTable;               // Gamma correction table
02019       
02020       RenderInfo               *rendInfo;
02021       GBuffer                  *gbuffer;
02022    public:
02023 
02024       BMMExport                BitmapStorage               ( );
02025       BMMExport virtual        ~BitmapStorage               ( );
02026 
02027       BitmapInfo               bi;
02028        MCHAR*                   evalString;
02029 
02030       // gamma 
02036       BMMExport   float        SetGamma(float gam);         
02039       inline      int          HasGamma                    ( ) { return (gammaTable!=NULL)          ? 1:0; };
02045       BMMExport   void         SetHasGamma(BOOL onOff);   
02046       void               UpdateGammaTable(); 
02054       BMMExport   UWORD       *GetInputGammaTable();
02055 
02058       inline  BitmapManager   *Manager                     ( ) { return manager;     }
02062       inline  int              OpenMode                    ( ) { return openMode;    }
02066       inline  int              Width                       ( ) { return bi.Width();  }
02070       inline  int              Height                      ( ) { return bi.Height(); }
02074       inline  float            Aspect                      ( ) { return bi.Aspect(); }
02078       inline  float            Gamma                       ( ) { return bi.Gamma();  }
02079       
02083       inline  int              Paletted                    ( ) { return (flags & MAP_PALETTED)            ? paletteSlots:0; }
02087       inline  int              IsDithered                  ( ) { return (flags & MAP_DITHERED)            ? 1:0; };
02091       inline  int              PreMultipliedAlpha          ( ) { return (flags & MAP_ALPHA_PREMULTIPLIED) ? 1:0; };
02095       inline  int              HasAlpha                    ( ) { return (flags & MAP_HAS_ALPHA)           ? 1:0; };
02099       inline  void             UseScaleColors              ( int on ) { flags &= ~MAP_USE_SCALE_COLORS; if (on) flags |= MAP_USE_SCALE_COLORS; };
02102       inline  int              ScaleColors                 ( ) { return (flags & MAP_USE_SCALE_COLORS)    ? 1:0; };
02111       inline  static void      ClampColor                  (BMM_Color_64& out, const BMM_Color_fl& in) { out.r = in.clipColor(in.r); out.g = in.clipColor(in.g); out.b = in.clipColor(in.b); }
02119       inline  static void      ClampColorA                 (BMM_Color_64& out, const BMM_Color_fl& in) { ClampColor(out, in); out.a = in.clipColor(in.a); }
02128       BMMExport static void    ScaleColor                  (BMM_Color_64& out, BMM_Color_fl in);
02136       inline static void       ScaleColorA                 (BMM_Color_64& out, const BMM_Color_fl& in) { ScaleColor(out, in); out.a = in.clipColor(in.a); }
02145       inline  void             ClampScaleColor             (BMM_Color_64& out, const BMM_Color_fl& in) { if (ScaleColors()) ScaleColor(out, in); else ClampColor(out, in); }
02154       inline  void             ClampScaleColorA            (BMM_Color_64& out, const BMM_Color_fl& in) { if (ScaleColors()) ScaleColorA(out, in); else ClampColorA(out, in); }
02155       
02158       inline  int              UsageCount                  ( ) { return usageCount; };
02161       inline  int              Type                        ( ) { return type; };
02164       inline  int              Flags                       ( ) { return flags; };
02170       inline  void             SetFlags                    ( DWORD f ) { flags |=  f; }
02171       inline  void             ClearFlags                  ( DWORD f ) { flags &= (~f); } 
02172 
02176       BMMExport virtual int             MaxRGBLevel                 ( ) = 0;
02179       BMMExport virtual int             MaxAlphaLevel               ( ) = 0;
02184       BMMExport virtual int             IsHighDynamicRange          ( ) = 0;
02185       
02195       BMMExport virtual void           *GetStoragePtr               ( int *type ) { *type = BMM_NO_TYPE; return (NULL); }
02209       BMMExport virtual void           *GetAlphaPtr                 ( int *type ) { *type = BMM_NO_TYPE; return (NULL); }
02210 
02211       //-- Scaling Tools
02212 
02213       BMMExport virtual void           Scale                       ( WORD *, int, WORD *, int );
02216       BMMExport virtual void           Scale                       ( float *, int, float *, int );
02217       BMMExport virtual BOOL           GetSRow                     ( WORD *, int, WORD *, int );
02220       BMMExport virtual BOOL           GetSRow                     ( float *, int, float *, int );
02221       BMMExport virtual BOOL           PutSRow                     ( WORD *, int, WORD *, int );
02224       BMMExport virtual BOOL           PutSRow                     ( float *, int, float *, int );
02225       BMMExport virtual BOOL           GetSCol                     ( WORD *, WORD *, int, int );
02228       BMMExport virtual BOOL           GetSCol                     ( float *, float *, int, int );
02229       BMMExport virtual BOOL           PutSCol                     ( WORD *, WORD *, int, int );
02232       BMMExport virtual BOOL           PutSCol                     ( float *, float *, int, int );
02233       BMMExport virtual BOOL           ScaleY                      ( Bitmap *, BMM_Color_64 *, WORD *, WORD *, HWND, int cw = 0, int ch = 0 );
02236       BMMExport virtual BOOL           ScaleY                      ( Bitmap *, BMM_Color_fl *, float *, float *, HWND, int cw = 0, int ch = 0 );
02237       BMMExport virtual BOOL           ScaleX                      ( Bitmap *, BMM_Color_64 *, WORD *, WORD *, HWND, int cw = 0, int ch = 0 );
02240       BMMExport virtual BOOL           ScaleX                      ( Bitmap *, BMM_Color_fl *, float *, float *, HWND, int cw = 0, int ch = 0 );
02241       BMMExport virtual int            StraightCopy                 ( Bitmap *from ) = 0;
02242 
02243       //-- These are the standard methods for accessing image pixels
02244       
02258       BMMExport virtual int             Get16Gray                   ( int x,int y,int pixels,WORD  *ptr) = 0;
02273       BMMExport virtual int             Put16Gray                   ( int x,int y,int pixels,WORD  *ptr) = 0;
02287       BMMExport virtual int             Get16Gray                   ( int x,int y,int pixels,float *ptr) = 0;
02302       BMMExport virtual int             Put16Gray                   ( int x,int y,int pixels,float *ptr) = 0;
02317       BMMExport virtual int             GetLinearPixels             ( int x,int y,int pixels,BMM_Color_64  *ptr) = 0;
02333       BMMExport virtual int             GetPixels                   ( int x,int y,int pixels,BMM_Color_64  *ptr) = 0;
02350       BMMExport virtual int             PutPixels                   ( int x,int y,int pixels,BMM_Color_64  *ptr) = 0;
02365       BMMExport virtual int             GetLinearPixels             ( int x,int y,int pixels,BMM_Color_fl  *ptr) = 0;
02380       BMMExport virtual int             GetPixels                   ( int x,int y,int pixels,BMM_Color_fl  *ptr) = 0;
02396       BMMExport virtual int             PutPixels                   ( int x,int y,int pixels,BMM_Color_fl  *ptr) = 0;
02411       BMMExport virtual int             GetIndexPixels              ( int x,int y,int pixels,unsigned char *ptr) = 0;
02425       BMMExport virtual int             PutIndexPixels              ( int x,int y,int pixels,unsigned char *ptr) = 0;
02426       
02427       BMMExport virtual int             Fill                        (const BMM_Color_fl& fillColor);
02428       BMMExport virtual int             Fill                        (const BMM_Color_64& fillColor);
02429 
02443       BMMExport virtual int             CropImage                   ( int width,int height,BMM_Color_64 fillcolor) = 0;
02457       BMMExport virtual int             CropImage                   ( int width,int height,BMM_Color_fl fillcolor) = 0;
02470       BMMExport virtual int             CropImage                   ( int width,int height,int fillindex)  = 0;
02472       BMMExport virtual int             ResizeImage                 ( int width,int height,int newpalette) = 0;
02473 
02482       BMMExport virtual int             CopyCrop                    ( Bitmap *from, BMM_Color_64 fillcolor ) = 0;
02491       BMMExport virtual int             CopyCrop                    ( Bitmap *from, BMM_Color_fl fillcolor ) = 0;
02503       BMMExport virtual int             CopyScaleLow                ( Bitmap *from ) = 0;
02511       BMMExport virtual int             CopyScaleHigh               ( Bitmap *from, HWND hWnd, BMM_Color_64 **buf = NULL, int w=0, int h=0 ) = 0;
02519       BMMExport virtual int             CopyScaleHigh               ( Bitmap *from, HWND hWnd, BMM_Color_fl **buf = NULL, int w=0, int h=0 ) = 0;
02520 
02547       BMMExport virtual int             CopyImage                   ( Bitmap *from,int operation,BMM_Color_64 fillcolor, BitmapInfo *bi = NULL) = 0;
02574       BMMExport virtual int             CopyImage                   ( Bitmap *from,int operation,BMM_Color_fl fillcolor, BitmapInfo *bi = NULL) = 0;
02594       BMMExport virtual int             CopyImage                   ( Bitmap *from,int operation,int fillindex) = 0;
02605       BMMExport virtual int             GetPalette                  ( int start,int count,BMM_Color_48 *ptr) = 0;
02618       BMMExport virtual int             SetPalette                  ( int start,int count,BMM_Color_48 *ptr) = 0;
02631       BMMExport virtual int             GetFiltered                 ( float u,float v,float du,float dv,BMM_Color_64 *ptr) = 0;
02644       BMMExport virtual int             GetFiltered                 ( float u,float v,float du,float dv,BMM_Color_fl *ptr) = 0;
02645       
02646       //-- User Interface
02647       
02659       BMMExport virtual int             Allocate                    ( BitmapInfo *bi,BitmapManager *manager,int openMode)  = 0;
02660       BMMExport virtual int             Connect                     ( ) = 0;
02661       BMMExport virtual int             Disconnect                  ( ) = 0;
02662       BMMExport virtual int             MapReady                    ( ) = 0;
02663       BMMExport virtual int             ClosestColor                ( BMM_Color_48 color);
02664       BMMExport virtual int             ClosestColor                ( int r,int g,int b);
02665 
02666       // GBuffer methods ----------------------
02667       // get a pointer to specified channel: also determine its type for check
02693       BMMExport virtual void*    GetChannel(ULONG channelID, ULONG& chanType) { return gbuffer?gbuffer->GetChannel(channelID, chanType):NULL;}
02694 
02697       GBuffer *GetGBuffer()  { return gbuffer; } 
02698 
02699       // create the specified channels -- return channels present: (creates GBuffer if non-existent); 
02707       BMMExport virtual ULONG    CreateChannels(ULONG channelIDs);
02708       
02709       // delete all the channels in channelIDs
02714       BMMExport virtual void     DeleteChannels(ULONG channelIDs) { if (gbuffer) gbuffer->DeleteChannels(channelIDs); }  
02715 
02716       // query which channels are present
02720       BMMExport virtual ULONG     ChannelsPresent() { return gbuffer?gbuffer->ChannelsPresent():0;  }
02721 
02722 
02723       // For output bitmaps, can get RenderInfo, which is written by the
02724       // renderer
02725       // AllocRenderInfo will alloc only if RenderInfo doesn't yet exist.
02731       BMMExport RenderInfo* AllocRenderInfo(); 
02732       // GetRenderInfo just hands back RenderInfo pointer
02735       BMMExport RenderInfo* GetRenderInfo();
02736 
02737 };
02738 
02739 //-----------------------------------------------------------------------------
02740 //-- Low Dynamic Range Bitmap Storage Class
02741 //
02742 //   None of these methods are to be used directly. Use the Bitmap class for
02743 //   any image read/write.
02744 //
02745 
02754 class BitmapStorageLDR : public BitmapStorage {
02755    public:
02756 
02757       using BitmapStorage::Get16Gray;
02758       using BitmapStorage::Put16Gray;
02759       using BitmapStorage::GetLinearPixels;
02760       using BitmapStorage::GetPixels;
02761       using BitmapStorage::PutPixels;
02762       
02763       using BitmapStorage::CropImage;
02764       using BitmapStorage::ResizeImage;
02765 
02766       using BitmapStorage::CopyCrop;
02767       using BitmapStorage::CopyScaleLow;
02768 
02769       using BitmapStorage::CopyImage;
02770       using BitmapStorage::GetFiltered;
02771 
02777       BMMExport virtual int             IsHighDynamicRange          ( ) { return 0; }
02778 
02779       //-- Scaling Tools
02780 
02786       BMMExport virtual int            StraightCopy                 ( Bitmap *from );
02787 
02788       //-- These are the standard methods for accessing image pixels
02789       
02803       BMMExport virtual int             Get16Gray                   ( int x,int y,int pixels,float *ptr);
02818       BMMExport virtual int             Put16Gray                   ( int x,int y,int pixels,float *ptr);
02833       BMMExport virtual int             GetLinearPixels             ( int x,int y,int pixels,BMM_Color_fl  *ptr);
02848       BMMExport virtual int             GetPixels                   ( int x,int y,int pixels,BMM_Color_fl  *ptr);
02864       BMMExport virtual int             PutPixels                   ( int x,int y,int pixels,BMM_Color_fl  *ptr);
02879       BMMExport virtual int             GetIndexPixels              ( int x,int y,int pixels,unsigned char *ptr) = 0;
02893       BMMExport virtual int             PutIndexPixels              ( int x,int y,int pixels,unsigned char *ptr) = 0;
02894       
02907       BMMExport virtual int             CropImage                   ( int width,int height,BMM_Color_fl fillcolor);
02908 
02917       BMMExport virtual int             CopyCrop                    ( Bitmap *from, BMM_Color_64 fillcolor );
02926       BMMExport virtual int             CopyCrop                    ( Bitmap *from, BMM_Color_fl fillcolor );
02938       BMMExport virtual int             CopyScaleLow                ( Bitmap *from );
02946       BMMExport virtual int             CopyScaleHigh               ( Bitmap *from, HWND hWnd, BMM_Color_64 **buf = NULL, int w=0, int h=0 );
02954       BMMExport virtual int             CopyScaleHigh               ( Bitmap *from, HWND hWnd, BMM_Color_fl **buf = NULL, int w=0, int h=0 );
02955 
02981       BMMExport virtual int             CopyImage                   ( Bitmap *from,int operation,BMM_Color_64 fillcolor, BitmapInfo *bi = NULL);
03007       BMMExport virtual int             CopyImage                   ( Bitmap *from,int operation,BMM_Color_fl fillcolor, BitmapInfo *bi = NULL);
03027       BMMExport virtual int             CopyImage                   ( Bitmap *from,int operation,int fillindex);
03039       BMMExport virtual int             GetFiltered                 ( float u,float v,float du,float dv,BMM_Color_fl *ptr);
03040       
03041 };
03042 
03043 //-----------------------------------------------------------------------------
03044 //-- High Dynamic Range Bitmap Storage Class
03045 //
03046 //   None of these methods are to be used directly. Use the Bitmap class for
03047 //   any image read/write.
03048 //
03049 
03056 class BitmapStorageHDR : public BitmapStorage {
03057    public:
03058 
03059       using BitmapStorage::Get16Gray;
03060       using BitmapStorage::Put16Gray;
03061       using BitmapStorage::GetLinearPixels;
03062       using BitmapStorage::GetPixels;
03063       using BitmapStorage::PutPixels;
03064       
03065       using BitmapStorage::CropImage;
03066       using BitmapStorage::ResizeImage;
03067 
03068       using BitmapStorage::CopyCrop;
03069       using BitmapStorage::CopyScaleLow;
03070       using BitmapStorage::CopyScaleHigh;
03071 
03072       using BitmapStorage::CopyImage;
03073       using BitmapStorage::GetFiltered;
03074 
03080       BMMExport virtual int             IsHighDynamicRange          ( ) { return 1; }
03081 
03082       //-- Scaling Tools
03083 
03089       BMMExport virtual int            StraightCopy                 ( Bitmap *from );
03090 
03091       //-- These are the standard methods for accessing image pixels
03092       
03106       BMMExport virtual int             Get16Gray                   ( int x,int y,int pixels,WORD  *ptr);
03121       BMMExport virtual int             Put16Gray                   ( int x,int y,int pixels,WORD  *ptr);
03136       BMMExport virtual int             GetLinearPixels             ( int x,int y,int pixels,BMM_Color_64  *ptr);
03147       BMMExport virtual int             GetPixels                   ( int x,int y,int pixels,BMM_Color_64  *ptr);
03163       BMMExport virtual int             PutPixels                   ( int x,int y,int pixels,BMM_Color_64  *ptr);
03164       
03177       BMMExport virtual int             CropImage                   ( int width,int height,BMM_Color_64 fillcolor);
03190       BMMExport virtual int             CropImage                   ( int width,int height,int fillindex);
03191 
03200       BMMExport virtual int             CopyCrop                    ( Bitmap *from, BMM_Color_64 fillcolor );
03209       BMMExport virtual int             CopyCrop                    ( Bitmap *from, BMM_Color_fl fillcolor );
03221       BMMExport virtual int             CopyScaleLow                ( Bitmap *from );
03229       BMMExport virtual int             CopyScaleHigh               ( Bitmap *from, HWND hWnd, BMM_Color_64 **buf = NULL, int w=0, int h=0 );
03237       BMMExport virtual int             CopyScaleHigh               ( Bitmap *from, HWND hWnd, BMM_Color_fl **buf = NULL, int w=0, int h=0 );
03238 
03264       BMMExport virtual int             CopyImage                   ( Bitmap *from,int operation,BMM_Color_64 fillcolor, BitmapInfo *bi = NULL);
03289       BMMExport virtual int             CopyImage                   ( Bitmap *from,int operation,BMM_Color_fl fillcolor, BitmapInfo *bi = NULL);
03309       BMMExport virtual int             CopyImage                   ( Bitmap *from,int operation,int fillindex);
03322       BMMExport virtual int             GetFiltered                 ( float u,float v,float du,float dv,BMM_Color_64 *ptr);
03323       
03324 };
03325 
03326 //-----------------------------------------------------------------------------
03327 //-- Bitmap Filter Class
03328 //
03329 //   Private class not to be documented
03330 //
03331 
03332 class BitmapFilter: public MaxHeapOperators {
03333    
03334    protected:
03335    
03336       UINT                     usageCount;                 // Number of Bitmaps using this storage
03337       BitmapManager           *manager;                    // Pointer to bitmap manager
03338       BitmapStorage           *storage;                    // Pointer to storage itself
03339       DWORD                    flags;                      // Filter flags
03340       int                      dirty;                      // Needs updating flag
03341       UINT                     type;                       // Type index of filter
03342       
03343    public:
03344    
03345       BMMExport                BitmapFilter();
03346       BMMExport virtual                ~BitmapFilter();
03347       
03348       inline    DWORD          Flags                       ( ) { return flags; };
03349       inline    void           SetFlag                     ( DWORD flag) { flags |= flag; dirty = 1; };
03350       inline    void           ToggleFlag                  ( DWORD flag) { flags ^= flag; dirty = 1; };
03351       inline    void           ClearFlag                   ( DWORD flag) { flags &= (~flag); dirty = 1; };
03352       inline    UINT           Type                        ( ) { return type; };
03353       inline    void           SetType                     ( UINT t) { type = t; };
03354       BMMExport int            Initialize                  ( BitmapManager *m,BitmapStorage *s);
03355 
03356       virtual   int            GetFiltered                 ( float u,float v,float du,float dv,BMM_Color_64 *ptr) = 0;
03357       virtual   int            GetFiltered                 ( float u,float v,float du,float dv,BMM_Color_fl *ptr) = 0;
03358       virtual   void           Free                        ( ) {};
03359 
03360       BMMExport int            Connect                     ( );
03361       BMMExport int            Disconnect                  ( );
03362       BMMExport int            SetStorage                  ( BitmapStorage *storage);
03363       inline  BitmapStorage   *GetStorage                  ( ) { return storage; };
03364       inline    void           MakeDirty                   ( ) { dirty = 1; };
03365 
03366 };
03367 
03368 //-----------------------------------------------------------------------------
03369 //-- Bitmap Dither Class
03370 //
03371 //   Private class not to be documented
03372 
03373 class BitmapDither: public MaxHeapOperators {
03374    
03375    protected:
03376    
03377       BitmapStorage           *storage;                    // Pointer to storage itself
03378       int                      type;                       // Type index of filter
03379       
03380    public:
03381     
03382       BMMExport                BitmapDither                ( );
03383       BMMExport virtual                ~BitmapDither                ( );
03384       inline    UINT           Type                        ( ) { return type; };
03385       inline    void           SetType                     ( UINT t) { type = t; };
03386       BMMExport int            Initialize                  ( BitmapStorage *s);
03387       virtual   int            PutPixels                 ( int x,int y,int pixels,BMM_Color_64 *ptr) = 0;
03388       virtual   int            PutPixels                 ( int x,int y,int pixels,BMM_Color_fl *ptr) = 0;
03389       virtual   void           Free                        ( ) {};
03390       BMMExport int            SetStorage                  ( BitmapStorage *storage);
03391     
03392 };
03393 
03394 
03395 //-----------------------------------------------------------------------------
03396 // Callback for notifying bitmaps that their Storage has changed, and 
03397 // any on screen displays need to be refreshed.  Installed via
03398 // Bitmap::SetNotify();
03399 // VFBClosed is 
03400 //
03401 
03402 //-- New flag handling. The "flag" parameter was unused in relrease < 5.
03403 // GG: 02/10/02
03404 
03405 //-- Notifies the storage has changed (the contents of the bitmap). You should
03406 // update to reflect the changes.
03407 #define BMNOTIFY_FLAG_STORAGE_CHANGE    0
03408 //-- Notifies the file has changed (probably by an external program). You
03409 // should reload the bitmap. Note that by the time this call is made, the API has
03410 // already checked to see if the user has set the global preferences asking for
03411 // these changes to be automatically reloaded.
03412 #define BMNOTIFY_FLAG_FILE_CHANGE       1
03413 
03421 class BitmapNotify: public MaxHeapOperators{
03422 public:
03423     //-- Call to notify clients the bitmap has changed.
03424     //-- flags can be one of the BMNOTIFY_FLAG_XXX flags above
03437     virtual int Changed(ULONG flags)=0;
03441     virtual void VFBClosed() {}  // called when VFB is closed
03442     };
03443 
03444 //-----------------------------------------------------------------------------
03445 // Callback for interactive adjustment of bitmap "Cropping rectangle", passed
03446 // in as an argument to Bitmap::Display.
03454 class CropCallback: public MaxHeapOperators {
03455     public:
03457     virtual float GetInitU()=0;
03459     virtual float GetInitV()=0;
03461     virtual float GetInitW()=0;
03463     virtual float GetInitH()=0;
03467     virtual BOOL GetInitMode()=0;
03482     virtual void SetValues(float u, float v, float w, float h, BOOL md)=0;
03485     virtual void OnClose()=0;
03486     };
03487     
03488 //-----------------------------------------------------------------------------
03489 //-- Basic Bitmap Class
03490 //
03491 //
03492    
03493 #define BMM_SINGLEFRAME -2000000L
03494 
03521 class Bitmap : public BaseInterfaceServer
03522 {
03523    friend class BitmapManagerImp;
03524       
03525    private:
03526    
03527       DWORD                    flags;                      // See above
03528 
03529       BitmapManager            *manager;                   // Manager of this bitmap
03530       BitmapIO                 *output;                    // Head of output handler list
03531       BitmapFilter             *filter;                    // Filtered access methods
03532       BitmapDither             *dither;                    // Dither methods
03533       BitmapStorage            *storage;                   // Actual storage
03534       UINT                     filterType;                 // Filtered access type
03535       UINT                     ditherType;                 // Dither type
03536       DWORD                    modifyID;                   // changes when bitmap changes: used in render effects
03537       int                      Free();
03538 
03539       void                     *vfbData;    
03540 
03541       BitmapNotify *bmNotify;       // Called when storage is change so display can update
03542 
03543       friend LRESULT CALLBACK  InputWndProc                ( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
03544 
03545       // To delete a Bitmap, call Bitmap::DeleteThis()
03546       BMMExport               ~Bitmap                      ( );
03547 
03548       // To get a new Bitmap, call BitmapManager::NewBitmap()
03549       BMMExport                Bitmap                      ( BitmapManager *manager = TheManager );
03550      
03551    public:
03552 
03554       inline  BitmapManager   *Manager                     ( ) { return manager; };
03555 
03556       //-- Don't use these unless you know what you're doing ----------------
03557       
03558       BMMExport int            Create                      ( BitmapInfo *bi );
03559       BMMExport BOOL           FixDeviceName               ( BitmapInfo *bi );
03560       inline    int            MapReady                    ( ) { if (storage) return storage->MapReady(); return 0; };
03561       BMMExport void           AddOutput                   ( BitmapIO *out  );
03562       BMMExport void           RemoveOutput                ( BitmapIO *out, BOOL deleteOutput=TRUE  );
03563       BMMExport BitmapIO *     FindOutput                  ( BitmapInfo *bi );
03564       BMMExport PAVIFILE       GetPaviFile                 ( BitmapInfo *bi );
03565 
03566 
03567       inline  void             *GetVFBData                 ( )  { return vfbData; }
03568       inline  void              SetVFBData                 (void *vfb ) { vfbData = vfb; }
03569 
03570       
03571       //-- Public Interface -------------------------------------------------
03572       
03577       BMMExport void           DeleteThis                  ( ); // Call this , NOT delete, to free a Bitmap.              
03581       inline  DWORD            Flags                       ( ) { return flags; };
03586       inline  void             SetFlag                     ( DWORD flag ) { flags |= flag; };
03591       inline  void             ToggleFlag                  ( DWORD flag ) { flags ^= flag; };
03596       inline  void             ClearFlag                   ( DWORD flag ) { flags &= (~flag); };
03597       
03601       inline  int              Width                       ( ) { if (storage) return storage->Width();              return 0; };
03605       inline  int              Height                      ( ) { if (storage) return storage->Height();             return 0; };
03609       inline  float            Aspect                      ( ) { if (storage) return storage->Aspect();             return (float)0.0; };
03613       inline  float            Gamma                       ( ) { if (storage) return storage->Gamma();              return (float)0.0; };
03618       inline  int              Paletted                    ( ) { if (storage) return storage->Paletted();           return 0; };
03622       inline  int              IsDithered                  ( ) { if (storage) return storage->IsDithered();         return 0; };
03626       inline  int              PreMultipliedAlpha          ( ) { if (storage) return storage->PreMultipliedAlpha(); return 0; };
03630       inline  int              HasAlpha                    ( ) { if (storage) return storage->HasAlpha();           return 0; };
03633       inline  int              IsHighDynamicRange          ( ) { if (storage) return storage->IsHighDynamicRange(); return 0; };
03637       inline  int              MaxRGBLevel                 ( ) { if (storage) return storage->MaxRGBLevel();        return 0; };
03641       inline  int              MaxAlphaLevel               ( ) { if (storage) return storage->MaxAlphaLevel();      return 0; };
03646       inline  void             UseScaleColors              ( int on ) { if (storage) storage->UseScaleColors(on); };
03650       inline  int              ScaleColors                 ( ) { if (storage) return storage->ScaleColors();        return 0; };
03659       inline  static void      ClampColor                  (BMM_Color_64& out, const BMM_Color_fl& in) { BitmapStorage::ClampColor(out, in); }
03667       inline  static void      ClampColorA                 (BMM_Color_64& out, const BMM_Color_fl& in) { BitmapStorage::ClampColorA(out, in); }
03668 
03677       inline  static void      ScaleColor                  (BMM_Color_64& out, const BMM_Color_fl& in) { BitmapStorage::ScaleColor(out, in);}
03685       inline  static void      ScaleColorA                 (BMM_Color_64& out, const BMM_Color_fl& in) { BitmapStorage::ScaleColorA(out, in);}
03695       inline  void             ClampScaleColor             (BMM_Color_64& out, const BMM_Color_fl& in) { if (storage) storage->ClampScaleColor(out, in); else ClampColor(out, in); }
03705       inline  void             ClampScaleColorA            (BMM_Color_64& out, const BMM_Color_fl& in) { if (storage) storage->ClampScaleColorA(out, in); else ClampColorA(out, in); }
03706 
03707               int              Put16Gray                   ( int x,int y,int pixels,WORD *ptr )
03708                                                            { if (storage) return storage->Put16Gray(x,y,pixels,ptr); return 0; };
03724               int              Put16Gray                   ( int x,int y,int pixels,float *ptr )
03725                                                            { if (storage) return storage->Put16Gray(x,y,pixels,ptr); return 0; };
03726       inline  void            *GetStoragePtr               ( int *type ) 
03727                                                            { if (storage) return storage->GetStoragePtr(type);       return NULL; };
03728       inline  void            *GetAlphaPtr                 ( int *type ) 
03729                                                            { if (storage) return storage->GetAlphaPtr(type);         return NULL; };
03730       inline  int              Get16Gray                   ( int x,int y,int pixels,WORD *ptr )
03731                                                            { if (storage) return storage->Get16Gray(x,y,pixels,ptr);         return 0; };
03746       inline  int              Get16Gray                   ( int x,int y,int pixels,float *ptr )
03747                                                            { if (storage) return storage->Get16Gray(x,y,pixels,ptr);         return 0; };
03748       inline  int              GetPixels                   ( int x,int y,int pixels,BMM_Color_64 *ptr )
03749                                                            { if (storage) return storage->GetPixels(x,y,pixels,ptr);         return 0; };
03765       inline  int              GetPixels                   ( int x,int y,int pixels,BMM_Color_fl *ptr )
03766                                                            { if (storage) return storage->GetPixels(x,y,pixels,ptr);         return 0; };
03767       BMMExport int            PutPixels                   ( int x,int y,int pixels,BMM_Color_64 *ptr );
03784       BMMExport int            PutPixels                   ( int x,int y,int pixels,BMM_Color_fl *ptr );
03801       inline  int              GetLinearPixels             ( int x,int y,int pixels,BMM_Color_64 *ptr )
03802                                                            { if (storage) return storage->GetLinearPixels(x,y,pixels,ptr);     return 0; };
03803       inline  int              GetLinearPixels             ( int x,int y,int pixels,BMM_Color_fl *ptr )
03804                                                            { if (storage) return storage->GetLinearPixels(x,y,pixels,ptr);     return 0; };
03819       inline  int              GetIndexPixels              ( int x,int y,int pixels,BYTE *ptr )
03820                                                            { if (storage) return storage->GetIndexPixels(x,y,pixels,ptr);      return 0; };
03837       inline  int              PutIndexPixels              ( int x,int y,int pixels,BYTE *ptr )
03838                                                            { if (storage) return storage->PutIndexPixels(x,y,pixels,ptr);      return 0; };
03839       inline  int              CropImage                   ( int width,int height,BMM_Color_64 fillcolor)
03840                                                            { if (storage) return storage->CropImage(width,height,fillcolor);   return 0; };
03841       inline  int              CropImage                   ( int width,int height,BMM_Color_fl fillcolor)
03842                                                            { if (storage) return storage->CropImage(width,height,fillcolor);   return 0; };
03843       inline  int              CropImage                   ( int width,int height,int fillindex)
03844                                                            { if (storage) return storage->CropImage(width,height,fillindex);   return 0; };
03846       inline  int              ResizeImage                 ( int width,int height,int newpalette)
03847                                                            { if (storage) return storage->ResizeImage(width,height,newpalette);return 0; };
03848       inline  int              CopyImage                   ( Bitmap *from,int operation,BMM_Color_64 fillcolor, BitmapInfo *bi = NULL)
03849                                                            { if (storage) return storage->CopyImage(from,operation,fillcolor,bi); return 0; };
03875       inline  int              CopyImage                   ( Bitmap *from,int operation,BMM_Color_fl fillcolor, BitmapInfo *bi = NULL)
03876                                                            { if (storage) return storage->CopyImage(from,operation,fillcolor,bi); return 0; };
03888       inline  int              CopyImage                   ( Bitmap *from,int operation,int fillindex)
03889                                                            { if (storage) return storage->CopyImage(from,operation,fillindex); return 0; };
03901       inline  int              GetPalette                  ( int start,int count,BMM_Color_48 *ptr)
03902                                                            { if (storage) return storage->GetPalette(start,count,ptr);         return 0; };
03913       inline  int              SetPalette                  ( int start,int count,BMM_Color_48 *ptr)
03914                                                            { if (storage) return storage->SetPalette(start,count,ptr);         return 0; };
03915 
03916       //-- GRAINSTART
03917 
03918       // Effects methods (GG 11/03/98) ----------
03919 
03920       BMMExport void            FilmGrain               ( float grain, BOOL mask, PBITMAP_FX_CALLBACK callback = NULL, void *param = NULL );
03921 
03922       //-- GRAINEND
03923 
03924       // GBuffer methods ---------------------
03925 
03947       inline void             *GetChannel                ( ULONG channelID, ULONG& chanType ) 
03948                                        { if (storage) return storage->GetChannel(channelID, chanType); return NULL; }   
03949       
03951       inline GBuffer *GetGBuffer()  { return storage? storage->GetGBuffer(): NULL; } 
03952 
03959       inline ULONG            CreateChannels             ( ULONG channelIDs ) 
03960                                              { if (storage) return storage->CreateChannels(channelIDs); return 0; }   
03966       inline void             DeleteChannels             ( ULONG channelIDs ) 
03967                                              { if (storage) storage->DeleteChannels(channelIDs); }     
03970       inline ULONG            ChannelsPresent            ( )   
03971                                              { if (storage) return storage->ChannelsPresent();  return 0; }   
03975       inline RenderInfo*           GetRenderInfo()        { if (storage) return storage->GetRenderInfo(); return NULL; }
03976 
03980       inline RenderInfo*           AllocRenderInfo()     { if (storage) return storage->AllocRenderInfo(); return NULL; }
03981 
03982 
03983       //---------------------------------------------------------------------
03984       //
03985       //   This call will check with the plug-in (file or device) defined in 
03986       //   the given BitmapInfo and prepare (create) the proper channels. If 
03987       //   a given channel already exists, no new channel will be created. 
03988       //
03989       //   After creating a bitmap, use this function to define the optional 
03990       //   channels that may be required by the given handler. 
03991       //
03992 
04003       BMMExport BOOL          PrepareGChannels           ( BitmapInfo *bi ); 
04004       BMMExport BOOL          PrepareGChannels           ( DWORD channels ); 
04005 
04006 
04007       BMMExport int           GetFiltered                ( float u,float v,float du,float dv,BMM_Color_64 *ptr );
04033       BMMExport int           GetFiltered                ( float u,float v,float du,float dv,BMM_Color_fl *ptr );
04043       BMMExport int           SetDither                  ( UINT ditherType );
04049       BMMExport int           SetFilter                  ( UINT filterType );
04052       inline    int           HasFilter                  ( ) { return (filter) ? 1:0; };
04055       inline    BitmapFilter  *Filter                    ( ) { return filter; }; 
04061       BMMExport int           SetStorage                 ( BitmapStorage *storage);
04064       inline    BitmapStorage *Storage                   ( ) { return storage; };
04066       inline    void          NullStorage                ( ) { storage = NULL; };
04067       
04068       //-- Windows DIB Conversion -------------------------------------------
04069       //
04070       //   Where depth is either 24 (BGR) or 32 (BGR0)
04071       //
04072 
04103       BMMExport PBITMAPINFO    ToDib                       ( int depth = 24, UWORD *gam=NULL, BOOL dither=FALSE, BOOL displayGamma=FALSE );
04104 
04105       //-- Do not use this directly. Instead, use BitmapManager::Create(PBITMAPINFO)
04106 
04114       BMMExport BOOL           FromDib                     ( PBITMAPINFO pbmi );
04115       
04116       //-- Image output operations ------------------------------------------
04117       //
04118       //  To write a single image to a file/device:
04119       //
04120       //  *> Create BitmapInfo class: BitmapInfo bi;
04121       //
04122       //  *> Define output file/device:
04123       //
04124       //     Directly:       bi.SetName("file.tga");
04125       //   or
04126       //     User Interface: BitmapManager::SelectFileOutput( ... &bi ...)
04127       //
04128       //  *> Define bitmap: 
04129       //
04130       //                     bi.SetWidth(x)
04131       //                     bi.SetHeight(y)
04132       //                     etc...
04133       //
04134       //  *> Create bitmap:  Bitmap *map = BitmapManager::Create(&bi);
04135       //                     
04136       //
04137       //  *> Do something:   map->Fill({0,0,0});
04138       //
04139       //  *> OpenOutput:     map->OpenOutput(&bi);
04140       //
04141       //  *> Write:          map->Write(&bi)
04142       //
04143       //  *> Close:          map->Close(&bi)
04144       //
04145       //  To write a multiframe file, just keep doing something different to
04146       //  the bimap and keep writting. 
04147       //
04148       //  To write a sequence of images to a file/device:
04149       //
04150       //  *> Create BitmapInfo class: BitmapInfo bi;
04151       //
04152       //  *> Define output file/device:
04153       //
04154       //     Directly:       bi.SetName("file.tga");
04155       //   or
04156       //     User Interface: BitmapManager::SelectFileOutput( ... &bi ...)
04157       //
04158       //  *> Define bitmap: 
04159       //
04160       //                     bi.SetWidth(x)
04161       //                     bi.SetHeight(y)
04162       //
04163       //                     bi.SetFirstFrame(0)
04164       //                     bi.SetLastFrame(29)
04165       //
04166       //                     etc...
04167       //
04168       //  *> Create bitmap:  Bitmap *map = BitmapManager::Create(&bi);
04169       //                     
04170       //
04171       //  *> OpenOutput:     map->OpenOutput(&bi);
04172       //
04173       //     for (x = 0 to 29) {
04174       //        *> Do something to image...
04175       //        *> Write:    map->Write(&bi,x);
04176       //     }
04177       //
04178       //  *> Close:          map->Close(&bi)
04179       //
04180       //
04181       //  Note: You can add any number of  outputs to a bitmap. Just keep
04182       //  calling map->OpenInput() with different outputs (Targa file AND
04183       //  Frame Buffer for instance). To write or close a specific output,
04184       //  use Write()  and Close().  To write  and close them all at once,
04185       //  use WriteAll() and CloseAll().
04186       //
04187       //  It is ok to use WriteAll() and CloseAll() if you have just one
04188       //  output defined.
04189       //
04190       
04208       BMMExport BMMRES         OpenOutput                  ( BitmapInfo *bi );                                        // Open output
04231       BMMExport BMMRES         Write                       ( BitmapInfo *bi, int frame = BMM_SINGLEFRAME );         // Write frame to file
04243       BMMExport BMMRES         WriteAll                    ( int frame = BMM_SINGLEFRAME );                         // Write all open outputs
04253       BMMExport int            Close                       ( BitmapInfo *bi, int flag = BMM_CLOSE_COMPLETE );         // Close an open output
04260       BMMExport int            CloseAll                    ( int flag = BMM_CLOSE_COMPLETE);                          // Close all open outputs
04261 
04262       //-- Window gravity
04263 
04264       #define   BMM_UL  1      //-- Upper Left
04265       #define   BMM_LL  2      //-- Lower Left
04266       #define   BMM_UR  3      //-- Upper Right
04267       #define   BMM_LR  4      //-- Upper Left
04268       #define   BMM_CN  5      //-- Center
04269 
04270       #define   BMM_RND 10     //-- Renderer (Save/Restore)
04271       #define   BMM_VPP 11     //-- Video Post Primary (Save/Restore)
04272       #define   BMM_VPS 12     //-- Video Post Secondary (Save/Restore)
04273 
04304       BMMExport int            Display                     ( MCHAR *title = NULL,   int position = BMM_CN, 
04305             BOOL autonomous = FALSE, BOOL savebutton = TRUE, CropCallback *crop=NULL, Bitmap *cloneMyVFB = NULL );
04309       BMMExport int            UnDisplay                   ( );
04313       BMMExport HWND           GetWindow                   ( );
04322       BMMExport void           RefreshWindow               ( RECT *rect = NULL );
04327       BMMExport void           SetWindowTitle              ( MCHAR *title );
04342       BMMExport void           SetCroppingValues           ( float u, float v, float w, float h, BOOL placeImage);
04343 
04344       //-- Get a Different Frame  -------------------------------------------
04345       //
04346       //   For  multifrane bitmaps (FLI's, AVI's, DDR devices, etc.),  if you
04347       //   simply want to load  another frame replacing a previously "Load"ed
04348       //   image.
04349       //
04350       //   If used with single frame drivers or if the driver doesn't support
04351       //   this function,  it returns BMMRES_SINGLEFRAME. If the return value
04352       //   is BMMRES_SUCCESS,  a new frame  has  been  loaded  into the given 
04353       //   bitmap.
04354       //
04355       //   To define desired frame, use bi->SetCurrentFrame( frame );
04356       //
04357       
04369       BMMExport BMMRES         GoTo                        ( BitmapInfo *bi );
04370 
04371       //-- Handy built-in functions
04372 
04385       BMMExport int            Fill                        ( int r,int g,int b,int alpha);
04390       BMMExport int            Fill                        (const BMM_Color_fl& fillColor);
04394       BMMExport int            Fill                        (const BMM_Color_64& fillColor);
04395 
04396       // Set a callback so can get notified if storage changed
04404       BMMExport void          SetNotify( BitmapNotify *bmnot=NULL);
04409       BitmapNotify *          GetNotify() { return bmNotify; }
04410         
04416       BMMExport BOOL IsAutonomousVFB();
04417 
04418       // Generic expansion function
04434       BMMExport INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0); 
04435 
04436       DWORD GetModifyID() { return modifyID; }
04437       void SetModifyID(DWORD m) { modifyID = m; }
04438       BMMExport void IncrModifyID();
04439 
04440       // Print the bitmap (if supported by the host app)
04442       BMMExport void Print(bool silent = false);
04443 
04454       BMMExport void ShowProgressLine(int y); // y<0 to hide
04455 };
04456 
04457 //-- Various Bitmap In-Memory Lists -------------------------------------------
04458 
04459 struct BMMStorageList: public MaxHeapOperators {
04460     BitmapStorage *ptr;
04461     BMMStorageList *next;
04462     };
04463 
04464 struct BMMFilterList: public MaxHeapOperators {
04465     BitmapFilter *ptr;
04466     BMMFilterList *next;
04467     } ;
04468 
04469 struct BMMBitmapList: public MaxHeapOperators {
04470     Bitmap *ptr;
04471     BMMBitmapList *next;
04472     };
04473 
04474 struct BMMGammaSettings: public MaxHeapOperators {
04475     BitmapManager *mgr;
04476     BitmapInfo    *bi;
04477     BOOL           out;
04478     };     
04479 
04480 struct BMMVfbPalette: public MaxHeapOperators {
04481     BYTE  r,g,b;
04482     };     
04483 
04484 class BitmapFileInputDialog: public MaxHeapOperators {
04485     public:
04486     virtual BOOL BrowseBitmapFilesInput(BitmapInfo* info, HWND hWnd, MCHAR* title, BOOL view) = 0;
04487     };
04488 
04489 class BitmapFileOutputDialog: public MaxHeapOperators {
04490     public:
04491     virtual BOOL BrowseBitmapFilesOutput(BitmapInfo* info, HWND hWnd, MCHAR* title) = 0;
04492     };
04493 
04494 //-----------------------------------------------------------------------------
04495 //-- Main Bitmap Manager Class
04496 //
04497 
04519 #pragma warning(push)
04520 #pragma warning(disable:4100)
04521 class BitmapManager : public InterfaceServer{
04522    
04523    public:
04524    
04525       BMMVfbPalette            *pal;
04526 
04527       //-- Construction/Destruction
04528       
04529       BitmapManager               ( BMMInterface *i) { pal = NULL; }
04530       BitmapManager               ( BMMInterface *i,const MCHAR *name) { pal = NULL; }
04531       BMMExport virtual           ~BitmapManager               ( );
04532       friend void                 DoConstruct      ( BitmapManager *m, BMMInterface *i, const MCHAR *name);
04533 
04534       //-- These are for internal use only
04535       
04536       virtual int            DeleteAllMaps               ( )=0;
04537       virtual int            AddStorage                  ( BitmapStorage *s)=0;
04538       virtual int            AddFilter                   ( BitmapFilter *a)=0;
04539       virtual int            AddBitmap                   ( Bitmap *b)=0;
04540       virtual int            DelStorage                  ( BitmapStorage *s)=0;
04541       virtual int            DelFilter                   ( BitmapFilter *a)=0;
04542       virtual int            DelBitmap                   ( Bitmap *b)=0;
04543       virtual BitmapFilter  *FindFilter                  ( BitmapStorage *s,UINT type)=0;
04544       virtual BitmapStorage *FindStorage                 ( BitmapInfo *bi, int openMode)=0;
04545       virtual int            FnametoBitMapInfo           ( BitmapInfo *bi )=0;       
04546       virtual void           FixFileExt                  ( OPENFILENAME &ofn, const MCHAR *extension)=0;
04547       virtual void           MakeVfbPalette              ( )=0;
04548 
04549       BMM_IOList               ioList;
04550       virtual void           ListIO                      ( )=0;
04551       
04552       //---------------------------------------------------------------------
04553       //-- Public Interface -------------------------------------------------
04554       
04555       //-- Host Interface
04556 
04559       virtual HINSTANCE      AppInst                     ( )=0;
04561       virtual HWND           AppWnd                      ( )=0;
04562         virtual DllDir        *AppDllDir                   ( )=0;
04570       virtual const MCHAR   *GetDir                      (int i)=0;
04573       virtual BOOL           AddMapDir                   (const MCHAR *dir,int update)=0;
04577       virtual int            GetMapDirCount              ( )=0;
04584         virtual const MCHAR   *GetMapDir                   (int i)=0;
04588       virtual Interface     *Max                         ()=0;
04591       virtual Bitmap        *NewBitmap                   ()=0; // returns a new Bitmap 
04592 
04593       // Set a replacement for the bitmap file dialog. NULL will set the default.
04594       virtual void          SetFileInputDialog(BitmapFileInputDialog* dlg = NULL)=0;
04595       virtual void          SetFileOutputDialog(BitmapFileOutputDialog* dlg = NULL)=0;
04596 
04597       //-- These won't stay here. Error handling will be dealt in a couple of 
04598       //   different ways. There will be a "Silent" flag that will be set by
04599       //   the client and tested here in order to know if an error dialog should
04600       //   go up. Normally, if the user is sitting in front of the computer
04601       //   this flag will be FALSE. When rendering in the background, or network
04602       //   rendering, etc., this flag will be TRUE. There should be some kind of
04603       //   "preferences" configuration for this behavior.
04604       //
04605       //   There also will be a method for logging errors. This method will check
04606       //   for a "loggin on/off" flag and either add the entry or ignore it. The
04607       //   bitmap manager and its devices will log everything that goes wrong.
04608       //   When silent mode is on and logging is also on, this is the method to
04609       //   check what went bad. Having each device logging its own error will
04610       //   enable a more accurate description of the problem (as opposed to "I/O
04611       //   error").
04612       //
04613       //   Gus
04614       //
04615       
04616       virtual int            Status                      ( int *sCount, int *aCount, int *bCount)=0;
04617       virtual int            Error                       ( const MCHAR *string)=0;
04618 
04619       //-- Error handling ---------------------------------------------------
04620       //
04621       //
04622 
04623       //-- Max Interface (means no logging)
04624       
04625       #define LG_NOLOG         0
04626       
04627       //-- User Interface
04628       
04629       #define LG_FATAL         ((DWORD)(1 << 0))
04630       #define LG_INFO          ((DWORD)(1 << 1))
04631       #define LG_DEBUG         ((DWORD)(1 << 2))
04632       #define LG_WARN          ((DWORD)(1 << 3))
04633 
04634       //-- User Interface 
04635       
04641       virtual BOOL           SilentMode                  ( )=0;
04643       virtual void           SysLog                      ( int type, char *format, ... )=0;
04644 
04645       //-- Max Interface (used internally)
04646       
04648       virtual BOOL           SetSilentMode               ( BOOL s )=0;
04650       virtual void           SetLogLevel                 ( DWORD level )=0;
04652       virtual DWORD          GetLogLevel                 ( )=0;
04653 
04654       //-- Creating a new bitmap from scracth -------------------------------
04655       //
04656       //   Make  sure the given  BitmapInfo class has the proper data for the
04657       //   creation of the bitmap.  If you used the BitmapManager function to
04658       //   define the bitmap (SelectBitmapOutput()), both filename and device
04659       //   driver have been defined for you. 
04660       //
04661       //   Make sure to set the type of bimap using bi.SetType(). This will 
04662       //   define the storage type as in (so far):
04663       //
04664       //   BMM_LINE_ART 
04665       //   BMM_PALETTED 
04666       //   BMM_GRAY_8
04667       //   BMM_GRAY_16
04668       //   BMM_TRUE_16  
04669       //   BMM_TRUE_32  
04670       //   BMM_TRUE_64  
04671       //
04672       //   Do NOT use BMM_TRUE_24 nor BMM_TRUE_48. These are read only types.
04673       //
04674       //   Example code is in src/app/vpexecut.cpp
04675       //
04676       //
04677       //   Once a bitmap has been created, use its own methods for adding
04678       //   outputs and writing it (i.e. map->OpenOutput(), map->Write() and
04679       //   map->Close()).
04680       //
04681       //   Gus
04682       //
04683       
04694       BMMExport virtual Bitmap        *Create                      ( BitmapInfo *bi   )=0;
04695 
04696       //-- Creating a new bitmap from an existing Windows DIB ---------------
04697       //
04698       //   To Convert a Bitmap to a Windows DIB check Bitmap::ToDib()
04699       //
04700 
04713       BMMExport virtual Bitmap        *Create                      ( PBITMAPINFO pbmi )=0;
04714 
04715       //-- Loads Bitmap -----------------------------------------------------
04716       //
04717       //   Loads a bitmap.
04718       //
04719       //   Like most other  bitmap  functions, you should define the image to
04720       //   to load (either setting the name/device directly in BitmapInfo bi,
04721       //   or having  SelectFileInput() do it for you).  Once bi has the name
04722       //   of the image you want to  load, call Load() to create a new Bitmap
04723       //   which contains the image. Additional options may be set by calling
04724       //   ImageInputOptions()  before calling Load().  That will as the user 
04725       //   for special details such as  positioning of smaller/larger images,
04726       //   etc. All this does is to set the proper fields in BitmapInfo. It's
04727       //   up to you to use those.
04728       //
04729       //   BitmapInfo defaults to frame "zero". For multifrane files, such as
04730       //   *.avi, *.ifl, *.flc, etc. you should  specify the frame number you
04731       //   want. Do it by using bi.SetCurrentFrame(f)  before calling Load().
04732       //   
04733       //   
04734       //   Note: If loading images from a device, make sure bi.Name() is
04735       //         empty (bi.SetName(_M(""));). This is automatic if you use
04736       //         SelectDeviceInput(). If you just create a BitmapInfo
04737       //         instance and set the device name by hand (bi.SetDevice()),
04738       //         this is also automatic as both name and device names are
04739       //         by default empty. This should only be a concern if you
04740       //         reuse a BitmapInfo class previously used for image files.
04741       //   
04742       //   
04743       //   One of the methods in BitmapInfo returns a  window handle to  send
04744       //   progress report messages. If you  want to  receive these messages,
04745       //   set the window handle  (  bi->SetUpdateWindow(hWnd)  ) and process
04746       //   BMM_PROGRESS messages (see above).
04747       //   
04748       //   Gus
04749       //
04750       
04771       BMMExport virtual Bitmap        *Load                       ( BitmapInfo *bi, BMMRES *status = NULL)=0;
04772 
04773       //-- Load Image into an existing Bitmap  ----------------
04774 
04796       virtual BMMRES         LoadInto                    ( BitmapInfo *bi, Bitmap **map, BOOL forceReload=FALSE )=0;
04797       
04798       //-- General User Interface -------------------------------------------
04799       
04820       virtual BMMRES         GetImageInfoDlg             ( HWND hWnd, BitmapInfo *bi, const MCHAR *filename = NULL )=0;
04835       virtual BMMRES         GetImageInfo                (            BitmapInfo *bi, const MCHAR *filename = NULL )=0;
04850       virtual BOOL           ImageInputOptions           ( BitmapInfo *bi, HWND hWnd )=0;
04861       virtual BOOL           SelectDeviceInput           ( BitmapInfo *bi, HWND hWnd )=0;
04872       virtual BOOL           SelectDeviceOutput          ( BitmapInfo *bi, HWND hWnd )=0;
04873 
04874 // flag passed in to SelectFileOutput
04875 #define BMM_ENABLE_SAVE_REGION  1
04876 // Flag returned by SelectFileOutput
04877 #define BMM_DO_SAVE_REGION      2
04878 
04902       virtual BOOL           SelectFileOutput            ( BitmapInfo *bi, 
04903                                                              HWND hWnd, 
04904                                                              MCHAR *title = NULL,
04905                                                              ULONG *pflags = NULL)=0;
04906 
04919       virtual BOOL           SelectFileInput             ( BitmapInfo *bi, 
04920                                                              HWND hWnd, 
04921                                                              MCHAR *title = NULL)=0;
04922       
04939       virtual BOOL           SelectFileInputEx           ( BitmapInfo *bi, 
04940                                                              HWND hWnd, 
04941                                                              MCHAR *title  = NULL,
04942                                                              BOOL viewonly = FALSE)=0;
04943       
04946       virtual void RefreshAllVFBs()=0;
04947 
04950       virtual void DeleteAllAutonomousVFBMaps()=0;
04951 
04952 // cmd values passed in to Execute
04953 #define BMM_STORE_GEOREF_DATA               0 // Used in VIZ only; arg1: const MCHAR*; arg2: GeoTableItem*; arg3: not used
04954 #define BMM_RETRIEVE_GEOREF_DATA            1 // Used in VIZ only; arg1: const MCHAR*; arg2: GeoTableItem**; arg3: not used
04955 #define BMM_USE_CUSTOM_FILTERLIST           2 // Used to pass a Filter list to the BitmapManager; arg1 MCHAR *, arg2,arg3 not used  
04956 #define BMM_SET_FILE_INPUT_SEQUENCE_FLAG    3 // Used to set the sequence flag  for file input 
04957 #define BMM_GET_FILE_INPUT_SEQUENCE_FLAG    4 // Used to get the sequence flag for file input 
04958 #define BMM_FLUSH_RELATIVE_FILE_RESOLUTION_CACHE 5 // Used to flush the internal cache used to avoid having to re-resolve relative paths on each LoadInto call
04959 
04960       // Generic expansion function
04976       virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)=0; 
04977 
04982       virtual void BeginSavingLoadErrorFiles()=0;  // --Begin accumulating a list of files that didn't load,
04983                                                    // and don't put up load errors in the meantime.
04987       virtual NameTab &GetLoadErrorFileList()=0;  // -- List of names of files not found
04990       virtual void EndSavingLoadErrorFiles()=0;  // --End accumulating a list of files that didn't load, free the list.
04997       virtual BMMExport bool CanImport(const MCHAR* filename)=0;
04998 
05000       inline void ClearInternalRelativePathResolutionCache()    { Execute(BMM_FLUSH_RELATIVE_FILE_RESOLUTION_CACHE); }
05001 
05002 };
05003 
05004 #pragma warning(pop)
05005 //-----------------------------------------------------------------------------
05006 //-- Bitmap Proxy Manager Class
05007 
05009 #define FPBITMAPPROXYMANAGER_INTERFACE_ID Interface_ID(0x24e22528, 0x601f3610)
05010 
05012 class IBitmapProxyManager : public FPStaticInterface {
05013     public:
05014         virtual BOOL        GetGlobalProxyEnable() = 0;                     
05015         virtual void        SetGlobalProxyEnable( BOOL enable ) = 0;        
05016 
05019         enum RenderMode {
05021             kRenderMode_UseProxies,
05025             kRenderMode_UseFullRes_KeepInMemory,
05029             kRenderMode_UseFullRes_FlushFromMemory
05030         };
05032 
05033         virtual RenderMode  GetGlobalProxyRenderMode() = 0;
05037         virtual void        SetGlobalProxyRenderMode( RenderMode renderMode ) = 0;
05038    
05041         enum {
05042                             proxySizeFactor_Full=1,                         
05043                             proxySizeFactor_Half=2,                         
05044                             proxySizeFactor_Third=3,                        
05045                             proxySizeFactor_Quarter=4,                      
05046                             proxySizeFactor_Eighth=8,                       
05047         };
05049         virtual int         GetGlobalProxySizeFactor() = 0;                 
05050         virtual void        SetGlobalProxySizeFactor( int factor ) = 0;     
05051         virtual int         GetGlobalProxySizeMin() = 0;                    
05052         virtual void        SetGlobalProxySizeMin( int min ) = 0;           
05053 
05054         virtual int         GetProxySizeFactor(const MCHAR* filename) = 0;              
05055         virtual void        SetProxySizeFactor(const MCHAR* filename, int factor) = 0;  
05056         virtual BOOL        GetProxyUseGlobal(const MCHAR* filename) = 0;               
05057         virtual void        SetProxyUseGlobal(const MCHAR* filename, BOOL global) =0 ;  
05058         virtual BOOL        GetProxyReady(const MCHAR* filename) = 0;                   
05059 
05063         enum {
05064                             proxyRequestRefresh_UpdateStale=1,              
05065                             proxyRequestRefresh_RefreshAll=2,               
05066                             proxyRequestRefresh_GenerateAll=4,              
05067         };
05069         virtual void        RefreshProxies( int requestRefresh ) = 0;       
05070         virtual void        GenerateProxies( int requestRefresh ) = 0;      
05071 
05073         virtual void        ShowConfigDialog( Tab<MCHAR*>* bitmapFilenames ) = 0;
05074 
05076         virtual void        ShowPrecacheDialog( Tab<MCHAR*>* bitmapFilenames ) = 0;
05077 
05081         enum {
05082                             proxyRequestFlags_ForceProxyMode=0x40000000,    
05083         };
05085 
05089         enum {
05090                             proxyRequestLoad_UseLoadedProxy=1,              
05091                             proxyRequestLoad_ReloadProxy=2,                 
05092 
05095                             proxyRequestLoad_UseLoadedSubject=3,
05096                             proxyRequestLoad_ReloadSubject=4,               
05097         };
05099 
05100 
05101         virtual BMMRES         LoadInto( BitmapInfo* requestInfo, Bitmap** pbitmap, int requestLoad, int requestFlags=0 ) = 0;
05102 };
05103 
05105 BMMExport IBitmapProxyManager* GetBitmapProxyManager();
05106 
05108 
05116 class BitmapProxyTemporaryDisableGuard: public MaxHeapOperators {
05117 public:
05123     BMMExport explicit BitmapProxyTemporaryDisableGuard(bool doDisable = true);
05125     BMMExport ~BitmapProxyTemporaryDisableGuard();
05126 private:
05127     static int m_numInstances;
05128     bool m_doDisable;
05129 };
05130 
05131 
05133 #define BMM_ASSET_GROUP             1 //!< The declared bitmap represents a group. You must call EndGroup on the enum callback after you are finished grouping assets.
05134 #define BMM_ASSET_PROXY             2 //!< The declared bitmap is proxy enabled.
05135 
05137 
05148 BMMExport void DeclareBitmapAsset(IEnumAuxAssetsCallback &enumCallback, IAssetAccessor &anAccessor, BitmapInfo* bitmapInfo, int flags=0);
05149 
05150 //-----------------------------------------------------------------------------
05151 //-- Forward References for Bitmap Functions
05152 //
05153 //   Internal Use
05154 //
05155 
05156 extern int                      ValidBitmapType     ( int type );
05197 extern BMMExport BitmapStorage* BMMCreateStorage    ( BitmapManager *manager,UINT type );
05198 extern BMMExport BitmapFilter*  BMMCreateFilter     ( BitmapManager *manager,UINT type );
05199 extern BMMExport BitmapDither*  BMMCreateDither     ( BitmapManager *manager,UINT type );
05200 extern BMMExport int            BMMCalcPalette      ( Bitmap *map,int colors,BMM_Color_48 *palette );
05201 extern BMMExport BYTE           BMMClosestColor     ( BMM_Color_64 *color,BMM_Color_48 *palette,int colors );
05202 // Returns a localized string that describes one of the (BMM_TRUE_32, BMM_TRUE_64, etc.) bitmap types.
05203 // The string is loaded into a static buffer and therefore should be used or copied immediately.
05204 // The bitmap flags (from BitmapInfo::Flags()) are also used.
05212 extern BMMExport const MCHAR*   BMMGetBitmapTypeDescription(int bitmapType, DWORD bitmapFlags);
05213 
05214 extern BMMExport void           OpenBMM             ( BMMInterface *i );
05215 extern BMMExport void           CloseBMM            ( );
05216 extern INT_PTR CALLBACK BMMGammaDlgProc     (HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
05217                 // WIN64 Cleanup: Martell
05218 extern           void            ExtractExtension   ( MCHAR *string, MCHAR *ext );
05219 
05220 
05221 //-- Public Utilities ---------------------------------------------------------
05222 
05233 BMMExport int           BMMCreateNumberedFilename   ( const MCHAR *namein,int frame,MCHAR *nameout );
05234 
05244 BMMExport int           BMMFindNumberedFilenames ( const MaxSDK::Util::Path &baseFilename, MaxSDK::Array<MaxSDK::Util::Path> &foundFiles);
05245 
05258 BMMExport int           BMMGetFullFilename          ( BitmapInfo *bi ); //<! Resolves the filename in the given BitmapInfo (bi->Name())
05259 BMMExport BOOL          BMMGetFullFilename          ( const MCHAR *namein, MCHAR* nameout ); //<! Resolves the given input name (namein) into the given output (nameout)
05261 
05262 BMMExport BOOL          BMMIsFile                   ( const MCHAR *filename );
05263 BMMExport void          BMMSplitFilename            ( const MCHAR *name,MCHAR *p,MCHAR *f,MCHAR *e );
05264 BMMExport LPTSTR        BMMGetLastErrorText         ( LPTSTR lpszBuf, DWORD dwSize );
05265 BMMExport Quantizer*    BMMNewQuantizer             ();
05266 
05269 
05270 BMMExport void          BMMAppendSlash              ( MCHAR *path );
05271 
05274 
05275 BMMExport void          BMMRemoveSlash              ( MCHAR *path );
05276 
05279 
05280 BMMExport void          BMMAppendSlash              ( MSTR &path );
05281 
05284 
05285 BMMExport void          BMMRemoveSlash              ( MSTR &path );
05286 
05287 //-----------------------------------------------------------------------------
05288 //-- Share Utilities
05289 //
05290 //  BMMGetUniversalName() 
05291 //  ---------------------
05292 //  Given a path (E:\path\filename.ext), the function will check and see if 
05293 //  this drive is mapped to a network share. If successful, the full UNC 
05294 //  version will be returned in out_uncname ("\\computer\share\path\file.ext")
05295 //  If the function returns FALSE, out_uncname will be left undefined.
05296 //
05297 //  This function has been enhanced to also return an UNC for a local drive
05298 //  that happens to be shared. For instance, if you pass in something like
05299 //  d:\data\images\maps\background\rottenredmond.tga and it happens that 
05300 //  d:\data is shared as "Image Data", the function will return:
05301 //  \\computername\Image Data\images\rottenredmond.tga.
05302 //
05303 //  Pass "nolocal" as TRUE if you just want to see if this is a network
05304 //  share (don't check if this local drive is shared).
05305 //
05306 //  BMMFindNetworkShare()
05307 //  ---------------------
05308 //  Given a path (E:\path\filename.ext) this function will check and see if
05309 //  this [local] path is shared. If successful, it will return both the
05310 //  share name and the path of the share.
05311 //
05312 //  BMMGetLocalShare()
05313 //  ------------------
05314 //
05315 //  This is the "second half" of BMMGetUniversalName() above. It is used
05316 //  internally but it is exported here as a convenience. It will check local
05317 //  paths only and return a UNC version if a share exists somewhere up in
05318 //  the path hierarchy.
05319 //
05320 //  GG: 06/28/00
05321 
05322 BMMExport BOOL  BMMGetUniversalName ( MCHAR *out_uncname, const MCHAR* in_path);
05323 BMMExport BOOL  BMMFindNetworkShare ( const MCHAR* in_localpath, MCHAR* out_sharename, MCHAR* out_sharepath);
05324 BMMExport BOOL  BMMGetLocalShare    ( const MCHAR *local_path, MCHAR *share );
05325 
05326 //-----------------------------------------------------------------------------
05327 
05328 // Get a color packer.  When done, be sure to call its DeleteThis();
05329 BMMExport ColorPacker *BMMNewColorPacker(
05330     int w,              // width of bitmap to be packed
05331     BMM_Color_48 *pal,  // palette to use
05332     int npal,           // number of entries in the palette
05333     BYTE* remap=NULL    // optional remap done at last stage.
05334     );
05335 
05336 //-----------------------------------------------------------------------------
05337 //  Rearrange palette "pal" ( which has colors 0..ncols-1 occupied, in 
05338 //  descending order of frequency),  into "newpal" so that the colors 10-245 are 
05339 //  populated first, then 0-9, then 246-255.  Sets optional array "remap" to map
05340 //  the old palette index values to the new ones    
05355 BMMExport void FixPaletteForWindows(BMM_Color_48 *pal, BMM_Color_48 *newpal,int ncols, BYTE *remap=NULL);
05356 
05357 //-----------------------------------------------------------------------------
05358 //-----------------------------------------------------------------------------
05359 //-- Layer Utility (IO Support)
05360 //
05361 
05362 #define BITMAP_IOLAYER_CLASS    Interface_ID(0x296b79ec,0x73e11944)
05363 
05364 class BitmapIOLayer : public BaseInterface {
05365     public:
05366         virtual BOOL            Init        (const MCHAR* filename)=0;
05367         virtual int             LayerCount  ()=0;
05368         virtual const MCHAR*    LayerName   (int index)=0;
05369         virtual BOOL            SetLayer    (int index, BitmapInfo* bi, BOOL fulframe = TRUE)=0;
05370 };
05371 
05372 //-----------------------------------------------------------------------------
05373 //-- Layer Utility (Global)
05374 //
05375 
05376 #define LAYER_INTERFACE             Interface_ID(0x1563269c,0x7ec41d89)
05377 #define I_LAYER_INTERFACE           0x000A1001  
05378 
05379 class BitmapLayerUtl : public FPStaticInterface  {
05380     public:
05381         virtual int             LayerCount  (const MCHAR* filename)=0;
05382         virtual const MCHAR*    LayerName   (const MCHAR* filename, int index)=0;
05383         virtual PBBitmap*       LoadLayer   (const MCHAR* filename, int index, BOOL fulframe = TRUE)=0;
05384 };
05385 
05386 
05387 //-----------------------------------------------------------------------------
05388 //-- Bitmap Pager Class
05389 //
05390 
05392 #define IBITMAPPAGER_INTERFACE_ID Interface_ID(0x48e1041f, 0x34c86c51)
05393 
05403 class IBitmapPager : public FPStaticInterface {
05404     public:
05405         DECLARE_DESCRIPTOR( IBitmapPager );
05406 
05407         //----------------------------------------------------------------------
05408         //-- Bitmap Pager options
05409 
05411 
05413         virtual BOOL IsPagerEnabled() = 0;
05415 
05419         virtual void SetPagerEnabled( BOOL b ) = 0;
05420 
05427 
05428         virtual const MCHAR* GetPageFilePath() = 0;
05430 
05432         virtual void SetPageFilePath(const MCHAR* path) = 0;
05434 
05444 
05445         virtual float GetMemoryLimitPercent() = 0;
05447 
05448         virtual void SetMemoryLimitPercent( float percent ) = 0;
05450 
05457 
05458         virtual float GetMemoryPaddingPercent() = 0;
05460 
05461         virtual void SetMemoryPaddingPercent( float percent ) = 0;
05463 
05464 
05472 
05473         virtual BOOL GetMemoryLimitAutoMode() = 0;
05475         virtual void SetMemoryLimitAutoMode( BOOL onOff ) = 0;
05477 
05478 
05480 
05482         virtual size_t GetMemoryLimit() = 0;
05483         virtual size_t GetMemoryUsedForPager() = 0;     
05484         virtual size_t GetMemoryPadding() = 0;          
05485         virtual size_t GetMemoryAvailablePadded() = 0;  
05486         // 64-bit values, may exceed 2GB
05487         virtual LONGLONG GetMemoryTotalForPager() = 0;  
05488 };
05489 
05491 inline IBitmapPager* GetIBitmapPager()
05492 { return (IBitmapPager*)GetCOREInterface(IBITMAPPAGER_INTERFACE_ID); }
05493