/*** ** ** Sample Code Bitmap Displayer ** ** Please check this file before downloading to determine what will you need ** for this file to work. ** Please read the disclaimer before using this code. ** ** This file has to be compiled with SVGALIB System from a project file. ** SVGALIB.LIB is contained SVGACC25.ZIP ** Please check these files in the C MS-DOS archives in SimTelnet or Garbo. ** ** Do copy the "svgacc.h" and "svgademo.h" into your c compiler "include" directory ** ** if you want to use another VGA system. Please change ** all the function referal to SVGALIB system to your own. ** But just make sure the VGA system displays 256 color for you ** to access 256 color bitmap. ** ** You have to use project file, in order to access the library ** function in svgalib.lib. Please read your compiler ** documentation for using project file. ** ** Ahmad Hafiz: ** http://www.geocities.com/SiliconValley/Vista/2459 ** cobra_ayaq@hotmail.com ** ** Please set TAB to 2 (in your c editor, for the text to aligned properly) ** ****/ #include #include #include /* i'm using a SVGALIB VGA system */ #include typedef unsigned char BYTE; typedef unsigned int UINT; typedef unsigned long DWORD; typedef unsigned int WORD; typedef signed long LONG; typedef struct tagBITMAPFILEHEADER { /* bmfh */ UINT bfType; DWORD bfSize; UINT bfReserved1; UINT bfReserved2; DWORD bfOffBits; } BITMAPFILEHEADER; typedef struct tagBITMAPINFOHEADER { /* bmih */ DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes; WORD biBitCount; DWORD biCompression; DWORD biSizeImage; LONG biXPelsPerMeter; LONG biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant; } BITMAPINFOHEADER; unsigned getbits(unsigned x, int p, int n) { return(x>>(p+1-n)) & ~(~0<bitmap filetodisplay.bmp" ** or from your compiler set the argument to be filetodisplay.bmp ** ***/ int main(int argc, char **argv) { FILE *fp; BITMAPFILEHEADER bmfh={0}; BITMAPINFOHEADER bmih={0}; DWORD index; BYTE ch; int startvmode; int bmpcolour; int y,x,q,i=0,j=0; PaletteData pal3={0}; if(argc==1) return 0; if((fp=fopen(argv[1],"rb"))==NULL) return 0; fread(&bmfh,sizeof(bmfh),1,fp); /* read bitmap file header */ fread(&bmih,sizeof(bmih),1,fp); /* read bitmap info header */ /* determine type of window bitmaps */ if(bmih.biBitCount==8) bmpcolour=256; if(bmih.biBitCount==4) bmpcolour=16; if(bmih.biBitCount==1) bmpcolour=2; /* * * * * * * * * * * * * * * * * * read the palette information from MSB b,g,r,i (i=ignore) * * * * * * * * * * * * * * * * * * */ for(index=0;index> 2; pal3[index].g = fgetc(fp) >> 2; pal3[index].r = fgetc(fp) >> 2; fgetc(fp); } startvmode=videomodeget(); /* save video mode - svgalib system */ whichvga(); /* determine which vga - svgalib system */ res320(); /* resolution - svgalib system */ palset(pal3,0,bmpcolour-1); /* setting palette for VGA 256 colour - svgalib system */ /* please note that drwpoint is a SVGALIB VGA system */ switch (bmpcolour){ case 256: /* draw 256 colour bitmap */ /* read the bitmap pixel */ for(y=0,index=0; index<=bmih.biSizeImage-bmih.biWidth; index+=(bmih.biWidth+1),y--) { for(x=0,q=0;q