Homebrew Help with pixel color

  • Thread starter Thread starter Moocow9m
  • Start date Start date
  • Views Views 825
  • Replies Replies 2

Moocow9m

Member
Newcomer
Joined
Dec 29, 2016
Messages
8
Reaction score
0
Trophies
0
Age
27
XP
76
Country
United States
I have this code:

Code:
void drawPixel(int x, int y, u16 color, u8* screen)
{
    int height=240;
    u32 v=((239-y)+x*height) *2;
    screen[v]=color;
    screen[v+1]=color;
    screen[v+2]=color;
}

void drawPixel(int x, int y, u16 r, u16 g, u16 b, u8* screen)
{
    int height=240;
    u32 v=((239-y)+x*height) *2;
    screen[v]=r;
    screen[v+1]=g;
    screen[v+2]=b;
}

However I cannot figure out how colors work. Can anyone give me a table?
 
Last edited by Moocow9m,
Well, there's 16.8 million possible colors (65,536 if you uncomment the one line), so a table seems unlikely.

But it's an intensity of red, green, and blue (the primary colors, yellow is not a primary color). A higher number is more of that color. 0/0/0 is black, 255/255/255 is white, 0/97/0 is dark green, 220/255/0 is a slightly greenish yellow, ...
 
Well, there's 16.8 million possible colors (65,536 if you uncomment the one line), so a table seems unlikely.

But it's an intensity of red, green, and blue (the primary colors, yellow is not a primary color). A higher number is more of that color. 0/0/0 is black, 255/255/255 is white, 0/97/0 is dark green, 220/255/0 is a slightly greenish yellow, ...
Well that commented line i forgot to remove before copying because I could not find a way to implement it. But when I ran a for loop it didn't give many correct color changes...

This code:

Code:
drawPixel(i, ii, 0, 255, 255, gfxGetFramebuffer(GFX_TOP,GFX_LEFT,0,0));
and
Code:
drawPixel(i, ii, 255, gfxGetFramebuffer(GFX_TOP,GFX_LEFT,0,0));

makes white and this code:

Code:
drawPixel(i, ii, 255, 0, 0, gfxGetFramebuffer(GFX_TOP,GFX_LEFT,0,0));
and
Code:
drawPixel(i, ii, 0, gfxGetFramebuffer(GFX_TOP,GFX_LEFT,0,0));

makes black (first one also makes makes a blue line at the bottom).
Can you explain this?
 
Last edited by Moocow9m,

Site & Scene News

Popular threads in this forum