Additonal Bitmap Methodsv0.9
By: Untra and Glitchfinder
Introduction
This is a set of additional methods that can be applied to desired bitmaps by scripters to make interesting things happen to them. Most of them are irreversible, but I intend to change this in the future so that the effects are not only reversible, but also so that they can be applied to the course of entire viewports, or the whole screen so as to make unique transitions or screen effects (as well as make battle animations more interesting). The script comes coupled with a .dll file that makes the affect instantaneous, minimizing stress on the game process.
Current Features
I swear to god I'll remake this mountain of spoiler tags. Argh!
Brightens a bitmap by X shades
(image brightened by 64 shades)
Darkens a bitmap by X shades
(image darkened by 64 shades)
Inverts a bitmaps colors
Puts a bitmaps colors into grayscale
Pixelates an image to X by X squares
(image pixelated to 8 by 8 squares)
Randomly scatters an images pixels over X passes (frosting it)
(image frosted over four passes)
Heavily contrasts the bitmap with its surroundings.
Similar to grayscale, but puts greater contrast between blacks, whites and grays.
Embosses the bitmap (still buggy- not all colors are embossed)
Puts the bitmap into a sepia tone.
Sharpens the bitmap.
Softens the bitmap.
Makes two copies of the bitmap, sets them at half transparency and pushes both copies X pixels away from the center on a Y rotation.
Script
There are two versions currently out; v0.9 and v0.5. Version 0.5 has the frost and pixelate methods, while version 0.85 works with a .dll that makes the methods work instantaneously, and comes with many more additional methods. The v1.0 release should have a functional Frost working.
Instructions
Stick right above main, like you know you should.
This script is mostly for more advanced scripters that want to do more complex things with graphics. Its still a tad buggy, and more features will come (if sporadicly.)
FAQ
maybe later.
Compatibility
Not that I know of.
Credits and Thanks
To Glitchfinder, who deserves just as much credit for this as I do.
To the makers of the MACL; that script inspired me to write this
And to Paint.Net, which helped me figure out how to make the Frost and Pixelate methods.
Authors Note
Feel free to ask for some new features. If they're not too complex, I might (try to) add them in.
Terms and Conditions
Licensed under the WTFPL public licence. Click here for more information.
By: Untra and Glitchfinder
Introduction
This is a set of additional methods that can be applied to desired bitmaps by scripters to make interesting things happen to them. Most of them are irreversible, but I intend to change this in the future so that the effects are not only reversible, but also so that they can be applied to the course of entire viewports, or the whole screen so as to make unique transitions or screen effects (as well as make battle animations more interesting). The script comes coupled with a .dll file that makes the affect instantaneous, minimizing stress on the game process.
Current Features
I swear to god I'll remake this mountain of spoiler tags. Argh!

Brightens a bitmap by X shades
(image brightened by 64 shades)

Darkens a bitmap by X shades
(image darkened by 64 shades)

Inverts a bitmaps colors

Puts a bitmaps colors into grayscale

Pixelates an image to X by X squares
(image pixelated to 8 by 8 squares)

Randomly scatters an images pixels over X passes (frosting it)
(image frosted over four passes)

Heavily contrasts the bitmap with its surroundings.

Similar to grayscale, but puts greater contrast between blacks, whites and grays.

Embosses the bitmap (still buggy- not all colors are embossed)

Puts the bitmap into a sepia tone.

Sharpens the bitmap.

Softens the bitmap.

Makes two copies of the bitmap, sets them at half transparency and pushes both copies X pixels away from the center on a Y rotation.
Script
There are two versions currently out; v0.9 and v0.5. Version 0.5 has the frost and pixelate methods, while version 0.85 works with a .dll that makes the methods work instantaneously, and comes with many more additional methods. The v1.0 release should have a functional Frost working.
Code:
#==============================================================================
# ** Additional Bitmap Methods
#------------------------------------------------------------------------------
# By Untra
# 5/5/10
# v0.5
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# * Brighten
#--------------------------------------------------------------------------
def brighten(amount)
for w in 0..(width - 1)
for h in 0..(height - 1)
color = get_pixel(w, h)
set_pixel(w, h, Color.new([color.red + amount, 255].min, [color.green + amount, 255].min, [color.blue + amount, 255].min, color.alpha)) if color.alpha > 0
end
end
return self
end
#--------------------------------------------------------------------------
# * Darken
#--------------------------------------------------------------------------
def darken(amount)
for w in 0...width
for h in 0...height
color = get_pixel(w, h)
set_pixel(w, h, Color.new([color.red - amount, 0].max, [color.green - amount, 0].max, [color.blue - amount, 0].max, color.alpha)) if color.alpha > 0
end
end
return self
end
#--------------------------------------------------------------------------
# * Invert
# WARNING: Inverting colors is especially process consuming, and with
# frequent use can lag a game indefinitely. Use sparringly.
# NOTE: calling an invert color method a second time will bring its colors
# back to normal, assuming you didn't change its colors while in negative.
#--------------------------------------------------------------------------
def invert
for w in 0..(width - 1)
for h in 0..(height - 1)
color = get_pixel(w, h)
set_pixel(w, h, Color.new(255 - color.red, 255 - color.green, 255 - color.blue, color.alpha)) if color.alpha > 0
end
end
return self
end
#--------------------------------------------------------------------------
# * Grayscale
# WARNING: Putting a bitmap into grayscale is process consuming, and cannot
# be undone without recalling the bitmap. Use caution.
# NOTE: calling this method repeatedly has no effect on the bitmap, but will
# still waste processing power. Do not call it repeatedly.
#--------------------------------------------------------------------------
def grayscale
for w in 0...width
for h in 0...height
color = get_pixel(w, h)
a = color.alpha
if a > 0
num = (color.red + color.green + color.blue) / 3
set_pixel(w, h, Color.new(num, num, num, a))
end
end
end
return self
end
#--------------------------------------------------------------------------
# * Pixelate {buggy}
# WARNING: Pixelating a bitmap is process consuming, and cannot be undone.
# NOTE: Funky things happen if you pixelate a bitmap to single pixels (which
# is the original bitmap). Its incredibly process consuming, so the method
# will return nil if you so attempt it.
# NOTE: Pixelateing bitmaps to a larger pixel size is less process consuming.
# for best results, don't pixelate to numbers below four.
# NOTE: This works much better for solid images, due to bugs.
#--------------------------------------------------------------------------
def pixelate(size)
if size <= 1
return nil
else
for w in 0..((width - 1) / size)
w *= size
for h in 0..((height - 1) / size)
h *= size
r, g, b, a = 0, 0, 0, 0
size.times do |i|
color = get_pixel(w, h)
r += color.red ; g += color.green ; b += color.blue ; a += color.alpha
color = get_pixel(w + i, h)
r += color.red ; g += color.green ; b += color.blue ; a += color.alpha
color = get_pixel(w, h + i)
r += color.red ; g += color.green ; b += color.blue ; a += color.alpha
end
fill_rect(w, h, size, size, Color.new( (r / size**2) * Math.sqrt(size), (g / size**2) * Math.sqrt(size), (b / size**2) * Math.sqrt(size), (a / size**2) * Math.sqrt(size)))
end
end
end
end
#--------------------------------------------------------------------------
# * Frost
# WARNING: Frosting a bitmap is process consuming, and cannot be undone.
# NOTE: Frosting a bitmap randomly scatters its pixels. As such, Consistant
# results are impossible to get.
# NOTE: Frosting a bitmap beyond eight won't result in a more scattered image.
#--------------------------------------------------------------------------
def frost(passes)
for pass in 1..passes
for w in 0...width
for h in 0...height
set_pixel(w, h, get_pixel(w + rand(3) - 1, h + rand(3) - 1))
end
end
end
return self
end
end
Version v0.9
http://www.box.net/shared/9m54d8hkzu
http://www.box.net/shared/9m54d8hkzu
Code:
#==============================================================================
# ** Additional Bitmap Methods
#------------------------------------------------------------------------------
# By Untra and Glitchfinder
# 6/3/10
# v0.9
#==============================================================================
class Bitmap
#------------------------------------------------------------------------------
#Make sure you have uabm.dll in your project folder.
#You can get it from (assuming link is not dead):
#http://www.box.net/shared/9m54d8hkzu
#------------------------------------------------------------------------------
Brighten = Win32API.new("uabm.dll", "Brighten", "li", "v")
Darken = Win32API.new("uabm.dll", "Darken", "li", "v")
Invert = Win32API.new("uabm.dll", "Invert", "l", "v")
Grayscale = Win32API.new("uabm.dll", "Grayscale", "l", "v")
Hcontrast = Win32API.new("uabm.dll", "Hcontrast", "l", "v")
Monochrome = Win32API.new("uabm.dll", "Monochrome", "l", "v")
Emboss = Win32API.new("uabm.dll", "Emboss", "l", "v")
Sepia = Win32API.new("uabm.dll", "Sepia", "l", "v")
Sharpen = Win32API.new("uabm.dll", "Sharpen", "l", "v")
Soften = Win32API.new("uabm.dll", "Soften", "l", "v")
#--------------------------------------------------------------------------
# * Brighten (0...255)
#--------------------------------------------------------------------------
def brighten(amount)
Brighten.call(self.__id__, amount)
end
#--------------------------------------------------------------------------
# * Darken (0...255)
#--------------------------------------------------------------------------
def darken(amount)
Darken.call(self.__id__, amount)
end
#--------------------------------------------------------------------------
# * Invert
#--------------------------------------------------------------------------
def invert
Invert.call(self.__id__)
end
#--------------------------------------------------------------------------
# * Grayscale
#--------------------------------------------------------------------------
def grayscale
Grayscale.call(self.__id__)
end
#--------------------------------------------------------------------------
# * Hyper Contrast
#--------------------------------------------------------------------------
def hyper_contrast
Hcontrast.call(self.__id__)
end
#--------------------------------------------------------------------------
# * Monochrome
#--------------------------------------------------------------------------
def monochrome
Monochrome.call(self.__id__)
end
#--------------------------------------------------------------------------
# * Emboss {buggy}
#--------------------------------------------------------------------------
def emboss
Emboss.call(self.__id__)
end
#--------------------------------------------------------------------------
# * Sepia
#--------------------------------------------------------------------------
def sepia
Sepia.call(self.__id__)
end
#--------------------------------------------------------------------------
# * Sharpen {will update with numeric value options}
#--------------------------------------------------------------------------
def sharpen
Sharpen.call(self.__id__)
end
#--------------------------------------------------------------------------
# * Soften {will update with numeric value options}
#--------------------------------------------------------------------------
def soften
Soften.call(self.__id__)
end
end
Instructions
Stick right above main, like you know you should.
This script is mostly for more advanced scripters that want to do more complex things with graphics. Its still a tad buggy, and more features will come (if sporadicly.)
FAQ
maybe later.
Compatibility
Not that I know of.
Credits and Thanks
To Glitchfinder, who deserves just as much credit for this as I do.
To the makers of the MACL; that script inspired me to write this
And to Paint.Net, which helped me figure out how to make the Frost and Pixelate methods.
Authors Note
Feel free to ask for some new features. If they're not too complex, I might (try to) add them in.
Terms and Conditions
Licensed under the WTFPL public licence. Click here for more information.