00001
00002
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
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 ImageRes::ImageRes(char* resFile, int readAll, int useCommonBuf) :
00035 ResourceIdx(resFile, readAll, useCommonBuf) {
00036 }
00037
00038
00039
00040
00041
00042
00043
00044
00045
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
00064
00065
00066
00067
00068
00069
00070
00071
00072 void ImageRes::put_back(int x, int y, char* imageName, int compressFlag) {
00073 char* bitmapPtr = ResourceIdx::read(imageName);
00074
00075
00076
00077
00078
00079
00080
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
00093
00094
00095
00096
00097
00098
00099
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
00118
00119
00120
00121
00122
00123
00124
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
00138
00139
00140
00141
00142
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
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
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 ) {
00178 filePtr->file_seek(filePtr->file_pos() - sizeof(short));
00179 vgaBuf->put_large_bitmap(x, y, filePtr);
00180 }
00181 else {
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
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
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
00214
00215
00216
00217
00218
00219
00220
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
00234
00235
00236
00237
00238
00239
00240
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