Bitmap Flipping
Version 1.0By Miget man12December 11, 2009IntroductionI'm using this for another script I'm making and I figured I may as well post it
FeaturesFlip bitmaps up/down or left/right.
ScriptCODE
# 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
CustomizationNone.
CompatibilityI would be extremely surprised if there were any compatibility issues.
InstallationPut in script editor.
FAQUm I dunno? It's not useful unless you're using it in a script though.
Terms and ConditionsCredits! (whether it's being used in a script or a game or whatever

)
CreditsMiget man12
~Miget man12