From: ludvig Newsgroups: comp.os.msdos.djgpp Subject: Re: 16bpp PutPixel Date: Sun, 24 Aug 1997 04:43:54 +0200 Organization: Grolier Interactive Europe Lines: 72 Message-ID: <33FF9FEA.260C@club-internet.fr> References: <19970816190400 DOT PAA15010 AT ladder02 DOT news DOT aol DOT com> Reply-To: ludvig AT club-internet DOT fr NNTP-Posting-Host: ppp-104-48.villette.club-internet.fr 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 Precedence: bulk Gingko 69 wrote: > > Hi, > > I'm having trouble getting a putpixel function to work in VESA2 16bpp > modes. My program uses 24bpp internal rendering, and so I would appreciate > if someone could post a 24->16bpp converter. Thanks in advance. > > Gingko Hi Ginko. I had the problem that I wanted to draw 16bits images but all my drawing programs could only produce 8 or 24 bits so I wrote a small function that loads a 24bit BMP and converts it to 16. BTW the code is rather old(and written for borland C++ v4.52)) so it might be some stupidities in it, but it works korrectly. Here it is: unsigned char far* Sprite::Load24BmpTo16(char *name) { const block=999; int i,j,han,n,xs,ys; unsigned long size; unsigned bytes; unsigned char bus[1024]; unsigned char far *info; unsigned int r,g,b,ih,il; if(_dos_open(name,O_RDONLY,&han)!=0) return(NULL); // File Not Found else { _dos_read(han,bus,54,&bytes); // Header xs=bus[18]+bus[19]*256; ys=bus[22]+bus[23]*256; size=4+xs*ys*2; if((info=(unsigned char far*)farmalloc(size))==NULL) // Dynamic Mem. Alloc. exit(1); // Not enough memory info[0]=bus[18]; // Width & Height for the Bitmap info[1]=bus[19]; info[2]=bus[22]; info[3]=bus[23]; _dos_read(han,bus,block,&bytes); n=0; for(j=0;j