Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / DBP - Greyscale filter

Author
Message
Captain GerBear
18
Years of Service
User Offline
Joined: 9th Jul 2006
Location:
Posted: 14th Jul 2006 18:48
Hey, I wonder if anyone knows of a way to take colored images in DBP and make them greyscale. I'm working on a game where the goal is addition of colors. If possible I'd like to avoid making greyscale versions of all of my sprites, as there will be a lot of them. I don't need separate sprites to be grey at different times, a full-screen grey effect would be fine. Any ideas?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Jul 2006 19:23
loop through each pixel in the image and rewrite its grey counter part.



Memblocks would be the fastest way. You could use "DOT" and "POINT" commands, but they would be slow and you'd have to reapply the affect whenever the screen refreshes. Whereas changing the image from the memblock can simply give you a whole new image grey-scaled.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 14th Jul 2006 19:38 Edited at: 14th Jul 2006 19:41
greyscale = luminance = (0.3*red) + (0.59*green) + (0.11*blue)

to convert your sprites to greyscale i'd do something like (pseudocode):



i'm sure there are better/faster ways of doing this but this quick and dirty version gives you the idea.

good luck!

Virtual Nomad
Athlon XP1800+, Windows XP+SP2, Soyo K7V Dragon+ MB, 1.5Gb 333 RAM, ATI Radeon 8700LT (128Mb)
Captain GerBear
18
Years of Service
User Offline
Joined: 9th Jul 2006
Location:
Posted: 14th Jul 2006 21:03
I'll try both of these methods, thank you. =)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Jul 2006 22:49
oh yea, i forgot about the eye picking up a color stronger than others.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike

Login to post a reply

Server time is: 2024-11-26 15:43:10
Your offset time is: 2024-11-26 15:43:10