Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Greyscaling an image?

Heya, I'm scripting a skill casting system that shows icons for each skill. I want, any time a skill is disabled, for the icon to show up as greyscale. Now I could do this in Fireworks myself, but then I'd have hundreds of needless icons. I wondered if there's already a method in RGSS to greyscale images?
 
If your icons are RPG::Sprites, you can use the tone attribute and set it to whatever you want, exactly like the screen tone, using the Tone object (Tone.new(reg, green, blue, grey))
If your icons are Bitmaps, then there is no built-in function that let you change its tone. However, I think Link T and/or Seph and/or Trickster did something like that a while back. Take a look at MACL2.0+, I'm sure you can find something in there! :)
 
it's actually pretty easy.
Code:
for x in 0...bitmap.width
  for y in 0...bitmap.height
    color = bitmap.get_pixel(x, y)
    luma = color.red * 0.3 + color.green * 0.59 + color.blue * 0.11
    bitmap.set_pixel(x, y, Color.new(luma, luma, luma))
  end
end

hope it helps.  :thumb:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top