Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

Ovgabuf.h Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Ovgabuf.h

Go to the documentation of this file.
00001 //Filename    : VGABUF.H
00002 //Description : Header file for class VgaBuffer, Direct Draw Buffer.
00003 
00004 #ifndef __VGABUF_H
00005 #define __VGABUF_H
00006 
00007 #include <IMGFUN.H>
00008 #include <DDRAW.H>
00009 
00010 //-------- Define class VgaBuf ----------------//
00011 
00012 class File;
00013 class Bitmap;
00014 class BitmapW;
00015 
00017 class VgaBuf {
00018 public:
00019     LPDIRECTDRAWSURFACE4  dd_buf;
00020     DDSURFACEDESC2      buf_des;
00021     BOOL            buf_locked;                   // whether the and back buffers have been locked or not.
00022     short*         cur_buf_ptr;
00023     char            is_front;                     // whether it's the front buffer or not
00024 
00025     // ------- temp_unlock --------- //
00026     // char                                             save_locked_flag;
00027     UCHAR           lock_stack_count;
00028     WORD            lock_bit_stack;
00029 
00030     //--------- back buffer ----------//
00031 
00032     short* buf_ptr()          { return cur_buf_ptr; }
00033     short* buf_ptr(int x, int y)  { return (short *)((char *)cur_buf_ptr + buf_des.lPitch*y) + x; }
00034 
00035     // pitch in pixel
00036     int   buf_pitch() {                           // in no. of pixel
00037         return buf_des.lPitch >> 1;
00038     }
00039 
00040     // pitch in byte
00041     int   buf_true_pitch()      { return buf_des.lPitch; }
00042 
00043     int buf_size()          { return buf_des.dwWidth * buf_des.dwHeight * sizeof(short); }
00044     int   buf_width()         { return buf_des.dwWidth; }
00045     int   buf_height()            { return buf_des.dwHeight; }
00046 
00047     //---- GUI colors -----//
00048 
00049     static short color_scheme;                    // color scheme, set by set_color()
00050 
00051     static char color_light;                      // color of the light panel side
00052     static char color_dark;                       // color of the dark panel side
00053     static char color_up;                         // color of up_panel surface
00054     static char color_down;                       // color of down_panel surface
00055     static char color_push;                       // color of pushed button surface
00056     static char color_border;                     // color of color
00057 
00058     static short *default_remap_table;            // new for 16-bit
00059 
00060 public:
00061     VgaBuf();
00062     ~VgaBuf();
00063 
00064     //---------- system functions ----------//
00065 
00066     void    init_front(LPDIRECTDRAW4 ddPtr);
00067     void    init_back(LPDIRECTDRAW4 ddPtr, DWORD =0, DWORD =0);
00068     void    deinit();
00069 
00070     void    set_color(int colorScheme);
00071 
00072     BOOL    is_buf_lost();
00073     BOOL    restore_buf();
00074 
00075     void    activate_pal(LPDIRECTDRAWPALETTE ddPalPtr);
00076     DWORD   color_match(COLORREF rgb);
00077 
00078     void    lock_buf();
00079     void    unlock_buf();
00080 
00081     void    temp_unlock();
00082     void    temp_restore_lock();
00083     void    temp_lock();
00084     void    temp_restore_unlock();
00085 
00086     void    set_buf_ptr(short* bufPtr)  { cur_buf_ptr = bufPtr; }
00087     void    set_default_buf_ptr()   { cur_buf_ptr = (short*)buf_des.lpSurface; }
00088 
00089     int     write_bmp_file(char* fileName);
00090     int     write_bmp_file_area(char* fileName, int x1, int y1, int x2, int y2);
00091 
00092     //---------- painting functions ----------//
00093 
00094     static int  translate_color(unsigned char c)  // calc 8-bit color to 16-bit color // new for 16 bit
00095         { return default_remap_table[c]; }
00096 
00097     void    bar(int x1,int y1,int x2,int y2,int colorCode);
00098     void    bar_fast(int x1,int y1,int x2,int y2,int colorCode)
00099         {   IMGbar(buf_ptr(), buf_true_pitch(), x1, y1, x2, y2, translate_color(colorCode)); }
00100     void    barW_fast(int x1,int y1,int x2,int y2,int colorCode)
00101         { IMGbar(buf_ptr(), buf_true_pitch(), x1, y1, x2, y2, colorCode); }
00102 
00103     void    bar_up(int x1,int y1,int x2,int y2)   { bar( x1, y1, x2, y2, color_up); }
00104     void    bar_down(int x1,int y1,int x2,int y2)   { bar( x1, y1, x2, y2, color_down); }
00105 
00106     void    draw_pixel(int x1,int y1,int colorCode)
00107         { *(buf_ptr()+buf_pitch()*y1+x1) = translate_color(colorCode); }
00108 
00109     void    separator(int,int,int,int);
00110     void    line(int x1,int y1,int x2,int y2,int colorCode);
00111     void    thick_line(int x1,int y1,int x2,int y2,int colorCode);
00112 
00113     void    indicator(int,int,int,int,float,float,int,int= -1);
00114     void    indicator(int barType, int x,int y,float,float,int colorScheme);
00115     void    v_indicator(int,int,int,int,float,float,int,int= -1);
00116 
00117     void    rect(int,int,int,int,int,int);
00118     void    d3_rect(int,int,int,int);
00119 
00120     void    d3_panel_up(int,int,int,int,int=2,int=1, char* =0);
00121     void    d3_panel_down(int,int,int,int,int=2,int=1, char* =0);
00122     void    d3_panel_up_clear(int,int,int,int,int=2, char* =0);
00123     void    d3_panel_down_clear(int,int,int,int,int=2, char* =0);
00124 
00125     void    tile(int,int,int,int,char*);
00126     void    adjust_brightness(int x1,int y1,int x2,int y2,int adjustDegree);
00127     void    draw_d3_up_border(int x1,int y1,int x2,int y2);
00128     void    draw_d3_down_border(int x1,int y1,int x2,int y2);
00129 
00130     void    convert_gray(int x1, int y1, int x2, int y2);
00131 
00132     //-------- buffer saving functions --------//
00133 
00134     short*  save_area(int,int,int,int,short* =0L);
00135     // void     rest_area(char*,int=1 );
00136     void    rest_area(short*,int=1,int=0 );
00137     void    rest_area_with_clipping(short*,int,int,int,int,int=1,int=0 );
00138 
00139     void    save_area_common_buf(int,int,int,int);
00140     void    rest_area_common_buf();
00141 
00142     //------- large bitmap displaying functions -------//
00143 
00144     void    put_large_bitmap(int x1, int y1, File* filePtr, short *colorRemapTable=0);
00145     void    put_large_bitmapW(int x1, int y1, File* filePtr);
00146 
00147     //---------- assembly bitmap manipulation functions ----------//
00148 
00149     // 8->16 blt
00150 
00151     void    put_bitmap(int x,int y,char* bitmapBuf);
00152 
00153     void    put_bitmap_hmirror( int x, int y, char *bitmapBuf )
00154         { IMGbltRemapHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, default_remap_table ); }
00155 
00156     void    put_bitmap_area(int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2 )
00157         { IMGbltAreaRemap( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, default_remap_table ); }
00158 
00159     void    put_bitmap_area_hmirror( int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2)
00160         { IMGbltAreaRemapHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, default_remap_table ); }
00161 
00162     void    put_bitmap_remap(int desX, int desY, char* bitmapBuf, short *colorRemapTable);
00163     void    put_bitmap_remap_fast( int x, int y, char *bitmapBuf, short *colorRemapTable )
00164         { IMGbltRemap( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, colorRemapTable ); }
00165 
00166     void    put_bitmap_remap_hmirror( int x, int y, char *bitmapBuf, short *colorRemapTable )
00167         { IMGbltRemapHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, colorRemapTable ); }
00168 
00169     void    put_bitmap_area_remap(int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2, short *colorRemapTable )
00170         { IMGbltAreaRemap( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, colorRemapTable ); }
00171 
00172     void    put_bitmap_area_remap_hmirror( int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2, short *colorRemapTable)
00173         { IMGbltAreaRemapHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, colorRemapTable ); }
00174 
00175     // functions with transparent color keying
00176 
00177     void    put_bitmap_trans(int x,int y,char* bitmapBuf);
00178 
00179     void    put_bitmap_trans_fast(int x,int y,char* bitmapBuf)
00180         { IMGbltTransRemap( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, default_remap_table ); }
00181 
00182     void    put_bitmap_trans_hmirror( int x, int y, char *bitmapBuf )
00183         { IMGbltTransRemapHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, default_remap_table ); }
00184 
00185     void    put_bitmap_area_trans( int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2 )
00186         { IMGbltAreaTransRemap( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, default_remap_table ); }
00187 
00188     void    put_bitmap_area_trans_hmirror( int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2 )
00189         { IMGbltAreaTransRemapHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, default_remap_table ); }
00190 
00191     void    put_bitmap_trans_remap( int x, int y, char *bitmapBuf, short *colorRemapTable )
00192         { IMGbltTransRemap( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, colorRemapTable ); }
00193 
00194     void    put_bitmap_trans_remap_hmirror( int x, int y, char *bitmapBuf, short *colorRemapTable )
00195         { IMGbltTransRemapHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, colorRemapTable ); }
00196 
00197     void    put_bitmap_area_trans_remap( int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2, short *colorRemapTable )
00198         { IMGbltAreaTransRemap( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, colorRemapTable ); }
00199 
00200     void    put_bitmap_area_trans_remap_hmirror( int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2, short *colorRemapTable)
00201         { IMGbltAreaTransRemapHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, colorRemapTable ); }
00202 
00203     // functions with run-length transparent key decompression
00204 
00205     void    put_bitmap_trans_decompress( int x, int y, char *bitmapBuf )
00206         { IMGbltTransRemapDecompress( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, default_remap_table ); }
00207 
00208     void    put_bitmap_trans_decompress_hmirror( int x, int y, char *bitmapBuf )
00209         { IMGbltTransRemapDecompressHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, default_remap_table ); }
00210 
00211     void    put_bitmap_area_trans_decompress( int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2 )
00212         { IMGbltAreaTransRemapDecompress( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, default_remap_table ); }
00213 
00214     void    put_bitmap_area_trans_decompress_hmirror( int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2 )
00215         { IMGbltAreaTransRemapDecompressHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, default_remap_table ); }
00216 
00217     void    put_bitmap_trans_remap_decompress( int x, int y, char *bitmapBuf, short *colorRemapTable)
00218         { IMGbltTransRemapDecompress( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, colorRemapTable ); }
00219 
00220     void    put_bitmap_trans_remap_decompress_hmirror( int x, int y, char *bitmapBuf, short *colorRemapTable)
00221         { IMGbltTransRemapDecompressHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, colorRemapTable ); }
00222 
00223     void    put_bitmap_area_trans_remap_decompress( int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2, short *colorRemapTable)
00224         { IMGbltAreaTransRemapDecompress( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, colorRemapTable ); }
00225 
00226     void    put_bitmap_area_trans_remap_decompress_hmirror( int x, int y, char *bitmapBuf, int srcX1, int srcY1, int srcX2, int srcY2, short *colorRemapTable)
00227         { IMGbltAreaTransRemapDecompressHMirror( buf_ptr(), buf_true_pitch(), x, y, bitmapBuf, srcX1, srcY1, srcX2, srcY2, colorRemapTable ); }
00228 
00229     // 16->16 blt
00230 
00231     void    read_bitmapW(int x1,int y1,int x2,int y2, short* bitmapWBuf)
00232         { IMGreadW(buf_ptr(), buf_true_pitch(), x1, y1, x2, y2, bitmapWBuf); }
00233     void    read_bitmapW(int x1,int y1,int x2,int y2, BitmapW* bitmapWBuf)
00234         { IMGreadW(buf_ptr(), buf_true_pitch(), x1, y1, x2, y2, (short *)bitmapWBuf); }
00235 
00236     void    put_bitmapW(int x, int y, short *bitmapWBuf )
00237         { IMGbltW( buf_ptr(), buf_true_pitch(), x, y, bitmapWBuf ); }
00238     void    put_bitmapW(int x, int y, BitmapW *bitmapWBuf )
00239         { IMGbltW( buf_ptr(), buf_true_pitch(), x, y, (short *)bitmapWBuf ); }
00240 
00241     void    put_bitmapW_area( int x, int y, short *bitmapWBuf, int srcX1, int srcY1, int srcX2, int srcY2 )
00242         { IMGbltWArea( buf_ptr(), buf_true_pitch(), x, y, bitmapWBuf, srcX1, srcY1, srcX2, srcY2 ); }
00243     void    put_bitmapW_area( int x, int y, BitmapW *bitmapWBuf, int srcX1, int srcY1, int srcX2, int srcY2 )
00244         { IMGbltWArea( buf_ptr(), buf_true_pitch(), x, y, (short *)bitmapWBuf, srcX1, srcY1, srcX2, srcY2 ); }
00245 
00246     // functions with transparent color keying
00247 
00248     void    put_bitmapW_trans( int x, int y, short *bitmapWBuf )
00249         { IMGbltWTrans( buf_ptr(), buf_true_pitch(), x, y, bitmapWBuf ); }
00250     void    put_bitmapW_trans( int x, int y, BitmapW *bitmapWBuf )
00251         { IMGbltWTrans( buf_ptr(), buf_true_pitch(), x, y, (short *)bitmapWBuf ); }
00252 
00253     void    put_bitmapW_area_trans( int x, int y, short *bitmapWBuf, int srcX1, int srcY1, int srcX2, int srcY2 )
00254         { IMGbltWAreaTrans( buf_ptr(), buf_true_pitch(), x, y, bitmapWBuf, srcX1, srcY1, srcX2, srcY2 ); }
00255     void    put_bitmapW_area_trans( int x, int y, BitmapW *bitmapWBuf, int srcX1, int srcY1, int srcX2, int srcY2 )
00256         { IMGbltWAreaTrans( buf_ptr(), buf_true_pitch(), x, y, (short *)bitmapWBuf, srcX1, srcY1, srcX2, srcY2 ); }
00257 
00258     // --------- VgaBuf to VgaBuf copy ------------ //
00259 
00260     void    blt_buf( VgaBuf *srcBuf, int x1, int y1 );
00261     // put whole srcBuf at (x1, y1) of this Vgabuf
00262 
00263     void    blt_buf_fast( VgaBuf *srcBuf, int srcX1, int srcY1, int srcX2, int srcY2)
00264         { IMGcopyW( buf_ptr(), buf_true_pitch(), srcBuf->buf_ptr(), srcBuf->buf_true_pitch(), srcX1, srcY1, srcX2, srcY2); }
00265     // cut (srcX1,srcY1)-(srcX2,srcY2) of srcBuf and put at (srcX1,srcY1) of this VgaBuf
00266 
00267     void    blt_buf_bright( VgaBuf *srcBuf, int srcX1, int srcY1, int srcX2, int srcY2, int brightness);
00268 
00269     void    join_trans_remap( VgaBuf *srcBuf, int x, int y, char *bitmapBuf, short *colorRemapTable)
00270         { IMGjoinTransRemap( buf_ptr(), buf_true_pitch(), srcBuf->buf_ptr(), srcBuf->buf_true_pitch(), x, y, bitmapBuf, colorRemapTable ); }
00271 
00272     void    join_trans( VgaBuf *srcBuf, int x, int y, char *bitmapBuf )
00273         { IMGjoinTransRemap( buf_ptr(), buf_true_pitch(), srcBuf->buf_ptr(), srcBuf->buf_true_pitch(), x, y, bitmapBuf, default_remap_table ); }
00274 };
00275 
00276 extern VgaBuf vga_front, vga_back, vga_true_front;
00277 
00278 //--------------------------------------------//
00279 #endif

Generated on Fri Aug 23 01:38:34 2002 for VirtualU by doxygen1.2.17