设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 170|回复: 0

[转载发布] Copern's Bitmap Color Functions

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-7-16 16:23:56 | 显示全部楼层 |阅读模式
    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:       
    1. 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:       
    1. 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:       
    1. [/code]
    2. Now we end up with this.
    3. [IMG]http://i.imgur.com/18g5u.png[/IMG]
    4. How about something really bizzare this time.
    5. Spoilercolor_levels = Color_Levels.new
    6. greens = {85 => 140, 165 => 140, 185 => 50, 255 => 50}
    7. values = {0 => 170, 60 => 170, 145 => 50, 200 => 130, 255 => 130}
    8. color_levels.set_points
    9. green, greens)
    10. color_levels.set_points
    11. value, values)
    12. bitmap.set_levels!(color_levels)
    13.                 Code:       
    14. [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/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 13:06 , Processed in 0.136453 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表