设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 106|回复: 0

[转载发布] Screenshot Taker by Jet and Zeus81

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-1 20:21:50 | 显示全部楼层 |阅读模式




    Screenshot Taker
    by Jet & Zeus81





    Introduction


    Jet’s screenshot saver, up from the ashes

    Features

    - Push-of-a-button screenshot taking
    - Displays how long it took to take the screenshot
    - Can save as .png OR .bmp
    - .bmp files are instant, .png are smaller but a little slower.
    - And more...

    Screenshot





    Script

    http://pastebin.com/raw.php?i=0fpPC0Xm

    Credit

    Jet
    Zeus81


    Jet’s  script is made under this license:

    [url=https://creativecommons.org/licenses/by-nc-sa/3.0/][/url]





                    Code:       
    1. #===============================================================================
    2. # Screenshot Taker
    3. # By Jet10985 (Jet)
    4. # PNG and BMP saving code by: Zeus81
    5. #===============================================================================
    6. # This script will allow you to take screenshots of the current gamescreen
    7. # with the push of a button
    8. # This script has: 7 customization options.
    9. #===============================================================================
    10. # Overwritten Methods:
    11. # None
    12. #-------------------------------------------------------------------------------
    13. # Aliased methods:
    14. # Graphics: update
    15. #===============================================================================
    16. =begin
    17. Notes:
    18. All screenshots are saved in a folder in the game directory called "Screenshots"
    19. and they are named sequentially, depending on how many screenshots are in
    20. the folder already.
    21. =end
    22. module JetScreenshotTaker
    23.   # Do you want to save the screenshot as a .bmp, or a .png?
    24.   # .bmp is basically instant, and is 32-bit but the alpha channel is not
    25.   # compatible with every image editing program.
    26.   # .png is slightly slower but it is usually smaller than the .bmp
    27.   # true is for .png, false if for .bmp
    28.   SAVE_AS_PNG = true
    29.   # Which button do you have to press to take a screenshot?
    30.   SCREENSHOT_BUTTON = Input::F5
    31.   # Do you want a pop-up window to appear when a screenshot has been taken?
    32.   # The popup window will display how many seconds it took for the screenshot
    33.   POPUP_SCREENSHOT_WINDOW = true
    34.   # Would you like a sound effect played when a screenshot is taken?
    35.   SCREENSHOT_SE = true
    36.   # What SE would you like played?
    37.   SCREENSHOT_SE_FILE = ""
    38.   # Do you want to add a "Watermark" or some other image ontop of screenshots?
    39.   WATERMARK = false
    40.   # What is the name of the watermark image name?
    41.   # This should be in the Pictures folder
    42.   # Watermark image starts at (0, 0) which is top left, so make the image
    43.   # screen-sized and place the contents accordingly.
    44.   WATERMARK_IMAGE = "Watermark"
    45. end
    46. #===============================================================================
    47. # DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
    48. #===============================================================================
    49. # Bitmap export v 3.0 by Zeus81
    50. class Bitmap
    51.   RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
    52.   RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
    53.   def address
    54.     RtlMoveMemory_pi.call(a = "\0" * 4, __id__ * 2 + 16, 4)
    55.     RtlMoveMemory_pi.call(a, a.unpack('L')[0] + 8, 4)
    56.     RtlMoveMemory_pi.call(a, a.unpack('L')[0] + 16, 4)
    57.     a.unpack('L')[0]
    58.   end
    59.   def export(filename)
    60.     jet_file_type = JetScreenshotTaker::SAVE_AS_PNG ? ".png" : ".bmp"
    61.     Dir.mkdir("Screenshots") unless File.directory?("Screenshots")
    62.     filename = "Screenshots/Screenshot #{Dir.entries("Screenshots").size - 1}#{jet_file_type}"
    63.     file = File.open(filename, 'wb')
    64.     case format=File.extname(filename)
    65.     when '.bmp'
    66.       data, size = String.new, width*height*4
    67.       RtlMoveMemory_ip.call(data.__id__*2+8, [size,address].pack('L2'), 8)
    68.       file.write(['BM',size+54,0,54,40,width,height,1,32,0,size,0,0,0,0].pack('a2L6S2L6'))
    69.       file.write(data)
    70.       RtlMoveMemory_ip.call(data.__id__*2+8, "\0"*8, 8)
    71.     when '.png'
    72.       def file.write_chunk(chunk)
    73.         write([chunk.size-4].pack('N'))
    74.         write(chunk)
    75.         write([Zlib.crc32(chunk)].pack('N'))
    76.       end
    77.       file.write("\211PNG\r\n\32\n")
    78.       file.write_chunk("IHDR#{[width,height,8,6,0,0,0].pack('N2C5')}")
    79.       RtlMoveMemory_pi.call(data="\0"*(width*height*4), address, data.size)
    80.       (width*height).times {|i| data[i<<=2,3] = data[i,3].reverse!}
    81.       deflate, null_char, w4 = Zlib::Deflate.new(9), "\0", width*4
    82.       (height-1).downto(0) {|i| deflate << null_char << data[i*w4,w4]}
    83.       file.write_chunk("IDAT#{deflate.finish}")
    84.       deflate.close
    85.       file.write_chunk('IEND')
    86.     when ''; print("Export format missing for '#{filename}'.")
    87.     else     print("Export format '#{format}' not supported.")
    88.     end
    89.     file.close
    90.   end
    91. end
    92. class << Graphics
    93.   alias jet9991_update update unless $@
    94.   def update(*args)
    95.     jet9991_update(*args)
    96.     if Input.trigger?(JetScreenshotTaker::SCREENSHOT_BUTTON)
    97.       old_time = Time.now
    98.       f = Graphics.snap_to_bitmap
    99.       if JetScreenshotTaker::WATERMARK
    100.         a = Cache.picture(JetScreenshotTaker::WATERMARK_IMAGE)
    101.         f.blt(0, 0, a, a.rect)
    102.       end
    103.       f.export("Image")
    104.       if JetScreenshotTaker::SCREENSHOT_SE
    105.         RPG::SE.new(JetScreenshotTaker::SCREENSHOT_SE_FILE, 100, 100).play
    106.       end
    107.       if JetScreenshotTaker::POPUP_SCREENSHOT_WINDOW
    108.         time = Time.now
    109.         real_time = (time - old_time)
    110.         elapsed_time = (real_time * 1000.0).to_i / 1000.0
    111.         p "Screenshot taken: #{elapsed_time} seconds"
    112.       end
    113.     end
    114.   end
    115. end
    复制代码




    本贴来自国际rpgmaker官方论坛作者:GrandmaDeb处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/screenshot-taker-by-jet-and-zeus81.90182/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 13:37 , Processed in 0.133111 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表