Bitmap FlippingVersion: 1.0Author: Miget man12Date: December 11, 2009Version History
- Version 1.0 12.11.2009 First version
Planned Future Versions
Description
I'm using this for another script I'm making and I figured I may as well post it
It flips bitmaps.
Features
- Flip bitmaps up to down
- Flip bitmaps left to right
Instructions Paste in editor. THIS IS A SCRIPTER'S TOOL!
Script
# Credits to Miget man12!
# To flip a bitmap left to right, call:
# bitmap.flip_lr
# To flip a bitmap up to down, call:
# bitmap.flip_ud
class Bitmap
def flip_lr # Flip Left/Right
stored_red = Table.new(self.width,self.height)
stored_grn = Table.new(self.width,self.height)
stored_blu = Table.new(self.width,self.height)
stored_alp = Table.new(self.width,self.height)
for y in 0..(self.height)
for x in 0..(self.width)
stored_red[x,y]=self.get_pixel(x,y).red
stored_grn[x,y]=self.get_pixel(x,y).green
stored_blu[x,y]=self.get_pixel(x,y).blue
stored_alp[x,y]=self.get_pixel(x,y).alpha
end
end
for y in 0..(self.height-1)
for x in 0..(self.width-1)
next if stored_red[self.width-x,y].nil? or stored_grn[self.width-x,y].nil? or stored_blu[self.width-x,y].nil? or stored_alp[self.width-x,y].nil?
self.set_pixel(x,y,Color.new(stored_red[self.width-x,y],stored_grn[self.width-x,y],stored_blu[self.width-x,y],stored_alp[self.width-x,y]))
end
end
end
def flip_ud # Flip Up/Down
stored_red = Table.new(self.width,self.height)
stored_grn = Table.new(self.width,self.height)
stored_blu = Table.new(self.width,self.height)
stored_alp = Table.new(self.width,self.height)
for y in 0..(self.height)
for x in 0..(self.width)
stored_red[x,y]=self.get_pixel(x,y).red
stored_grn[x,y]=self.get_pixel(x,y).green
stored_blu[x,y]=self.get_pixel(x,y).blue
stored_alp[x,y]=self.get_pixel(x,y).alpha
end
end
for y in 0..(self.height)
for x in 0..(self.width)
next if stored_red[x,y].nil? or stored_grn[x,self.height-y].nil? or stored_blu[x,self.height-y].nil? or stored_alp[x,self.height-y].nil?
self.set_pixel(x,y,Color.new(stored_red[x,self.height-y],stored_grn[x,self.height-y],stored_blu[x,self.height-y],stored_alp[x,self.height-y]))
end
end
end
end
Credit
Support
I'd very much prefer contact on this topic
Known Compatibility Issues
I can't fathom any sort of compatibility issues this could have.
Author's Notes
Useless for non-scripters really
~Miget man12