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

Password:

OIMGRES.CPP Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

OIMGRES.CPP

Go to the documentation of this file.
00001 //Filename    : OIMGES.CPP
00002 //Description : Object ImageRes
00003 
00004 #include <string.h>
00005 
00006 #include <ALL.H>
00007 #include <OVGA.H>
00008 #include <OCOLTBL.H>
00009 #include <OMOUSE.H>
00010 #include <OIMGRES.H>
00011 #include <OIFACE.H>
00012 #include <OBITMAP.H>
00013 
00014 //--------- Format of RES file ------------//
00015 //
00016 // In the resource file, contain many compressed images, each image
00017 // has the following data
00018 //
00019 // <char[8]> = the name of the image
00020 // <int>     = the widht of the image
00021 // <int>     = the height of the image
00022 // <char...> = the bitmap of the image
00023 //
00024 //--------------------------------------------//
00025 
00026 //------- Start of function ImageRes::ImageRes -------//
00027 //
00028 // <char*> resName   = name of the resource file (e.g. "GIF.RES")
00029 // [int]   readAll   = whether read all data into the buffer or read one each time
00030 //                     (default:0)
00031 // [int]   useCommonBuf = whether use the sys common buffer to store the data or not
00032 //                     (default:0)
00033 //
00034 ImageRes::ImageRes(char* resFile, int readAll, int useCommonBuf) :
00035     ResourceIdx(resFile, readAll, useCommonBuf) {
00036 }
00037 
00038 //--------- End of function ImageRes::ImageRes -------//
00039 
00040 //-------- Start of function ImageRes::put_front --------//
00041 //
00042 // int  x,y       = the location of the image
00043 // char* imageName = name of the image
00044 // [int] compressFlag = compress flag
00045 //                                                              (default: 0)
00046 //
00047 void ImageRes::put_front(int x, int y, char* imageName, int compressFlag) {
00048     char* bitmapPtr = ResourceIdx::read(imageName);
00049 
00050     if(!bitmapPtr)
00051         return;
00052 
00053     mouse.hide_area( x, y, x+*((short*)bitmapPtr)-1, y+*(((short*)bitmapPtr)+1)-1 );
00054 
00055     if( compressFlag )
00056         vga_front.put_bitmap_trans_decompress( x, y, bitmapPtr );
00057     else
00058         vga_front.put_bitmap_trans( x, y, bitmapPtr );
00059 
00060     mouse.show_area();
00061 }
00062 
00063 //---------- End of function ImageRes::put_front --------//
00064 
00065 //-------- Start of function ImageRes::put_back --------//
00066 //
00067 // int  x,y       = the location of the image
00068 // char* imageName = name of the image
00069 // [int] compressFlag = compress flag
00070 //                                                              (default: 0)
00071 //
00072 void ImageRes::put_back(int x, int y, char* imageName, int compressFlag) {
00073     char* bitmapPtr = ResourceIdx::read(imageName);
00074 
00075     /*  if(user_interface.backgd_flag==0)
00076         {
00077         if(strcmp(imageName,"QUEST_UP")==0)
00078         {
00079         vga_back.barW_fast(x,y,x+*(short*)bitmapPtr,y+*((short*)bitmapPtr+1)+1,0xFFFF);
00080         return;
00081         }
00082         }
00083     */
00084     if( bitmapPtr ) {
00085         if( compressFlag )
00086             vga_back.put_bitmap_trans_decompress( x, y, bitmapPtr );
00087         else
00088             vga_back.put_bitmap_trans( x, y, bitmapPtr );
00089     }
00090 }
00091 
00092 //---------- End of function ImageRes::put_back --------//
00093 
00094 //-------- Start of function ImageRes::put_front --------//
00095 //
00096 // int x,y      = the location of the image
00097 // int bitmapId = id. of the bitmap
00098 // [int] compressFlag = compress flag
00099 //                                                              (default: 0)
00100 //
00101 void ImageRes::put_front(int x, int y, int bitmapId, int compressFlag) {
00102     char* bitmapPtr = ResourceIdx::get_data(bitmapId);
00103 
00104     if( !bitmapPtr )
00105         return;
00106 
00107     mouse.hide_area( x, y, x+*((short*)bitmapPtr)-1, y+*(((short*)bitmapPtr)+1)-1 );
00108 
00109     if( compressFlag )
00110         vga_front.put_bitmap_trans_decompress( x, y, bitmapPtr );
00111     else
00112         vga_front.put_bitmap_trans( x, y, bitmapPtr );
00113 
00114     mouse.show_area();
00115 }
00116 
00117 //---------- End of function ImageRes::put_front --------//
00118 
00119 //-------- Start of function ImageRes::put_back --------//
00120 //
00121 // int ,y       = the location of the image
00122 // int bitmapId = id. of the bitmap
00123 // [int] compressFlag = compress flag
00124 //                                                              (default: 0)
00125 //
00126 void ImageRes::put_back(int x, int y, int bitmapId, int compressFlag) {
00127     char* bitmapPtr = ResourceIdx::get_data(bitmapId);
00128 
00129     if( bitmapPtr ) {
00130         if( compressFlag )
00131             vga_back.put_bitmap_trans_decompress( x, y, bitmapPtr );
00132         else
00133             vga_back.put_bitmap_trans( x, y, bitmapPtr );
00134     }
00135 }
00136 
00137 //---------- End of function ImageRes::put_back --------//
00138 
00139 //-------- Start of function ImageRes::put_join --------//
00140 //
00141 // int  x,y       = the location of the image
00142 // char* imageName = name of the image
00143 //
00144 void ImageRes::put_join(int x, int y, char* imageName) {
00145     char* bitmapPtr = ResourceIdx::read(imageName);
00146 
00147     if( !bitmapPtr )
00148         return;
00149 
00150     mouse.hide_area( x, y, x+((Bitmap *)bitmapPtr)->get_width()-1, y+((Bitmap *)bitmapPtr)->get_height()-1 );
00151 
00152     if( bitmapPtr )
00153         vga_front.join_trans( &vga_back, x, y, bitmapPtr );
00154 
00155     mouse.show_area();
00156 }
00157 
00158 //---------- End of function ImageRes::put_join --------//
00159 
00160 //-------- Start of function ImageRes::put_large --------//
00161 //
00162 // When a picture file is > 64K, which cannot be read into a single
00163 // memory buffer.
00164 //
00165 // It will call vga.put_pict() which will continously read the file
00166 // and put to the screen until completion.
00167 //
00168 // <VgaBuf*> vgaBuf       = the vga buffer for display
00169 // <int>            x,y       = the location of the image
00170 // <char*>   imageName = name of the image
00171 //
00172 void ImageRes::put_large(VgaBuf* vgaBuf, int x, int y, char* imageName) {
00173     int dataSize;
00174 
00175     File* filePtr = get_file(imageName, dataSize);
00176 
00177     if (filePtr->file_get_short() != -1 ) {         // use common color palette
00178         filePtr->file_seek(filePtr->file_pos() - sizeof(short));
00179         vgaBuf->put_large_bitmap(x, y, filePtr);
00180     }
00181     else {                                          // use own color palette
00182         unsigned char palette[256 * 3];
00183         short *remapTable;
00184         filePtr->file_read(palette, 256 * 3);
00185         PalDesc palDesc(palette, 3, 256, 6);
00186         ColorTable colorTable;
00187         colorTable.generate_table_fast(MAX_BRIGHTNESS_ADJUST_DEGREE, palDesc, ColorTable::bright_func);
00188         remapTable = (short *) colorTable.get_table(0);
00189         vgaBuf->put_large_bitmap(x, y, filePtr, remapTable);
00190     }
00191 }
00192 
00193 //---------- End of function ImageRes::put_large --------//
00194 
00195 //-------- Start of function ImageRes::put_large --------//
00196 //
00197 // When a picture file is > 64K, which cannot be read into a single
00198 // memory buffer.
00199 //
00200 // It will call vga.put_pict() which will continously read the file
00201 // and put to the screen until completion.
00202 //
00203 // <VgaBuf*> vgaBuf       = the vga buffer for display
00204 // <int>            x,y       = the location of the image
00205 // <int>                 bitmapId  = id. of the bitmap in the bitmap resource file.
00206 //
00207 void ImageRes::put_large(VgaBuf* vgaBuf, int x, int y, int bitmapId) {
00208     int dataSize;
00209 
00210     vgaBuf->put_large_bitmap( x, y, ResourceIdx::get_file(bitmapId, dataSize) );
00211 }
00212 
00213 //---------- End of function ImageRes::put_large --------//
00214 
00215 //-------- Start of function ImageRes::put_to_buf --------//
00216 //
00217 // Put the image to the specified Vga buffer.
00218 //
00219 // <VgaBuf*> vgaBufPtr = the pointer to the Vga buffer
00220 // <char*>       imageName = name of the image
00221 //
00222 void ImageRes::put_to_buf(VgaBuf* vgaBufPtr, char* imageName) {
00223     if( read_all ) {
00224         vgaBufPtr->put_bitmap(0, 0, get_ptr(imageName));
00225     }
00226     else {
00227         int dataSize;
00228         File* filePtr = get_file(imageName, dataSize);
00229         vgaBufPtr->put_large_bitmap(0, 0, filePtr);
00230     }
00231 }
00232 
00233 //---------- End of function ImageRes::put_to_buf --------//
00234 
00235 //-------- Start of function ImageRes::put_to_buf --------//
00236 //
00237 // Put the image to the specified Vga buffer.
00238 //
00239 // <VgaBuf*> vgaBufPtr = the pointer to the Vga buffer
00240 // <int>     bitmapId  = id. of the bitmap in the resource file.
00241 //
00242 void ImageRes::put_to_buf(VgaBuf* vgaBufPtr, int bitmapId) {
00243     if( read_all ) {
00244         vgaBufPtr->put_bitmap(0, 0, get_data(bitmapId));
00245     }
00246     else {
00247         int dataSize;
00248         File* filePtr = get_file(bitmapId, dataSize);
00249         vgaBufPtr->put_large_bitmap(0, 0, filePtr);
00250     }
00251 }
00252 
00253 //---------- End of function ImageRes::put_to_buf --------//

Generated on Fri Aug 23 01:37:59 2002 for VirtualU by doxygen1.2.17