From: varobert AT colba DOT net Message-Id: <3.0.32.19990715123307.007add30@mail.colba.net> X-Sender: varobert AT mail DOT colba DOT net X-Mailer: Windows Eudora Pro Version 3.0 (32) Date: Thu, 15 Jul 1999 12:33:08 -0400 To: djgpp AT delorie DOT com Subject: Re: Allegro shading, once again I'm lost Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Reply-To: djgpp AT delorie DOT com It depends: if your bitmaps are all 256 colors on disk, you can load them as 256 color images like so: set_color_depth(16); get_gfx_mode(...); //... your code set_color_depth(8); //This will not change screen modes, but rather how Allegro loads images. BITMAP *mybmp = load_bitmap(file); set_color_mode(16); //...more of your code so now you can address them as 8-bit color bitmaps the way you described. Now, if your bitmaps are 16-bit color on disk, then you could do something like that: int k = ((short*)BMP->line[y])[x]; int r = getr(k) * shade / 256, g = getg(k) * shade / 256, b = getb(k) * shade / 256; ((short*)BMP->line[y])[x] = makecol(r,g,b); There are, of course, ways to optimize this (with a look up table for each color component, etc. ). Or, you could always use a 16MB array of [65536][256]... - GodOfWar At 08:58 AM 7/14/99 -0400, you wrote: >First of all, sorry to be posting the (almost) same question, but I'm >still lost... > >Lets say I have a 256-color BMP in 8 bit color mode. So something like >this: > >BMP->line[y][x] > >will return a value between 0-255. So, if I needed, I could use this >value as the subscript for an array, like this: > > >Color = ShadePalette[ BMP->line[y][x] ] [ 0 ] > ^^^^^^^^^^^^^^^ ^ > Color Index Shading Index > >Now for the question... In 16-bit color mode, the BMP->line[y][x] >returns a 16-bit number, which ranges from 0 to 65535. Now, its pretty >hard to have an array that is like this: ShadePalette[65535][255] Its >a little too big! So using it as an array subscript is out of the >question. So, how do I use a LUT for shading in 16-bit color mode? Or >is there another way? > > >Thanx in advance!! > >