From: "Chris A. Triebel" Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro won't display more than 1 PCX (properly)!!! Date: Mon, 27 Jan 1997 10:03:51 -0500 Organization: University of New Hampshire - Durham, NH Lines: 56 Message-ID: References: <5ce17t$68h AT news DOT interlog DOT com> <19970125 DOT 193413 DOT 4975 DOT 2 DOT chambersb AT juno DOT com> NNTP-Posting-Host: sun4.iol.unh.edu Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: <19970125.193413.4975.2.chambersb@juno.com> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp On Sun, 26 Jan 1997, Benjamin D Chambers wrote: > Date: Sun, 26 JAN 1997 03:33:36 GMT > From: Benjamin D Chambers > To: djgpp AT delorie DOT com > Newgroups: comp.os.msdos.djgpp > Subject: Re: Allegro won't display more than 1 PCX (properly)!!! > > > On 25 Jan 1997 22:25:01 GMT "Gautam N. Lad" writes: > >Hi, > >Ok, since I don't know how to display PCX images, I had to resort > >to Allegro (which I think is amazing, and I look forward to the > >new version which includes some 3D goodies!!). > > > >I modified the example EX15.C source to display two different PCXs. > >So, here's the code. Now what I don't understand is why > >does Allegro use one palette to display an image, and when another > >palette is created for another image, that original palette > >gets screwed up, and starts using the palette from the new palette. > >Are ya confused? Look at the source; it might be easier. > > > >In this program, two PCX images are loaded (I could've used a for > >loop, but I wanted to make sure it works. Oh well.) > > Of course it uses the new palette - you called setpalette on the new > palette. > You only have 256 colors to use, and when you change them, _everything_ > on the screen uses the new 256 colors. > > ..Chambers You can try to merge the two palletes. In many cases colors are redundant. Simply pick a pallete, start going through the other pallete looking for matching colors. One one is found you scan through the image associated with the first pallete searching the color that you wish to change and replace it. WARNING: This doesn't come without a trick. The above text is just the simple case. You now need a mechanism for identifying which is an original color, and which is a replaced color. quick example: ( hope the wild syntax helps more than hurts. A ! reps a color, # reps a pallete, and @ reps an image ) You have found the color !2 of pallete #2 matches color !1 of pallete #1. You replace color #1 in image @1 with color !2. You continue scanning and find the color !3 of pallete #2 matches color !2 of pallete #1. You begin scanning image @1 and replace all occurances of color !2 with color !3. ... See the problem? A simple ( slow ) solution is to rebuild the image elsewhere. Use the original untouched and simply copy it into the new image as you go. cat