Introduction
This is a DLL with accompanying Ruby script for modifying bitmap colors. It adds a few methods for recoloring bitmaps or changing bitmap color levels.
Features
- Recolor a bitmap maintaining the original brightness.
- Recolor a bitmap with a mask to determine brightness and blending.
- Modify the color levels of a bitmap.
Instructions
SpoilerLet us say our original bitmap is the RPGMaker cloak, blown up for better viewing.
Alright, so let's say we simply want to turn it into an orange color.
Code:
- bitmap.colorify!( Color.new(200, 100, 0, 255) )
复制代码
We'll end up with something like this.
Spoiler
Alright so how about this time we use a mask image and a red color instead. I'll show a variety of different brightness and alpha values for quick demonstration. The transparency layer was made visible for better viewing.
Spoiler
Code:
- bitmap.colorify_masked!( Color.new(200, 50, 50, 255), bitmapmask, false )
复制代码
If your mask image is smaller than the target bitmap, you can tell it to repeat the pattern (false by default). Here's what we end up with.
Spoiler
A value of 128 on the mask is essentially the original brightness. A higher value will make the pixels brighter than the original towards max brightness. A lower value will make the pixels darker than the original towards minimum brightness (black in this case). A value of 0 skips processing of that pixel. The alpha layer does just what you would expect by alpha blending with the original color.
Next up we have the "set levels" function. With this we can modify specific channels and ranges of values as well as the brightness.
Alright let's put a heavy emphasis on green values, tone down the red, nearly drop the blue, and highlight mid values while making higher values darker.
Spoilercolor_levels = Color_Levels.new
color_levels.set_point
blue, 190, 80).set_point
blue, 255, 80)
greens = {100 => 80, 150 => 135, 185 => 255}
reds = {205 => 105, 253 => 140, 255 => 160}
values = {135 => 170, 255 => 140}
color_levels.set_points
green, greens).set_points
red, reds).set_points
value, values)
bitmap.set_levels!(color_levels)
Code:
- [/code]
- Now we end up with this.
- [IMG]http://i.imgur.com/18g5u.png[/IMG]
- How about something really bizzare this time.
- Spoilercolor_levels = Color_Levels.new
- greens = {85 => 140, 165 => 140, 185 => 50, 255 => 50}
- values = {0 => 170, 60 => 170, 145 => 50, 200 => 130, 255 => 130}
- color_levels.set_points
- green, greens)
- color_levels.set_points
- value, values)
- bitmap.set_levels!(color_levels)
- Code:
- [code]
复制代码
Prepare yourself, it's not pretty.
Further instructions can be found in the script comments at the top.
Additional Notes
This should theoretically work for VX and earlier but I do not have a way of testing it. If it doesn't work for VX, please let me know.
Download
DLL Download
http://www.4shared.c...rnbmcolors.html
Script
http://pastebin.com/AHheHtHC
Terms of Use
See script for terms of use.
本贴来自国际rpgmaker官方论坛作者:Copern处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/coperns-bitmap-color-functions.4038/