![]() |
|
Palette Color |
Onewing
Member #6,152
August 2005
![]() |
Okay, common question, but I can not for the life of me connect these dots. I'm in 8-bit color depth and I've got a palette of 256 colors. I thought I could use makecol8 to produce one of the palette colors, but maybe I'm doing something wrong. Here, take a look at the following code: for(int h = 0; h < 256 ; h++) { rectfill(buffer, buffer->w/2, h*2, buffer->w, h*2+2, palette_color[h]); get_color(h,test); rectfill(buffer, 0, h*2, buffer->w/2, h*2+2, makecol8(test->r,test->g,test->b)); }
That bit of code produces: The colors on the right are the correct colors from the palette. And lastly, what I ultimately want to do is to be able to pull a pixel from the bitmap and say it is # of the palette. I'm missing something, because all my logic/study has just led me in the circles, after reading (misinterpreting?) the manual for quite some time. [edit] ------------ |
Evert
Member #794
November 2000
![]() |
Quote: And lastly, what I ultimately want to do is to be able to pull a pixel from the bitmap and say it is # of the palette. That's what getpixel does. Am I missing something? Quote: It seems the problem with makecol8 is it doesn't use the vga (0-63) colors like I thought it did. As per the manual, makecol8 takes RGB values in the range 0-255. |
Onewing
Member #6,152
August 2005
![]() |
My bad, must've been a long day. The problem was I believed there was some connection between palettes and using makecol. Quote: That's what getpixel does. Am I missing something? I've been in 32 bit for so long I was used to getpixel pulling a number that was more abstract (don't take me literally here), for lack of better terms. However, logically it makes since considering I'm in 8bit mode now. I was taking it a step at a time, and since I couldn't get makecol to work, I didn't think getpixel would work. So I spent all my time trying to figure out what the difference was there. Quote: As per the manual, makecol8 takes RGB values in the range 0-255. Not so plainly though, nor directly under makecol8. In fact, you have to go to makecol32: manual said: These functions convert colors from a hardware independent form (red, green, and blue values ranging 0-255) into various display dependent pixel formats. And even "these functions" is a little...vague. And maybe I missed it somewhere, but the manual doesn't ever seem to say, "this is how you use those colors you set up in your palette." ------------ |
Evert
Member #794
November 2000
![]() |
Quote: I've been in 32 bit for so long I was used to getpixel pulling a number that was more abstract (don't take me literally here), for lack of better terms. However, logically it makes since considering I'm in 8bit mode now. Well, what it does is give you the colour value. In high/true colour mode, this is an RGB value. In 8 bit mode, the colour is the index in the palette (that's alwo why palette_color[n]=n in 8 bit mode; it's the converted RGB value in high/true colour mode). Quote: Not so plainly though, nor directly under makecol8. In fact, you have to go to makecol32: No I don't: man makecol8 said: makecol8(3) Allegro manual makecol8(3) NAME SYNOPSIS int makecol8(int r, int g, int b); int makecol15(int r, int g, int b); int makecol16(int r, int g, int b); int makecol24(int r, int g, int b); int makecol32(int r, int g, int b); /* 16 bit color version of green. */ RETURN VALUE Or, http://alleg.sourceforge.net/stabledocs/en/alleg012.html#makecol8 Quote: And maybe I missed it somewhere, but the manual doesn't ever seem to say, "this is how you use those colors you set up in your palette." There's nothing to say. It's no different from how you would use a colour in any other colour depth. Maybe I don't understand what you don't understand though... |
Onewing
Member #6,152
August 2005
![]() |
Quote: No I don't: Well, um, you do if you use the manual on a.cc, which is what I've been using. Quote: Maybe I don't understand what you don't understand though... Oh, I'm sure you don't understand most of what I don't understand, which is quite understandable. Anywho, who it all makes sense now and very logically, computer-wise that is. I look back now and I don't even really remember what I was having a problem with. ------------ |
Evert
Member #794
November 2000
![]() |
Quote: Well, um, you do if you use the manual on a.cc, which is what I've been using.
Ah, right! I forgot that the A.cc copy of the manual doesn't deal well with multiple functions grouped together in one heading. |
|