RGB blue is... grey?

Started by KamikazeHighland, Sat 28/05/2011 06:09:51

Previous topic - Next topic

KamikazeHighland

Game.GetColorFromRGB(255, 0, 0); is Red, Game.GetColorFromRGB(0, 255, 0); is Green.  Game.GetColorFromRGB(0, 0, 255); is... light grey...?

Game.GetColorFromRGB(0, 0, 100); is some sort of red.

monkey0506

Well see, we can't really help you with that until you tell us what the actual problem is.  :=

Wyz

I guess it has something to do with subtractions.  :=
Life is like an adventure without the pixel hunts.

Gilbert

#3
The problem is that:
1. AGS uses 16-bit colour depth for its colour space;
2. The first 32 colours are actually coming from standard EGA palette and shades of grays for some reason (which should be BLUE for true 16-bit colour space).

So, it's IMPOSSIBLE to set the drawing colour to RGB(0, 0, B) where B is 1 to 31(*8 ) atm, and GetColorFromRGB(R,g,b) just simply returns (R>>4)<<11) + ((g>>4)<<5) + (b>>3)), so this function is technically broken, if you want to get pure blue.

To get blue you need to make a compromise by using colours like (8, 8, 255).

Alternatively, fix this function by using this:
Code: ags
function FixedColourFromRGB(int R, int g, int b){
  int col = Game.GetColorFromRGB(R, g, b);
  if (col<32) col += ((1<<5)+(1<<11));
  return col;
}

Kweepa

This should really be fixed in AGS 4.
Still waiting for Purity of the Surf II

Calin Leafshade

Color Class plz, not an integer.

Color c = Color.FromARGB(R, G, B, A);

KamikazeHighland

Quote from: Calin Leafshade on Sun 29/05/2011 15:32:17
Color Classplease, not an integer.

Color c = Color.FromARGB(R, G, B, A);


Is that an actual thing?  That'd be cool, although I can define alpha in DrawImage.


Anyway, so will using GetColorFromRGB only ever return one of the 65535 colors that can be read with GetPixel?  I ask because while I'm not sure how to make use of Iceboty's code, if the color returned is an integer can that int ever be outside the 32x64x32 color range (i.e. Color_Transparent = -1, white = 65535)?  I'd be wasting my time with GetColorFromRGB if the color could only ever be one of the color codes anyway.

I'm glad you spelled out how GetColorFromRGB works because I've been trying to figure out why it returns different values for green and red whenever I set them to be the same.

I can't get enough of the double bitwise shifts, lol.  8)

Calin Leafshade

I'm afraid thats not a thing no. Just saying thats how it should be done.

monkey0506

#8
Well AGS is actually already defining the type:

Code: ags
struct ColorType {
  char rr,g,b; // should be single "are" :P silly SMF
  char filler;  // $AUTOCOMPLETEIGNORE$
  };


Which is only used for the palette (presently):

Code: ags
import ColorType palette[256];


Without actually perusing the source code, I don't know what the "filler" is used for, and obviously this isn't exactly the same as what Calin was talking about, but I just wanted to point out that this type already exists for use with palette-based games.

I think that the palette isn't really based off of "real" RGB either, but..

Gilbert

The filler is used for padding, so the palette data of each entry starts at a multiple of 4 bytes.

SMF spam blocked by CleanTalk