Bitmap tinting

● ARCHIVED · READ-ONLY
Started by Tsukihime 7 posts View original ↗
  1. Is there a script that I can use that will allow me to change the tint of a bitmap?


    For example, say I want to make an image redder or darker.


    This is typically accomplished by manipulating pixel colors, so if I wanted to make an image redder (to simulate a sunset type of effect, sort of), I would just add more red to each pixel.


    I'm basically going to be providing an add-on that allows users to create map shots with the "screen tint" options applied.
  2. I don't think there is a script for this, other than maybe Copern's Color Functions via his dll..but perhaps you've already figured out your own dilemma my friend :p


    Manipulating a Bitmap is essentially manipulating the pixels underneath the structure; unfortunately in Ruby this is slower, but still possible. You can try your hand at writing a dll to make the function considerably faster, or just brute force it out with (get / set)_pixel.


    Perhaps you could create a bitmap the size of the map and then use fill_rect with the tint color, and blt the bitmap onto the one you are saving? I -think- that would be faster than iterating through each pixel, but idk...and I'm not sure exactly how accurate that is when compared to the each_pixel method.
  3. FenixFyreX said:
    I don't think there is a script for this, other than maybe Copern's Color Functions via his dll..but perhaps you've already figured out your own dilemma my friend :p


    Manipulating a Bitmap is essentially manipulating the pixels underneath the structure; unfortunately in Ruby this is slower, but still possible. You can try your hand at writing a dll to make the function considerably faster, or just brute force it out with (get / set)_pixel.


    Perhaps you could create a bitmap the size of the map and then use fill_rect with the tint color, and blt the bitmap onto the one you are saving? I -think- that would be faster than iterating through each pixel, but idk...and I'm not sure exactly how accurate that is when compared to the each_pixel method.
    That's pretty creative.


    I tried creating a huge red rectangle and then blt'd it over my image with a given opacity.


    Though, the end result wasn't too attractive.


    I guess I'd have to throw a dll at it and do actual pixel manipulations following the tinting algorithm.
  4. If you don't want to do write it by yourself, I already wrote some of the Sprite “effects” like tone or color for bitmaps.


    See the attachment for the tone effect(s). Feel free to do whatever you want with it. I've extracted it from a larger source code and rewrote some stuff (mainly reordering some code and removing SSE2 intrinsics), so even though it's a bit slower now, it's also more readable and portable.


    (Actually, I think RGSS3 requires SSE or even SSE2. Maybe I should check that and add them again.)

    Project21.zip
  5. Nice cremno, that looks neat!


    @Tsuki, I remembered two ways of writing a dll in RGSS, the first is this: RGSSX Bitmap Functions


    The second is this: Wanabe's LoadSo


    The second one is more powerful (it's re-implementing the ability to load ruby extensions) and is most likely the source cremno used (or an iteration thereof, it simply is a 'rehash' of the ruby headers and part of it's source), but not 100% complete yet. The first one is more specifically for just adding in your own custom for-rpgmaker-only written-in-visual-studio dll. Hope that helps.
  6. FenixFyreX said:
    Nice cremno, that looks neat!
    Thanks. Its results are almost identical to the RGSS sprite tone effect. If anyone finds some (actually relevant) differences, send me a PM.

    FenixFyreX said:
    is most likely the source cremno used
    No, I haven't used anything of it. It's partially based on poccil's struct definitions. You can look at the source code as it's included.