gport.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: gport.h
00004 
00005     DESCRIPTION: Palette management.
00006 
00007     CREATED BY: Dan Silva
00008 
00009     HISTORY:
00010 
00011  *> Copyright (c) 1994, All Rights Reserved.
00012  **********************************************************************/
00013 
00014 #pragma once
00015 #include "coreexp.h"
00016 #include "maxheap.h"
00017 #include <WTypes.h>
00018 #include "maxtypes.h"
00019 #include "color.h"
00020 #include "box2.h"
00021 
00022 
00037 class GPort: public MaxHeapOperators {
00038     public:
00040         virtual ~GPort() {;}
00041 
00042         // get the palette index associated with the ith slot
00048         virtual int AnimPalIndex(int i)=0;
00049     
00050         // returns a slot number if available, -1 if not:
00051         // typically called in WM_INITDIALOG processing for as
00052         // may slots as you need (total availible is 8)
00057         virtual int GetAnimPalSlot()=0;
00058 
00059         // Release an animated palete slot slot 
00060         // Typically called in WM_DESTROY for each slot
00061         // obtained with GetAnimPalSlot
00068         virtual void ReleaseAnimPalSlot(int i)=0;
00069 
00070         // set the color associated with the ith animated slot
00077         virtual void SetAnimPalEntry(int i, COLORREF cr)=0;
00078 
00079         // Stuff the standard MAX palette the palette for the HDC,
00080         // handing back a handle to the old palette.
00087         virtual HPALETTE PlugPalette(HDC hdc)=0;
00088 
00089         // Create a brush for drawing with the ith animated palette slot color
00098         virtual HBRUSH MakeAnimBrush(int slotNum, COLORREF col )=0;
00099 
00100         // Update colors calls the Windows UpdateColors on the hdc.
00101         // Returns 1 iff it changed screen pixel values .
00102         // Call this when get WM_PALETTECHANGED Msg
00110         virtual int UpdateColors(HDC hdc)=0;
00111 
00112         // After several SetAnimPalEntry calls, call this to affect the
00113         // HDC's palette
00120         virtual void AnimPalette(HDC hdc)=0;
00121 
00122         // The companion function to PlugPalette.
00130         virtual void RestorePalette(HDC hDC,HPALETTE hOldPal)=0;
00131 
00132         // Map an single row of pixels 24 bit color to indices into 
00133         // the current GPort palette, applying a dither pattern.
00134         // This routine does NOT do gamma correction.
00135         // inp points to an array of width RGB triples.
00136         // outp is an array of width bytes.  x and y are necessary to 
00137         // establish dither pattern alignment.
00159         virtual void MapPixels(UBYTE* inp, UBYTE *outp, int x, int y, int width)=0;
00160 
00161          
00162         // Display an array of 24bit colors in the HDC: if the current display is 8 bit
00163         //  it will display it (with dither) using in the GPort palette, otherwise it 
00164         //  will just blit to the screen. Does NOT do gamma correction.
00165         //   "drect" is the destination rectangle in the hdc.
00166         //   "map" points to an array of RGB triples, with bytesPerRow bytes on each scanline.
00167         //   "xsrc" and "ysrc" are the position within this source raster of the upper left
00168         //    corner of the rectangle to be copied..
00188         virtual void DisplayMap(HDC hdc, Rect& drect,int xsrc, int ysrc, UBYTE *map, int bytesPerRow)=0;
00189         
00190         // This version stretches the image (if src!=dest).
00191         //  "dest" is the destination rectangle in the hdc;
00192         //  "src" is the source rectangle in map.
00207         virtual void DisplayMap(HDC hdc, Rect& dest, Rect& src, UBYTE *map, int bytesPerRow)=0; 
00208 
00209         // DitherColorSwatch first gamma corrects Color c using the current
00210         // display gamma. In paletted modes, it will fill rectangle "r" with 
00211         // a dithered pattern  approximating Color c.  In 24 bit modes it just 
00212         // fills the rectange with c.
00224         virtual void DitherColorSwatch(HDC hdc, Rect& r, Color c)=0;
00225 
00226         // This attempts to use the animated color slot indicated by "slot"
00227         // to paint a rectangular color swatch. 
00228         // If slot is -1, it will uses DitherColorSwatch.  It does gamma correction.
00250         virtual void PaintAnimPalSwatch(HDC hdc, DWORD col, int slot, int left, int top, int right, int bottom)=0;
00251 
00252         // get the current GPort palette.
00254         virtual HPALETTE GetPalette()=0;
00255     };
00256 
00257 // Normally this is the only one of these, and this gets you a pointer to it.
00263 extern CoreExport GPort* GetGPort();
00264 
00265