From: sfranke/druid- Newsgroups: comp.os.msdos.djgpp Subject: having trouble w/ bitmaps in vbe2.0 Date: Thu, 26 Sep 1996 22:45:49 -0600 Organization: Adhesive Media, Inc. Lines: 78 Message-ID: <324B5BFD.7CF2@eden.com> NNTP-Posting-Host: net-1-110.santonio.eden.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp I'm having trouble getting a bitmap loaded and displayed w/ vbe2.0 under djgpp. I know this isn't really hard to do (I can do it in real mode assembler ;) ), but I'm just getting started with djgpp... I'm using vbe2.0 linear 640x480x8bit. Most of the code comes from the vbetest.c file. I think the problem may have to do with a misuse of pointers or something. Or maybe I'm loading the file wrong (I'm using the same format and method I used for asm). The palette isn't working right either... I'm not sure.. here's excerpts of what I think is fairly important. I can email/post the full source if you want it - it's just one small file.. any help (even just glancing at this) is very much appreciated :) s.franke/druid- ----------------------------------------------------------- typedef struct { unsigned char r; unsigned char g; unsigned char b; } rgbpal; void drawPic( unsigned char image[65535], unsigned char *vid, int l, int w, int x, int y); void set_palette(int entry,int r,int g,int b) { outportb(0x3c8,(BYTE)entry); outportb(0x3c9,(BYTE)r); outportb(0x3c9,(BYTE)g); outportb(0x3c9,(BYTE)b); } ====IN MAIN==== unsigned char thepic[65535]; unsigned char junk[32]; rgbpal pal[256]; fp = fopen("gfx.raw" , "r" ); fread( junk , 1, 32, fp ); // has a 32 byte header fread( pal , 1, 768 , fp ); // 768 bytes for the palette fread( thepic, 1, 65535, fp ); // a 256 * 256 picture fclose( fp ); for( i=0 ; i<256 ; i++ ) set_palette(i,(int) pal[i].r/4,(int) pal[i].g/4,(int) pal[i].b/4); drawPic(thepic,video,256,256,0,0); ====this is the function for drawing==== void drawPic( unsigned char image[65535], unsigned char *vid, int l, int w, int x, int y) { int picind = 0; int scrind = x * y; int pixcnt = 0; int xoffset = 640 - l; int horiz = 0; unsigned char pixel; while( pixcnt < l * w ) { pixel=image[picind]; vid[scrind]=pixel; scrind++; picind++; pixcnt++; horiz++; if(horiz == l) { horiz=0; scrind+=xoffset; } } return; }