Author Topic: 16bit color could fix things.  (Read 2319 times)

Offline Scott_AW

  • Mr. Polyvector
  • ***
  • Posts: 214
    • View Profile
    • SAW Game Design
16bit color could fix things.
« on: 2010-Nov-01 »
When switching to 16bit color, I found my getpixel command was much more accurate.

I haven't tried other things that have had issue on different systems yet.  Grabsprite tends to work on some computers and not others.

Lately I found my get pixel routine was very off, completely ignoring white against black in some areas.  But switching to 16bit allowed it to properly function.
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/

Offline BlueSteel

  • Mc. Print
  • *
  • Posts: 39
  • Jack of ALL codes .. master of none :(
    • View Profile
    • Coding Monkeys
Re: 16bit color could fix things.
« Reply #1 on: 2010-Nov-01 »
in my younger days as a programmer I too used to read pixels. then i came over to the PC and there was no function to do it.. ie: floating memory / unreliable etc.. so i was taught to use arrays as opposed to reading the screen (which i argues is an array of sorts anyway.. and why should i need to have the same thing in memory again) to which i was told that on modern day OS's that its not a good idea as you data could get corrupted or be stale.. that irs best to stick to use arrays and check them.

So which is it.. has it reverted back to the way i used to do it.. or is it still better practice to use arrays / linked lists etc... rather than using pixels

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 932
  • KodeSource
    • View Profile
    • KodeSource
Re: 16bit color could fix things.
« Reply #2 on: 2010-Nov-01 »
Here's a portion of the 'GETPIXEL()' help file entry:

Quote
Warning: The color returned can differ up to 13% from the actual value for the pixel. 16 bit colored pixels are especially likely to return incorrect information. The reason for this is that some platforms have 16 bit displays - 24 bits of color information is converted down to 16 bits resulting in a loss of accuracy.

It appears as if only 24 bit colour would result in an accurate GETPIXEL() command.
Otherwise, the colour is stored as 24 bit, but down-sized to 16 bit for display.
GETPIXEL() will read this 16 bit colour and convert it back to 24 bit for storing in GLBasic memory.

Perhaps only using "16 bit safe" colours may help, if such a concept makes sense.
ie. what values when converted from 24 to 16 bit, then back again to 24 bit results in the original value.
It would depend on how the colours are converted I guess.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline Scott_AW

  • Mr. Polyvector
  • ***
  • Posts: 214
    • View Profile
    • SAW Game Design
Re: 16bit color could fix things.
« Reply #3 on: 2010-Nov-02 »
I think the problem happens on systems with 32bit color instead of 24bit.

I'd use the sprite2data functions to convert the data to an array but this also doesn't work on all systems.  Although I haven't tried it with different color modes yet.
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/