• Announcements

    • RagingHobo

      Forum Upgraded!   07/17/2017

      We have successfully upgraded our forum to the latest version! Some things have moved around but don't worry everything is still there, we still need to find updated versions of the plugins we were using previously to restore everything to the way it was. There will be a running topic in the Feedback and Support in case you notice something wrong. Before you do so please clear your browser cache and close your browser completely to rule out a caching issue. Thank you for your patience during the outage and while we get everything back to 150%  
Tync

Map to Image exporter Help

9 posts in this topic

Hello I am new and I am trying to use a code. Its at the bottom.

Sadly I do not understand how to set on the Following parts:

#   Now make a new event, autorun, with script call:
#   $saver = Map_Saver.new
#   Then turn self-switch A ON.
#   Go to the event's second page, put as condition self-switch A, then put
#   script call:
#   $saver.update
#   Finally make the second page to be autorun as well.

If someone can give me a step by step or something I will be very thankful

 

 

# =============================================================================
# Map Saver ACE
# Version 0.1
# Author: Yami
# Credit: Omegas7 for VX version   Site: http://www.myrpgmaker.com
# Credit: Woratana for PNG Saver script.
# =============================================================================
# Save a whole map into a .png file by taking multiple screenshots and finally
# combining them. Exporting the resulting bitmap to a .png image file using
# Woratana's PNG Saver script.
# =============================================================================
# Instructions:
#   Go to Paint or whatever image editing software you want.
#   Create a new file, width and height will be the same as your map, but
#   multiplied by 32. (If map's width is 20, the image's width will be 640).
#   Name the image "Blank", and save it on the System folder of your game.
#   Go to your game map, and put the player starting position on the
#   bottom left part of the map.
#   Now make a new event, autorun, with script call:
#   $saver = Map_Saver.new
#   Then turn self-switch A ON.
#   Go to the event's second page, put as condition self-switch A, then put
#   script call:
#   $saver.update
#   Finally make the second page to be autorun as well.
#   Run the game, you will see the map will start scrolling. Let it be.
#   At the end the script will start creating the image file, this process
#   may take several minutes depending on your map's size.
#   Sure, it may take very long, but it saves HOURS if you planned to make
#   your map manually, so do not complain .
# =============================================================================
# Notes:
#   The final result will be an image file located on your game's main folder.
#   The image will be exactly what appears on the screen, so if you got a HUD,
#   it will appear as well.
#   If you notice a problem with the final result, like with tiles etc,
#   try activating "weird mode" below.
#   If the final result is still not fixed, try to get support.
# =============================================================================

class Map_Saver
  def initialize

    # If the resulting image seems to be wrongly made, try turning this value
    # to "true". Normally, this should be false.
    @weird_mode = false

    @result = Bitmap.new('Graphics/System/Blank')
    @bitmaps = []
    @moving = true
    @last_place = 'none'
    @finishing = false
    @pause_time = 30
    @scrolling_x = 13
  end
  def update
    if !(@finishing)
	  if !($game_map.scrolling?)
	    if @moving
		  execute_image
	    else
		  if can_move?(8)
		    $game_map.start_scroll(8, @scrolling_x, 7)
		    @moving = true
		    @last_place = 'down'
		  elsif can_move?(6) && @last_place == 'down'
		    $game_map.start_scroll(6, 17, 7)
		    @last_place = 'left'
		  elsif can_move?(2) && @last_place == 'left'
		    $game_map.start_scroll(2, $game_map.height, 9)
		    @last_place = 'up'
		    @moving = true
		  else
		    @finishing = true
		    for i in 0...@bitmaps.size
			  y = @bitmaps[i][2]*32
			  if @bitmaps[i][3] == true
			    y += 16 if @weird_mode
			  end
			  @result.blt(@bitmaps[i][1]*32,y,@bitmaps[i][0],
			  Rect.new(0,0,Graphics.width,Graphics.height))
		    end
		    @result.make_png('Map','')
		    print "Map image production is over!"
		    exit
		  end
	    end
	  end
    end
  end
  def execute_image
    Graphics.freeze
    @bitmaps.push([Graphics.snap_to_bitmap,
    $game_map.display_x,
    $game_map.display_y,
    nil])
    @moving = false
    Graphics.transition(@pause_time)
    if can_move?(8) && can_move?(2)
	  @bitmaps[@bitmaps.size - 1][3] = true
    end
  end
  def can_move?(direction)
    case direction
    when 6
	  return false if ($game_map.display_x) == ($game_map.width - Graphics.width / 32)
	  return true
    when 2
	  return false if ($game_map.display_y) == ($game_map.height - Graphics.height / 32)
	  return true
    when 4
	  return false if ($game_map.display_x == 0)
	  return true
    when 8
	  return false if ($game_map.display_y == 0)
	  return true
    end
  end
end

# =============================================================================
# PNG Saver by Woratana.
# =============================================================================
module Zlib
  class Png_File < GzipWriter
    def make_png(bitmap, mode = 0)
	  @bitmap, @mode = bitmap, mode
	  create_loader
	  self.write(make_header)
	  self.write(make_ihdr)
	  self.write(make_idat)
	  self.write(make_iend)
    end
    def create_loader
	  w = @bitmap.width
	  h = @bitmap.height
	  @calculated = [0,nil]
	  @calculated[1] = (w*h).to_f
	  @window = Window_Base.new(0,150,544,116)
	  @window.contents.font.size = 16
	  @update = ((@bitmap.width*@bitmap.height)/3000.0).floor.to_i
	  refresh_loader
    end
    def refresh_loader
	  Graphics.update
	  @window.contents.clear
	  text = ['Creating image file, please wait...',
	  percent.to_s + '% done...']
	  for i in 0...text.size
	    @window.contents.draw_text(0,20*i,520,20,text[i])
	  end
	  Graphics.update
    end
    def percent
	  return ((100/@calculated[1])*@calculated[0]).floor
    end
    def make_header
	  return [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a].pack('C*')
    end
    def make_ihdr
	  ih_size			   = [13].pack('N')
	  ih_sign			   = 'IHDR'
	  ih_width			  = [@bitmap.width].pack('N')
	  ih_height			 = [@bitmap.height].pack('N')
	  ih_bit_depth		  = [8].pack('C')
	  ih_color_type		 = [6].pack('C')
	  ih_compression_method = [0].pack('C')
	  ih_filter_method	  = [0].pack('C')
	  ih_interlace_method   = [0].pack('C')
	  string = ih_sign + ih_width + ih_height + ih_bit_depth + ih_color_type +
			   ih_compression_method + ih_filter_method + ih_interlace_method
	  ih_crc = [Zlib.crc32(string)].pack('N')
	  return ih_size + string + ih_crc
    end
    def make_idat
	  header  = "\x49\x44\x41\x54"
	  data    = @mode == 0 ? make_bitmap_data0 : make_bitmap_data1
	  data    = Zlib::Deflate.deflate(data, 8)
	  crc	 = [Zlib.crc32(header + data)].pack('N')
	  size    = [data.length].pack('N')
	  return size + header + data + crc
    end
    def make_bitmap_data0
	  gz = Zlib::GzipWriter.open('png2.tmp')
	  t_Fx = 0
	  w = @bitmap.width
	  h = @bitmap.height
	  data = []
	  for y in 0...h
	    data.push(0)
	    for x in 0...w
		  t_Fx += 1
		  if t_Fx % 10000 == 0
		    Graphics.update
		  end
		  if t_Fx % 100000 == 0
		    s = data.pack('C*')
		    gz.write(s)
		    data.clear
		  end
		  color = @bitmap.get_pixel(x, y)
		  red = color.red
		  green = color.green
		  blue = color.blue
		  alpha = color.alpha
		  data.push(red)
		  data.push(green)
		  data.push(blue)
		  data.push(alpha)
		  @calculated[0] += 1
		  if @calculated[0] % @update == 0
		    refresh_loader
		  end
	    end
	  end
	  s = data.pack('C*')
	  gz.write(s)
	  gz.close   
	  data.clear
	  gz = Zlib::GzipReader.open('png2.tmp')
	  data = gz.read
	  gz.close
	  File.delete('png2.tmp')
	  return data
    end
    def make_bitmap_data1
	  w = @bitmap.width
	  h = @bitmap.height
	  data = []
	  for y in 0...h
	    data.push(0)
	    for x in 0...w
		  color = @bitmap.get_pixel(x, y)
		  red = color.red
		  green = color.green
		  blue = color.blue
		  alpha = color.alpha
		  data.push(red)
		  data.push(green)
		  data.push(blue)
		  data.push(alpha)
		  @calculated[0] += 1
		  if @calculated[0] % @update == 0
		    refresh_loader
		  end
	    end
	  end
	  return data.pack('C*')
    end
    def make_iend
	  ie_size = [0].pack('N')
	  ie_sign = 'IEND'
	  ie_crc  = [Zlib.crc32(ie_sign)].pack('N')
	  return ie_size + ie_sign + ie_crc
    end
  end
end
#=============================================================================
# ** Bitmap
#=============================================================================
class Bitmap
  def make_png(name = 'like', path = '', mode = 0)
    Zlib::Png_File.open('png.tmp')   { |gz| gz.make_png(self, mode) }
    Zlib::GzipReader.open('png.tmp') { |gz| $read = gz.read }
    f = File.open(path + name + '.png', 'wb')
    f.write($read)
    f.close
    File.delete('png.tmp')
  end
end



#   Now make a new event, autorun, with script call:
#   $saver = Map_Saver.new
#   Then turn self-switch A ON.
#   Go to the event's second page, put as condition self-switch A, then put
#   script call:
#   $saver.update
#   Finally make the second page to be autorun as well.

 

 

Share this post


Link to post
Share on other sites

I guess it means that you'd set up an autorun event? Pray I hadn't erred, but I think you should:

  • Create an event on the map. Set the event trigger to autorun.
  • On the event page, insert a script call, and type the code provided.
$saver = Map_Saver.new
  • After the script call, create another entry in the event page. This time, turn on the self-switch A.
  • Create another page in the event editor. Set the conditions to run if self-switch A is on. Be sure to set this page's trigger to autorun, too.
  • In the second event page, insert a script call and call the update method as provided.
$saver.update

If what I'm saying is right, I actually wanted to upload some screenshots to further ease our understanding, but pray understand my internet connection is as crappy. I hope it helps in some way.

Edited by oichidan

Share this post


Link to post
Share on other sites

Ok so this is what I took from what you said but its still not working for me >.<

 

http://prntscr.com/f9vx81 <-- Page 1

http://prntscr.com/f9vxj4 <-- Page 2

 

http://prntscr.com/f9vy3e <-- Map with trigger

 

http://prntscr.com/f9vy8n <-- Where I placed the Script

 

 

I think I have all the bases covered lol

As a note the Event Does start it gives me the Mapshot Started On start up but it never completes the event 

Edited by Tync

Share this post


Link to post
Share on other sites

Yeeeaaahhh...

 

That other script looked like a half-broken shoulderbag strap in comparison to Tsukihime's script...

 

In fact, there's no other script I'd recommend for map shots and screen shots (so I'm glad someone actually got on this train).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.