Код:
	class VX_to_XP
  def initialize(quelle,ziel,type,shutdown=false)
    @quelle = quelle
    @ziel = ziel
 
    # Führe entsprechende Methode aus
    if type == "Characters" then
      load_characters
    elsif type == "Faces" then
      load_faces
    elsif type == "Tile" then
      load_tiles
    elsif type == "Balloon" then
      load_balloon
    elsif type == "Icons" then
      load_icons
    elsif type == "A1" or type == "A2" or type == "A3" or type == "A4" then
      load_autotile(type)
    elsif type == "Bigchar" then
      load_bigchar
    end
 
    # Wenn shutdown true ist, beende das Programm
    if shutdown == true then
      $scene = nil
    end
  end
 
 
  def load_characters
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
    # Speichere original-Bitmap Höhe und Breite
    block_breite = original.bitmap.width / 4
    block_hoehe = original.bitmap.height / 2
 
    # Erstelle neuen Array
    @new_bitmap = Array.new(8)
    for br in 1..4
      for he in [0,1]
 
        # Errechne Additionswert add
        if he == 0
          then add = 0
          else add = 4
        end
 
        #Erstelle neuen Sprite
        @new_bitmap[br+add] = Sprite.new
        #Erstelle neues Bitmap
        @new_bitmap[br+add].bitmap = Bitmap.new(block_breite+(block_breite/3),block_hoehe)
        #Setzte Rect fest
        ausschnitt = Rect.new(((br-1)*block_breite)+(block_breite/3),he*block_hoehe,block_breite/3,block_hoehe)
        #Kopiere Ausschnitt
        @new_bitmap[br+add].bitmap.blt(0,0,original.bitmap,ausschnitt)
        #Setzte Rect fest
        ausschnitt = Rect.new((br-1)*block_breite,he*block_hoehe,block_breite,block_hoehe)
        #Kopiere Ausschnitt
        @new_bitmap[br+add].bitmap.blt(block_breite/3,0,original.bitmap,ausschnitt)
 
      end
    end
    #Lösche den original-Sprite
    original.dispose
    #Speichere die Bitmaps
    for number in 1..8
      @new_bitmap[number].bitmap.make_png("#{@ziel} - #{number}")
      @new_bitmap[number].dispose
    end
  end
 
  def load_tiles
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
    #Erstelle neuen Sprite
    @new_bitmap = Sprite.new
    #Erstelle neues Bitmap
    @new_bitmap.bitmap = Bitmap.new(256,1024)
    #Setzte Rect fest
    ausschnitt = Rect.new(0,0,256,512)
    #Kopiere Ausschnitt
    @new_bitmap.bitmap.blt(0,0,original.bitmap,ausschnitt)
    #Ändere Rect
    ausschnitt.x = 256
    #Kopiere Ausschnitt
    @new_bitmap.bitmap.blt(0,512,original.bitmap,ausschnitt)
    #Lösche den original-Sprite
    original.dispose
    #Speichere die Bitmaps
    @new_bitmap.bitmap.make_png("#{@ziel}")
    @new_bitmap.dispose
  end
 
  def load_faces
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
    # Speichere original-Bitmap Höhe und Breite
    block_breite = original.bitmap.width / 4
    block_hoehe = original.bitmap.height / 2
 
    # Erstelle neuen Array
    @new_bitmap = Array.new(8)
    for br in 1..4
      for he in [0,1]
 
        # Errechne Additionswert add
        if he == 0
          then add = 0
          else add = 4
        end
 
        #Erstelle neuen Sprite
        @new_bitmap[br+add] = Sprite.new
        #Erstelle neues Bitmap
        @new_bitmap[br+add].bitmap = Bitmap.new(block_breite,block_hoehe)
        #Setzte Rect fest
        ausschnitt = Rect.new((br-1)*block_breite,he*block_hoehe,block_breite,block_hoehe)
        #Kopiere Ausschnitt
        @new_bitmap[br+add].bitmap.blt(0,0,original.bitmap,ausschnitt)
 
      end
    end
    #Lösche den original-Sprite
    original.dispose
    #Speichere die Bitmaps
    for number in 1..8
      @new_bitmap[number].bitmap.make_png("#{@ziel} - #{number}")
      @new_bitmap[number].dispose
    end
  end
 
  def load_balloon
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
    #Erstelle neuen Array
    @new_bitmap = Array.new(10)
    for nr in 1..10
      #Erstelle neuen Sprite
      @new_bitmap[nr] = Sprite.new
      #Erstelle neues Bitmap
      @new_bitmap[nr].bitmap = Bitmap.new(960,384)
    end
 
    for hoehe in 0..9
      for breite in 0..7
        #Lege Rect fest
        ausschnitt = Rect.new(breite*32,hoehe*32,32,32)
        # Bestimme anim
        if breite <= 4 then
          anim = breite, 0
        else
          anim = breite-5, 1
        end
        #Kopiere Ausschnitt auf @new_bitmap
        @new_bitmap[hoehe+1].bitmap.blt((192*anim[0])+80,80+(192*anim[1]),original.bitmap,ausschnitt)
      end
    end
    #Lösche den original-Sprite
    original.dispose
    #Speichere die Bitmaps
    for number in 1..10
      @new_bitmap[number].bitmap.make_png("#{@ziel} - #{number}")
      @new_bitmap[number].dispose
    end
  end
 
  def load_icons
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
    #Lese Iconanzahl fest
    iconsx = original.bitmap.width/24
    iconsy = original.bitmap.height/24
    #Erstelle neuen Array
    @new_bitmap = Array.new(iconsx*iconsy)
    for nr in 1..@new_bitmap.size
      #Erstelle neuen Sprite
      @new_bitmap[nr] = Sprite.new
      #Erstelle neues Bitmap
      @new_bitmap[nr].bitmap = Bitmap.new(24,24)
    end
    add = 1
    for breite in 1..iconsx
      for hoehe in 1..iconsy
        #Lege Rect fest
        ausschnitt = Rect.new(24*(breite-1),24*(hoehe-1),24,24)
        #Kopere ausschnitt auf @new_bitmap
        @new_bitmap[add].bitmap.blt(0,0,original.bitmap,ausschnitt)
        @new_bitmap[add].y = (breite+add)*24
        add += 1
      end
    end
    #Lösche den original-Sprite
    original.dispose
    #Speichere die Bitmaps
    for number in 1..@new_bitmap.size-1
      @new_bitmap[number].bitmap.make_png("#{@ziel} - #{number}")
      @new_bitmap[number].dispose
    end
  end
 
  def tileA1
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
 
    # KONVERTIERE "WASSER"-AUTOTILES
 
    @new_bitmap = Array.new(16)
    add = 0
    for hoehe in 0..3
      for breite in 0..1
        add += 1
        @new_bitmap[add] = Sprite.new
        @new_bitmap[add].bitmap = Bitmap.new(288,128)
        for animation in 0..2
          convert_auto((64*animation)+(breite*256),hoehe*96,original.bitmap)
          ausschnitt = Rect.new(0,0,96,128)
          @new_bitmap[add].bitmap.blt(animation*96,0,$autotile_bitmap,ausschnitt)
        end
        $autotile_bitmap.dispose
      end
    end
 
    # KONVERTIERE "WASSERFALL"-AUTOTILES
    wasserfall = Array.new(8)
    add = 0
 
    #Wandle Wasserfälle in normale VX-Autotiles
    for hoehe in 0..3
      for breite in 0..1
        if breite == 1 or hoehe > 1 then
          add += 1
          wasserfall[add] = Bitmap.new(192,96)
          for animation in 0..2
            #Erstelle Anzeige-Bild
            rect = Rect.new(192+(breite*256),(hoehe*96)+(animation*32),16,16)
            wasserfall[add].blt(animation*64,0,original.bitmap,rect)
            rect.x += 48
            wasserfall[add].blt(16+(animation*64),0,original.bitmap,rect)
            rect.x -= 48
            rect.y += 16
            wasserfall[add].blt(animation*64,16,original.bitmap,rect)
            rect.x += 48
            wasserfall[add].blt(16+(animation*64),16,original.bitmap,rect)
 
            #Erstelle Autotile-Rand
            rect = Rect.new(animation*64,0,16,16)
            wasserfall[add].blt(animation*64,32,wasserfall[add],rect)
            wasserfall[add].blt(animation*64,64,wasserfall[add],rect)
            rect.x += 16
            wasserfall[add].blt(48+(animation*64),32,wasserfall[add],rect)
            wasserfall[add].blt(48+(animation*64),64,wasserfall[add],rect)
            rect.y += 16
            wasserfall[add].blt(48+(animation*64),80,wasserfall[add],rect)
            wasserfall[add].blt(48+(animation*64),48,wasserfall[add],rect)
            rect.x -= 16
            wasserfall[add].blt(animation*64,80,wasserfall[add],rect)
            wasserfall[add].blt(animation*64,48,wasserfall[add],rect)
 
            #Erstelle Autotile-Mitte
            rect = Rect.new(208+breite*256,(hoehe*96)+(animation*32),32,32)
            wasserfall[add].blt(16+animation*64,32,original.bitmap,rect)
            wasserfall[add].blt(16+animation*64,64,original.bitmap,rect)
 
            #Erstelle Autotile-Ecke
            rect = Rect.new(16+(animation*64),48,32,32)
            wasserfall[add].blt((animation*64)+32,0,wasserfall[add],rect)
           end
        end
      end
    end
 
    #Wandle Wasserfälle zu XP-Autotiles um
    add = 0
    6.times do
      add += 1
      @new_bitmap[add+8] = Sprite.new
      @new_bitmap[add+8].bitmap = Bitmap.new(288,128)
      for x_wert in 0..2
        convert_auto(x_wert*64,0,wasserfall[add])
        rect = Rect.new(32,64,32,32)
        $autotile_bitmap.blt(64,0,$autotile_bitmap,rect)
        @new_bitmap[add+8].bitmap.blt(96*x_wert,0,$autotile_bitmap,ausschnitt)
        $autotile_bitmap.dispose
      end
    end
 
    # KONVERTIERE UNANIMIERTE AUTOTILES
    add = 0
    @new_bitmap[15] = Sprite.new
    @new_bitmap[15].bitmap = Bitmap.new(96,128)
    @new_bitmap[16] = Sprite.new
    @new_bitmap[16].bitmap = Bitmap.new(96,128)
    2.times do
      convert_auto(192,(add*96),original.bitmap)
      add += 1
      ausschnitt = Rect.new(0,0,96,128)
      @new_bitmap[add+14].bitmap.blt(0,0,$autotile_bitmap,ausschnitt)
      $autotile_bitmap.dispose
    end
 
    #Lösche den original-Sprite
    original.dispose
 
    # Speichere die Autotiles
    for save in 1..8
      @new_bitmap[save].bitmap.make_png("#{@ziel} W#{save}")
      @new_bitmap[save].dispose
    end
 
    for save in 9..14
     @new_bitmap[save].bitmap.make_png("#{@ziel} WF#{save-8}")
     @new_bitmap[save].dispose
    end
 
    for save in 15..16
      @new_bitmap[save].bitmap.make_png("#{@ziel} #{save-14}")
      @new_bitmap[save].dispose
    end
  end
 
 
 
  def load_autotile(type)
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
    if type == "A1" then
      tileA1
    elsif type == "A2" then
      tileA2
    elsif type == "A3" then
      tileA3
    elsif type == "A4" then
      tileA4
    end
  end
 
  def convert_auto(x,y,bitmap)
    $autotile_bitmap = Bitmap.new(96,128)
 
    rect = Rect.new(x+32,y,32,32)
    $autotile_bitmap.blt(64,0,bitmap,rect)
    rect = Rect.new(x,y,32,32)
    $autotile_bitmap.blt(0,0,bitmap,rect)
 
    rect = Rect.new(x,y+32,16,16)
    $autotile_bitmap.blt(0,32,bitmap,rect)
    rect = Rect.new(x+48,y+32,16,16)
    $autotile_bitmap.blt(80,32,bitmap,rect)
    rect = Rect.new(x,y+80,16,16)
    $autotile_bitmap.blt(0,112,bitmap,rect)
    rect = Rect.new(x+48,y+80,16,16)
    $autotile_bitmap.blt(80,112,bitmap,rect)
 
    rect = Rect.new(x+16,y+32,32,16)
    $autotile_bitmap.blt(16,32,bitmap,rect)
    rect = Rect.new(x,y+48,16,32)
    $autotile_bitmap.blt(0,48,bitmap,rect)
    rect = Rect.new(x+48,y+48,16,32)
    $autotile_bitmap.blt(80,48,bitmap,rect)
    rect = Rect.new(x+16,y+80,32,16)
    $autotile_bitmap.blt(16,112,bitmap,rect)
 
    rect = Rect.new(x+16,y+32,32,16)
    $autotile_bitmap.blt(48,32,bitmap,rect)
    rect = Rect.new(x,y+48,16,32)
    $autotile_bitmap.blt(0,80,bitmap,rect)
    rect = Rect.new(x+48,y+48,16,32)
    $autotile_bitmap.blt(80,80,bitmap,rect)
    rect = Rect.new(x+16,y+80,32,16)
    $autotile_bitmap.blt(48,112,bitmap,rect)
 
    rect = Rect.new(x+16,y+48,32,32)
    $autotile_bitmap.blt(16,48,bitmap,rect)
    rect = Rect.new(x+16,y+48,32,32)
    $autotile_bitmap.blt(16,80,bitmap,rect)
    rect = Rect.new(x+16,y+48,32,32)
    $autotile_bitmap.blt(48,48,bitmap,rect)
    rect = Rect.new(x+16,y+48,32,32)
    $autotile_bitmap.blt(48,80,bitmap,rect)
 
    return $autotile_bitmap
  end
 
  def tileA2
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
    # Erstelle neuen Array
    @new_bitmap = Array.new(32)
 
    add = 0
    #Wandle VX-Autotiles in XP-Autotiles
    for breite in 0..7
      for hoehe in 0..3
        add += 1
        @new_bitmap[add] = Sprite.new
        @new_bitmap[add].bitmap = Bitmap.new(96,128)
        convert_auto(breite*64,hoehe*96,original.bitmap)
        rect = Rect.new(0,0,96,128)
        @new_bitmap[add].bitmap.blt(0,0,$autotile_bitmap,rect)
      end
    end
 
    #Lösche den original-Sprite
    original.dispose
 
    #Speichere die Autotiles
    for save in 1..32
      @new_bitmap[save].bitmap.make_png("#{@ziel} - #{save}")
      @new_bitmap[save].dispose
    end
  end
 
  def tileA3
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
    # Erstelle neuen Array und neues Bitmap
    @new_bitmap = Array.new(32)
    @tileset = Bitmap.new(256,512)
 
    rect = Rect.new(0,0,256,256)
    @tileset.blt(0,0,original.bitmap,rect)
    rect.x += 256
    @tileset.blt(0,256,original.bitmap,rect)
 
    #Wandle die Tiles in VX-Autotiles
    vxp = Array.new(32)
    add = 0
    for hoehe in 0..3
      for breite in 0..7
        add += 1
        vxp[add] = Bitmap.new(64,96)
        rect = Rect.new(breite*64,hoehe*64,64,64)
        vxp[add].blt(0,32,original.bitmap,rect)
        rect = Rect.new(0,32,16,16)
        vxp[add].blt(0,0,vxp[add],rect)
        rect.x += 32
        vxp[add].blt(16,0,vxp[add],rect)
        rect.y += 32
        vxp[add].blt(16,16,vxp[add],rect)
        rect.x -= 32
        vxp[add].blt(0,16,vxp[add],rect)
      end
    end
 
    # Wandle vxp in XP-Autotiles
    for add in 1..32
      convert_auto(0,0,vxp[add])
      rect = Rect.new(32,64,32,32)
      $autotile_bitmap.blt(64,0,$autotile_bitmap,rect)
      @new_bitmap[add] = Sprite.new
      @new_bitmap[add].bitmap = Bitmap.new(96,128)
      rect = Rect.new(0,0,96,128)
      @new_bitmap[add].bitmap.blt(0,0,$autotile_bitmap,rect)
    end
 
    #Lösche den original-Sprite
    original.dispose
 
    #Speichere die Bitmaps
    for save in 1..32
      @new_bitmap[save].bitmap.make_png("#{@ziel} - #{save}")
      @new_bitmap[save].dispose
    end
 
    @tileset.make_png("Tileset A3")
  end
 
  def tileA4
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
    # Erstelle neuen Array und neues Bitmap
    @new_bitmap = Array.new(48)
    for bit in 1..64
      @new_bitmap[bit] = Sprite.new
      @new_bitmap[bit].bitmap = Bitmap.new(96,128)
    end
    @tileset = Bitmap.new(256,768)
 
    #Erstelle die Tiles als komplettes Set
    add = 0
    for br in 0..1
      for he in 0..2
        rect = Rect.new(br*256,(he*160)+32,256,128)
        @tileset.blt(0,add*128,original.bitmap,rect)
        add += 1
      end
    end
  # @tileset.make_png("#{@ziel} Tileset")
  @tileset.dispose
 
    #Konvertiere die bereits fertigen Autotiles
    add = 0
    for breite in 0..7
      for hoehe in 0..2
        add += 1
        convert_auto(breite*64,hoehe*160,original.bitmap)
        rect = Rect.new(0,0,96,128)
        @new_bitmap[add].bitmap.blt(0,0,$autotile_bitmap,rect)
      end
    end
 
    #Wandle die Mauern in VX-Autotiles um
    vxp = Array.new(24)
    add = 0
    for breite in 0..7
      for hoehe in 0..2
        add += 1
        vxp[add] = Bitmap.new(64,96)
        rect = Rect.new(breite*64,(hoehe*160)+96,64,64)
        vxp[add].blt(0,32,original.bitmap,rect)
        rect = Rect.new(0,32,16,16)
        vxp[add].blt(0,0,vxp[add],rect)
        rect.x += 48
        vxp[add].blt(16,0,vxp[add],rect)
        rect.y += 48
        vxp[add].blt(16,16,vxp[add],rect)
        rect.x -= 48
        vxp[add].blt(0,16,vxp[add],rect)
      end
    end
 
    #Wandle die VX-Mauer-Autotiles in XP um
    for add in 1..24
      convert_auto(0,0,vxp[add])
      rect = Rect.new(32,64,32,32)
      $autotile_bitmap.blt(64,0,$autotile_bitmap,rect)
      rect = Rect.new(0,0,96,128)
      @new_bitmap[add+24].bitmap.blt(0,0,$autotile_bitmap,rect)
    end
 
    #Lösche den original-Sprite
    original.dispose
 
    for save in 1..48
      @new_bitmap[save].bitmap.make_png("#{@ziel} - #{save}")
      @new_bitmap[save].dispose
    end
  end
 
  def load_bigchar
    # Erstelle original-Sprite
    original = Sprite.new
    # Erstelle original-Bitmap
    original.bitmap = Bitmap.new(@quelle)
    #Lese Breite und Höhe
    breite = original.bitmap.width
    hoehe = original.bitmap.height
    #Erstelle neues Bitmap
    @new_bitmap = Sprite.new
    @new_bitmap.bitmap = Bitmap.new(breite+breite/3,hoehe)
 
    rect = Rect.new(0,0,breite,hoehe)
    @new_bitmap.bitmap.blt(breite/3,0,original.bitmap,rect)
    rect = Rect.new(breite/3,0,breite/3,hoehe)
    @new_bitmap.bitmap.blt(0,0,original.bitmap,rect)
 
    #Lösche den original-Sprite
    original.dispose
    #Speichere die Bitmaps
    @new_bitmap.bitmap.make_png("#{@ziel}")
    @new_bitmap.dispose
  end
end
class Extras
  def initialize(quelle,ziel,type,shutdown=false)
    @quelle = quelle
    @ziel = ziel
 
    # Führe entsprechende Methode aus
    if type == "Tilefusion" then
      load_tilefusion
    elsif type == "Autofusion" then
      load_autofusion
    end
 
    # Wenn shutdown true ist, beende das Programm
    if shutdown == true then
      $scene = nil
    end
  end
 
  def load_tilefusion
    #Lade die Tilesets
    hoehe = 0
    for load in 0..@quelle.size-1
      @quelle[load] = Bitmap.new(@quelle[load])
      hoehe += @quelle[load].height
    end
    #Erstelle ein neues Bitmap
    @new_bitmap = Bitmap.new(256,hoehe)
    #Fusioniere die Tilesets
    hoehe = 0
    for fus in 0..@quelle.size-1
      rect = Rect.new(0,0,256,@quelle[fus].height)
      @new_bitmap.blt(0,hoehe,@quelle[fus],rect)
      hoehe += @quelle[fus].height
    end
    #Speichere das Tileset
    @new_bitmap.make_png("#{@ziel}")
  end
 
  def load_autofusion
    #Lade die beiden Bilder
    for load in [0,1]
      @quelle[load] = Bitmap.new(@quelle[load])
    end
    #Wenn eins der beiden ein einziges Tile ist, wandle es um
    for load in [0,1]
      if @quelle[load].width == 32 and @quelle[load].height == 32 then
        temp = Bitmap.new(32,32)
        rect = Rect.new(0,0,32,32)
        temp.blt(0,0,@quelle[load],rect)
        @quelle[load] = Bitmap.new(96,128)
        @quelle[load].blt(0,0,temp,rect)
        @quelle[load].blt(64,0,temp,rect)
        for h in 1..3
          for b in 0..2
            @quelle[load].blt(b*32,h*32,temp,rect)
          end
        end
      end
    end
 
    #Lege das zweite Autotile über das erste
    rect = Rect.new(0,0,96,128)
    @quelle[0].blt(0,0,@quelle[1],rect)
    #Speichere das Bitmap
    @quelle[0].make_png("#{@ziel}")
  end
end
 
Социальные закладки