Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Bitmap Flipping~, (scripters' tool)
miget man12
post Dec 11 2009, 07:10 PM
Post #1


Making a Comeback
Group Icon

Group: Revolutionary
Posts: 393
Type: Musician
RM Skill: Intermediate




Bitmap Flipping

Version 1.0
By Miget man12
December 11, 2009


Introduction
I'm using this for another script I'm making and I figured I may as well post it happy.gif

Features
Flip bitmaps up/down or left/right.

Script
[Show/Hide] Teeny script biggrin.gif
CODE
# 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


Customization
None.

Compatibility
I would be extremely surprised if there were any compatibility issues.

Installation
Put in script editor.

FAQ
Um I dunno? It's not useful unless you're using it in a script though.

Terms and Conditions
Credits! (whether it's being used in a script or a game or whatever wink.gif )

Credits
Miget man12

~Miget man12


__________________________
By the way:


I'm bored because it's summer so I decided to drop by for a bit.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st May 2013 - 09:38 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker