Colouring Sprites, with greyscaling? *solved*
Colouring Sprites, with greyscaling? *solved*
Hi guys, as far as i've looked i havent been able to find anything to do with grayscale + RGB colouring, has anyone else found a way to do this or did i miss something in the manual/search?
Sorry to be a bother.
Sorry to be a bother.
Last edited by CadeX on Mon Feb 05, 2007 12:27 am, edited 1 time in total.
Pro-Gamer, Programmer, Pro-Grammer
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
please try to explain a bit clearer.
you can plot single dots on a sprite, each with it's own color.
you can use 256col-mode having a palette of colors,
and you can manipulate the colors.
color modes of a screen are the standard ones: 16col, 256col (= 8bit), 16bit,(24bit) 32bit
a gray color is always achieved when each color channel, red green and blue, have the save value.
so, what exacly is what you are looking for?
you can plot single dots on a sprite, each with it's own color.
you can use 256col-mode having a palette of colors,
and you can manipulate the colors.
color modes of a screen are the standard ones: 16col, 256col (= 8bit), 16bit,(24bit) 32bit
a gray color is always achieved when each color channel, red green and blue, have the save value.
so, what exacly is what you are looking for?
oh... and have a nice day.
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
I guess he wants something like this:
Code: Select all
Procedure GraySprite(SpriteNUM.w)
StartDrawing(SpriteOutput(SpriteNUM))
IW = SpriteWidth(SpriteNUM)
IH = SpriteHeight(SpriteNUM)
BufferPitch = DrawingBufferPitch() / SizeOf(LONG)
If IW <> BufferPitch : IW = BufferPitch : EndIf
*pxData.LONG = DrawingBuffer()
For i=1 To (IW * IH)
R = Blue(*pxData\l)
G = Green(*pxData\l)
B = Red(*pxData\l)
Average =(R + G + B)/3
*pxData\l = RGB(Average,Average,Average)
*pxData + 4
Next
StopDrawing()
EndProcedure
InitSprite() : InitKeyboard()
OpenScreen(640,480,32,"untitled")
CreateSprite(0,240,240)
StartDrawing(SpriteOutput(0))
For i=0 To 240-1
CV = (i * 255) / (240-1)
Box(0,i,240,1,RGB(255,CV,0))
Next
StopDrawing()
CopySprite(0,1) : GraySprite(1)
Repeat
ExamineKeyboard()
ClearScreen(0)
DisplaySprite(0,40,50)
DisplaySprite(1,320,50)
FlipBuffers()
Until KeyboardPushed(1)
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
> Why not just say "is there anyway to turn a coloured sprite into a grayscale?"
yep, that's what I meant.
I see no use in covering people with codes who cannot even ask questions....
btw:
@Fluid
(R+G+B)/3 isn't the correct formula, you'll have to take the different lucency of the canals into account....
here is a proc by Olaf from the german forum that uses the correct factors:
yep, that's what I meant.
I see no use in covering people with codes who cannot even ask questions....
btw:
@Fluid
(R+G+B)/3 isn't the correct formula, you'll have to take the different lucency of the canals into account....
here is a proc by Olaf from the german forum that uses the correct factors:
Code: Select all
Global lumared.d=0.299,lumagreen.d=0.587,lumablue.d=0.114
Procedure Luma(color)
y=Int(lumared*Red(color)+lumagreen*Green(color)+lumablue*Blue(color))
ProcedureReturn y
EndProcedure
oh... and have a nice day.
System YIQKaeru Gaman wrote:@Fluid
(R+G+B)/3 isn't the correct formula, you'll have to take the different lucency of the canals into account....
here is a proc by Olaf from the german forum that uses the correct factors:Code: Select all
Global lumared.d=0.299,lumagreen.d=0.587,lumablue.d=0.114 Procedure Luma(color) y=Int(lumared*Red(color)+lumagreen*Green(color)+lumablue*Blue(color)) ProcedureReturn y EndProcedure
Code: Select all
|Y| |0.299 0.587 0.114| |R|
|I| = |0.596 -0.275 -0.321| * |G|
|Q| |0.212 -0.523 -0.311| |B|
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
The french one is YDbDr
Code: Select all
|Y | | 0.299 0.587 0.114| |R|
|Db| = |-0.450 -0.883 1.333| * |G|
|Dr| |-1.333 1.116 0.217| |B|
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/