VX 스크립트

 출처:rmrk

#==============================================================================
#  Screenshot
#  Version: 1.0
#  Author: modern algebra (rmrk.net)
#  Date: April 5, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#    This script allows the player to take a screenshot of any area in the game
#   that he/she wants. Useful for sharing achievements I suppose.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    All you need to do is set which button you want to use for taking
#   screenshots with at line 31, and set the destination folder for screenshots
#   at line 33.
#    If you want to force a screenshot, you can put this code in a call script:
#       $scene.take_screenshot
#==============================================================================
#==============================================================================
# ** Scene_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constant - MA_SCREENSHOT_BUTTON, MA_SCREENSHOT_PATH
#    aliased method - update
#==============================================================================

class Scene_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * CONSTANTS
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  #  MA_SCREENSHOT_BUTTON - the button to press to take a Screenshot
  MA_SCREENSHOT_BUTTON = Input::F5
  #  MA_SCREENSHOT_PATH - the path to save the file
  MA_SCREENSHOT_PATH = "Screenshot "
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modag_screenshot_upd_9ik2 update
  def update (*args)
    modag_screenshot_upd_9ik2 (*args) # Run Original Method
    if Input.trigger? (MA_SCREENSHOT_BUTTON)
      take_screenshot
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Take Screenshot
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def take_screenshot
    x = 1
    while FileTest.exist? ("#{MA_SCREENSHOT_PATH}#{x}.png")
      x += 1
    end
    Graphics.snap_to_bitmap.make_png (x.to_s, MA_SCREENSHOT_PATH, 1)
  end
end
#==============================================================================
#  Everything below this point is the PNG Saver script, written by 66rpg.com
#==============================================================================

# PNG Saver by 66rpg.com

module Zlib
  class Png_File < GzipWriter
    def make_png(bitmap, mode = 0)
      @bitmap, @mode = bitmap, mode
      self.write(make_header)
      self.write(make_ihdr)
      self.write(make_idat)
      self.write(make_iend)
    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  = "x49x44x41x54"
      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
            if t_Fx % 100000 == 0
              s = data.pack('C*')
              gz.write(s)
              data.clear
            end
          end
          color = @bitmap.get_pixel(x, y)
          data.push(color.red, color.green, color.blue, color.alpha)
        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)
          data.push(color.red, color.green, color.blue, color.alpha)
        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

$scene.take_screenshot 을 스크립트로 이벤트추가 해주심 됩니다.(전체 단축키스크립트를 이용해 단축기로도 스샷 가능

Comment '14'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 3 습작 2012.12.24 5398
457 스킬 스킬, 아이템 적아 구분 없이 쓰기 10 file EuclidE 2011.10.16 2900
456 스킬 스킬 필요조건에 살짝 손대봤습니다. -- 수정 18 아이미르 2011.03.23 2499
455 스킬 스킬 필요 조건(번역) 23 file 훈덕 2009.02.03 4644
454 전투 스킬 커맨드 스크립트 16 아방스 2009.02.05 4535
453 상점 스킬 샾 스크립트 2.0 48 아방스 2008.03.05 6628
452 스킬 스킬 사용시 컷인 연출 (번역) 26 file 훈덕 2009.02.05 5387
451 기타 스크립트로 커먼 이벤트 실행 [수정] 3 허걱 2009.08.17 2311
450 기타 스크립트강좌 4 아하!잘봤어요. 2009.05.04 2158
» 기타 스크린샷 기능 14 비극ㆍ 2010.04.19 2090
448 이동 및 탈것 스위치 on일때 못 움직이게...(이동고정) 6 허걱 2009.07.14 2322
447 메시지 소설풍(노벨풍) 문자 스크립트 31 file 맛난호빵 2011.01.03 5551
446 저장 세이브/로드가 불가능한 스크립트!!! 9 file ~AYARSB~ 2010.03.08 3298
445 기타 세이브 포인트 2 비극ㆍ 2010.04.19 2518
444 저장 세이브 파일 개수 16개로 늘리기 (기본 세이브 엔진용) 1 file Bunny_Boy 2015.09.07 816
443 저장 세이브 시스템 확장 스크립트 9 file 신규회원 2012.02.24 3315
442 기타 설명하기 힘든 스크립트 (스크린샷 확인) 10 file 사람이라면? 2010.08.16 3818
441 직업 서브클래스 선택 시스템 Subclass Selection System 7 file 카르와푸딩의아틀리에 2009.06.30 3943
440 새로운 종류의 세이브 스크립트!! 8 Man... 2008.10.28 3517
439 전투 새로운 전투돌입효과 29 file RPGbooster 2008.10.08 5079
438 맵/타일 새로운 월드맵 만들기 (로맨싱사가풍) 37 file 078656577er 2009.10.09 6151
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 32 Next
/ 32