设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1803|回复: 2
打印 上一主题 下一主题

[已经解决] 请问有没有整地图截图或者输出地图图片的方法?

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2920
在线时间
713 小时
注册时间
2010-7-25
帖子
813

开拓者

跳转到指定楼层
1
发表于 2015-2-10 10:55:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
突然发觉如果不先把地图变成图片再对照着改就没法添加图层

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 2015-2-10 10:57:29 | 只看该作者

点评

喵呜喵5粘的那个连接我一进去就卡网页,不过tseyik给的脚本倒是成功了,谢谢。  发表于 2015-2-10 12:24
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
22948
在线时间
8638 小时
注册时间
2011-12-31
帖子
3367
3
发表于 2015-2-10 11:10:42 | 只看该作者
本帖最后由 tseyik 于 2015-2-10 11:17 编辑

範例(執行前需先save一次)
https://rpg.blue/forum.php?mod=r ... 513&pid=2579564
Map Screenshot
RUBY 代码复制
  1. =begin
  2.  
  3. #===============================================================================
  4.  
  5.  Title: Map Screenshot
  6.  
  7.  Author: Tsukihime
  8.  
  9.  Date: Apr 15, 2013
  10.  
  11. --------------------------------------------------------------------------------
  12.  
  13.  ** Change log
  14.  
  15.  Apr 15, 2013
  16.  
  17.    - updated script to use GDI+ interface
  18.  
  19.    - added support for region map overlay and passage map overlay
  20.  
  21.  Apr 6, 2013
  22.  
  23.    - fixed bug where drawing events crashed the game
  24.  
  25.  Apr 2, 2013
  26.  
  27.    - map data is now setup by an instance of Game_Map, to account for custom
  28.  
  29.      map scripts adding to the map
  30.  
  31.  Jul 27
  32.  
  33.    - Export dirNames are now optional
  34.  
  35.  May 28
  36.  
  37.    - updated overlay mapping compatibility to draw the overlays
  38.  
  39.      based on the player's current position
  40.  
  41.    - fixed issue where import hash was commented out
  42.  
  43.    - Added support for Yami's overlay mapping
  44.  
  45.  May 24, 2012
  46.  
  47.    - fixed large characters
  48.  
  49.    - some optimizations for calculating bounds and dimensions
  50.  
  51.  May 5, 2012
  52.  
  53.    - fixed waterfall autotile
  54.  
  55.    - added screenshot feature
  56.  
  57.  May 4, 2012
  58.  
  59.    - fixed tiles with alpha channel
  60.  
  61.    - fixed shadows
  62.  
  63.    - fixed wall autotiles
  64.  
  65.  May 1, 2012
  66.  
  67.    - fixed wall autotile, although there is still an issue with some tiles
  68.  
  69.  Apr 29, 2012
  70.  
  71.    - fixed shadow map drawing
  72.  
  73.    - added region highlighting
  74.  
  75.    - added damage tile highlighting
  76.  
  77.  Apr 28, 2012
  78.  
  79.    - Initial Release
  80.  
  81. ------------------------------------------------------------------------------
  82.  
  83.  ** Description
  84.  
  85.  
  86.  
  87.  This script allows you to take a full image of any of your game's maps
  88.  
  89.  and export. An image of the map is referred to as a "mapshot" (as opposed to
  90.  
  91.  screenshot).
  92.  
  93.  
  94.  
  95.  The script provides various configuration options to control what kinds of
  96.  
  97.  things you want to see on your map, such as events, vehicles, region ID's, or
  98.  
  99.  specific tile properties.
  100.  
  101.  
  102.  
  103. ------------------------------------------------------------------------------
  104.  
  105.  ** Usage
  106.  
  107.  
  108.  
  109.  The default key for taking a mapshot is F7. This can be changed in the
  110.  
  111.  configuration section.
  112.  
  113.  
  114.  
  115.  To take a mapshot, first start the game, and then hit F7.
  116.  
  117.  A message will appear informing you that a mapshot was successfully taken.
  118.  
  119.  
  120.  
  121.  Alternatively, you can use script calls to take mapshots.
  122.  
  123.  
  124.  
  125.     Map_Saver.new(map_id).export
  126.  
  127.     
  128.  
  129.  Aside from exporting images, you are able to use the image that the
  130.  
  131.  map saver captures.
  132.  
  133.  
  134.  
  135.    ms = Map_Saver.new(map_id)
  136.  
  137.    bmp = ms.map_image
  138.  
  139.    
  140.  
  141.  This gives you a reference to a Bitmap object that contains an image of
  142.  
  143.  your map.
  144.  
  145. --------------------------------------------------------------------------------
  146.  
  147.   ** Credits
  148.  
  149.  
  150.  
  151.   Cremno
  152.  
  153.     -GDI+ interface code
  154.  
  155.   Cidiomar
  156.  
  157.     -for drawing autotiles and shadows,
  158.  
  159.     -providing efficient bmp and png exporters
  160.  
  161.   Moon
  162.  
  163.     -auto-tile related info
  164.  
  165.   Mephistox
  166.  
  167.     -testing and suggestions
  168.  
  169. ================================================================================
  170.  
  171. =end
  172.  
  173. $imported = {} if $imported.nil?
  174.  
  175. $imported["TH_MapSaver"] = true
  176.  
  177. #===============================================================================
  178.  
  179. # ** Configuration
  180.  
  181. #===============================================================================
  182.  
  183. module TH
  184.  
  185.   module Map_Saver
  186.  
  187.  
  188.  
  189.     #Mapshot options. This takes an image of the entire map
  190.  
  191.     Mapshot_Button = Input::F7
  192.  
  193.     Mapshot_Scale =1
  194.  
  195.  
  196.  
  197.     #Screenshot options. This takes an image of the visible map
  198.  
  199.     Screenshot_Button = Input::F6
  200.  
  201.     Screenshot_Scale = 1
  202.  
  203.  
  204.  
  205.     #Folder that the map will be exported to
  206.  
  207.     Mapshot_Directory = "Mapshots"
  208.  
  209.     Screenshot_Directory = "Screenshots"
  210.  
  211.  
  212.  
  213.     # format you want to export to. You should stick with png.
  214.  
  215.     # Options: [bmp, png]
  216.  
  217.     Export_Format = "png"
  218.  
  219.  
  220.  
  221.     # Sprite draw options
  222.  
  223.     Draw_Events = false
  224.  
  225.     Draw_Player = false
  226.  
  227.     Draw_Followers = false
  228.  
  229.     Draw_Vehicles = false
  230.  
  231.  
  232.  
  233.     #Should shadows be drawn? What color?
  234.  
  235.     Draw_Shadow = true
  236.  
  237.     Shadow_Color = Color.new(0, 0, 0, 128)
  238.  
  239.  
  240.  
  241.     # Should regions be drawn? Requires "Region Overlay Map" script
  242.  
  243.     Draw_Regions = false
  244.  
  245.  
  246.  
  247.     # Should passage settings be drawn? Requires "Passage Overlay Map" script
  248.  
  249.     Draw_Passages = false
  250.  
  251.  
  252.  
  253.     #Should damage tiles be highlighted? What color?
  254.  
  255.     Highlight_Damage = true
  256.  
  257.     Damage_Color = Color.new(128, 0, 0, 128)
  258.  
  259.   end
  260.  
  261. end
  262.  
  263.  
  264.  
  265. #==============================================================================
  266.  
  267. # ** Module: Map_Tiles
  268.  
  269. # Contains data and methods useful for working with maps and tiles
  270.  
  271. #==============================================================================
  272.  
  273.  
  274.  
  275. module Map_Tiles
  276.  
  277.   AUTOTILE_PARTS = [[18,17,14,13], [ 2,14,17,18], [13, 3,17,18], [ 2, 3,17,18],
  278.  
  279.                     [13,14,17, 7], [ 2,14,17, 7], [13, 3,17, 7], [ 2, 3,17, 7],
  280.  
  281.                     [13,14, 6,18], [ 2,14, 6,18], [13, 3, 6,18], [ 2, 3, 6,18],
  282.  
  283.                     [13,14, 6, 7], [ 2,14, 6, 7], [13, 3, 6, 7], [ 2, 3, 6, 7],
  284.  
  285.                     [16,17,12,13], [16, 3,12,13], [16,17,12, 7], [12, 3,16, 7],
  286.  
  287.                     [10, 9,14,13], [10, 9,14, 7], [10, 9, 6,13], [10, 9, 6, 7],
  288.  
  289.                     [18,19,14,15], [18,19, 6,15], [ 2,19,14,15], [ 2,19, 6,15],
  290.  
  291.                     [18,17,22,21], [ 2,17,22,21], [18, 3,22,21], [ 2, 3,21,22],
  292.  
  293.                     [16,19,12,15], [10, 9,22,21], [ 8, 9,12,13], [ 8, 9,12, 7],
  294.  
  295.                     [10,11,14,15], [10,11, 6,15], [18,19,22,23], [ 2,19,22,23],
  296.  
  297.                     [16,17,20,21], [16, 3,20,21], [ 8,11,12,15], [ 8, 9,20,21],
  298.  
  299.                     [16,19,20,23], [10,11,22,23], [ 8,11,20,23], [ 0, 1, 4, 5]]
  300.  
  301.   WATERFALL_PIECES = [[ 2, 1, 6, 5], [ 0, 1, 4, 5], [ 2, 3, 6, 7], [0, 3, 4, 7]]
  302.  
  303.   WALL_PIECES =  [[10, 9, 6, 5], [ 8, 9, 4, 5], [ 2, 1, 6, 5], [ 0, 1, 4, 5],
  304.  
  305.                   [10,11, 6, 7], [ 8,11, 4, 7], [ 2, 3, 6, 7], [ 0, 3, 4, 7],
  306.  
  307.                   [10, 9,14,13], [ 8, 9,12,13], [ 2, 1,14,13], [ 0, 1,12,13],
  308.  
  309.                   [10,11,14,15], [8, 11,12,15], [ 2, 3,14,15], [ 0, 3,12,15]]
  310.  
  311.  
  312.  
  313.   A1_TILES = [[0, 0], [0, 96], [192, 0], [192, 96],
  314.  
  315.                [256, 0], [448, 0], [256, 96], [448, 96],
  316.  
  317.                [0, 192], [192, 192], [0, 288], [192, 288],
  318.  
  319.                [256, 192], [448, 192], [256, 288], [448, 288]]
  320.  
  321.  
  322.  
  323.  
  324.  
  325.   #--------------------------------------------------------------------------
  326.  
  327.   # * Checks if a tile is a wall
  328.  
  329.   #--------------------------------------------------------------------------
  330.  
  331.   def is_wall?(data)
  332.  
  333.     return true if data.between?(2288, 2335)
  334.  
  335.     return true if data.between?(2384, 2431)
  336.  
  337.     return true if data.between?(2480, 2527)
  338.  
  339.     return true if data.between?(2576, 2623)
  340.  
  341.     return true if data.between?(2672, 2719)
  342.  
  343.     return true if data.between?(2768, 2815)
  344.  
  345.     return true if data.between?(4736, 5119)
  346.  
  347.     return true if data.between?(5504, 5887)
  348.  
  349.     return true if data.between?(6272, 6655)
  350.  
  351.     return true if data.between?(7040, 7423)
  352.  
  353.     return true if data > 7807
  354.  
  355.     false
  356.  
  357.   end
  358.  
  359.   #--------------------------------------------------------------------------
  360.  
  361.   # * Checks if a tile is roof
  362.  
  363.   #--------------------------------------------------------------------------
  364.  
  365.   def is_roof?(data)
  366.  
  367.     return true if data.between?(4352, 4735)
  368.  
  369.     return true if data.between?(5120, 5503)
  370.  
  371.     return true if data.between?(5888, 6271)
  372.  
  373.     return true if data.between?(6656, 7039)
  374.  
  375.     return true if data.between?(7424, 7807)
  376.  
  377.     false
  378.  
  379.   end  
  380.  
  381.   #--------------------------------------------------------------------------
  382.  
  383.   # * Checks if a tile is soil
  384.  
  385.   #--------------------------------------------------------------------------
  386.  
  387.   def is_soil?(data)
  388.  
  389.     return true if data.between?(2816, 4351) && !is_table?(data)
  390.  
  391.     return true if data > 1663 && !is_stair?(data)
  392.  
  393.     false
  394.  
  395.   end   
  396.  
  397.   #--------------------------------------------------------------------------
  398.  
  399.   # * Checks if a tile is a stair
  400.  
  401.   #--------------------------------------------------------------------------
  402.  
  403.   def is_stair?(data)
  404.  
  405.      return true if data.between?(1541, 1542)
  406.  
  407.      return true if data.between?(1549, 1550)
  408.  
  409.      return true if data.between?(1600, 1615)
  410.  
  411.      false
  412.  
  413.   end
  414.  
  415.   #--------------------------------------------------------------------------
  416.  
  417.   # * Checks if a tile is a table
  418.  
  419.   #--------------------------------------------------------------------------
  420.  
  421.   def is_table?(data)
  422.  
  423.     return true if data.between?(3152, 3199)
  424.  
  425.     return true if data.between?(3536, 3583)
  426.  
  427.     return true if data.between?(3920, 3967)
  428.  
  429.     return true if data.between?(4304, 4351)
  430.  
  431.     false
  432.  
  433.   end
  434.  
  435.  
  436.  
  437.   #--------------------------------------------------------------------------
  438.  
  439.   # * The tileset to be used
  440.  
  441.   #--------------------------------------------------------------------------
  442.  
  443.   def tileset
  444.  
  445.     $data_tilesets[@tileset_id]
  446.  
  447.   end
  448.  
  449.  
  450.  
  451.   #--------------------------------------------------------------------------
  452.  
  453.   # * Region ID
  454.  
  455.   #--------------------------------------------------------------------------
  456.  
  457.   def region_id(x, y)
  458.  
  459.     valid?(x, y) ? @map.data[x, y, 3] >> 8 : 0
  460.  
  461.   end
  462.  
  463.  
  464.  
  465.   #--------------------------------------------------------------------------
  466.  
  467.   # * Gets all of the tiles for each layer at position x,y
  468.  
  469.   #--------------------------------------------------------------------------
  470.  
  471.   def layered_tiles(x, y)
  472.  
  473.     [2, 1, 0].collect {|z| @map.data[x, y, z] }
  474.  
  475.   end
  476.  
  477.  
  478.  
  479.   def layered_tiles_flag?(x, y, bit)
  480.  
  481.     layered_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 }
  482.  
  483.   end
  484.  
  485.  
  486.  
  487.   def valid?(x, y)
  488.  
  489.     x >= 0 && x < width && y >= 0 && y < height
  490.  
  491.   end
  492.  
  493.  
  494.  
  495.   def damage_floor?(x, y)
  496.  
  497.     valid?(x, y) && layered_tiles_flag?(x, y, 0x100)
  498.  
  499.   end
  500.  
  501.  
  502.  
  503.   #--------------------------------------------------------------------------
  504.  
  505.   # * Specifies which type of autotile is used
  506.  
  507.   #--------------------------------------------------------------------------
  508.  
  509.   def auto_tile(id)
  510.  
  511.     id / 48
  512.  
  513.   end
  514.  
  515.  
  516.  
  517.   #--------------------------------------------------------------------------
  518.  
  519.   # * Specifies the specific arrangement of autotiles used
  520.  
  521.   #--------------------------------------------------------------------------
  522.  
  523.   def auto_index(id)
  524.  
  525.     id % 48
  526.  
  527.   end
  528.  
  529.  
  530.  
  531.   #--------------------------------------------------------------------------
  532.  
  533.   # * Put the auto-tile pieces together
  534.  
  535.   #--------------------------------------------------------------------------
  536.  
  537.   def make_autotile(rects, sx, sy)
  538.  
  539.     @tile.clear
  540.  
  541.     for i in 0...4
  542.  
  543.       @auto_rect.x = (rects[i] % 4) * 16 + sx
  544.  
  545.       @auto_rect.y = (rects[i] / 4) * 16 + sy
  546.  
  547.       @tile.blt((i % 2) * 16,(i / 2) * 16, @tilemap, @auto_rect)
  548.  
  549.     end
  550.  
  551.   end
  552.  
  553.  
  554.  
  555.   #--------------------------------------------------------------------------
  556.  
  557.   # * Get auto-tile A1 tiles
  558.  
  559.   #--------------------------------------------------------------------------
  560.  
  561.   def autotile_A1(tile_id)
  562.  
  563.     @tilemap = @bitmaps[0]
  564.  
  565.     autotile = tile_id / 48
  566.  
  567.     auto_id = tile_id % 48
  568.  
  569.     sx, sy = A1_TILES[autotile]
  570.  
  571.     if is_wall?(tile_id + 2048)
  572.  
  573.       rects = WATERFALL_PIECES[auto_id]
  574.  
  575.     else  
  576.  
  577.       rects = AUTOTILE_PARTS[auto_id]
  578.  
  579.     end
  580.  
  581.     make_autotile(rects, sx, sy)
  582.  
  583.   end
  584.  
  585.  
  586.  
  587.   #--------------------------------------------------------------------------
  588.  
  589.   # * Get auto-tile A2 tiles.
  590.  
  591.   # 64x96 tiles, 8 per row, 4 rows
  592.  
  593.   #--------------------------------------------------------------------------
  594.  
  595.   def autotile_A2(tile_id)
  596.  
  597.     autotile = tile_id / 48
  598.  
  599.     auto_id = tile_id % 48
  600.  
  601.     @tilemap = @bitmaps[1]
  602.  
  603.     sx = (autotile % 8) * 64
  604.  
  605.     sy = (autotile / 8 % 4) * 96
  606.  
  607.     rects = AUTOTILE_PARTS[auto_id]
  608.  
  609.     make_autotile(rects, sx, sy)
  610.  
  611.   end
  612.  
  613.  
  614.  
  615.   #--------------------------------------------------------------------------
  616.  
  617.   # * Get auto-tile A3 tiles.
  618.  
  619.   # 64x64 tiles, 8 per row, 4 rows
  620.  
  621.   #--------------------------------------------------------------------------
  622.  
  623.   def autotile_A3(tid)
  624.  
  625.     @tilemap = @bitmaps[2]
  626.  
  627.     sx = (auto_tile(tid) % 8) * 64
  628.  
  629.     sy = (auto_tile(tid) / 8 % 4) * 64
  630.  
  631.     rects = WALL_PIECES[auto_index(tid)]
  632.  
  633.     make_autotile(rects, sx, sy)
  634.  
  635.   end
  636.  
  637.  
  638.  
  639.   #--------------------------------------------------------------------------
  640.  
  641.   # * Get auto-tile A4 tiles (walls)
  642.  
  643.   #--------------------------------------------------------------------------
  644.  
  645.   def autotile_A4(tile_id)
  646.  
  647.     @tilemap = @bitmaps[3]
  648.  
  649.     autotile = tile_id / 48
  650.  
  651.     auto_id = tile_id % 48
  652.  
  653.     sx = (autotile % 8) * 64
  654.  
  655.     sy = (autotile / 16 * 160) + (autotile / 8 % 2) * 96
  656.  
  657.     if is_wall?(tile_id + 5888)
  658.  
  659.       rects = WALL_PIECES[auto_id]
  660.  
  661.     else
  662.  
  663.       rects = AUTOTILE_PARTS[auto_id]
  664.  
  665.     end
  666.  
  667.     make_autotile(rects, sx, sy)
  668.  
  669.   end
  670.  
  671.  
  672.  
  673.   #--------------------------------------------------------------------------
  674.  
  675.   # * Get auto-tile A5 tiles (normal)
  676.  
  677.   #--------------------------------------------------------------------------
  678.  
  679.   def autotile_A5(tile_id)
  680.  
  681.     @tilemap = @bitmaps[4]
  682.  
  683.     sx = (tile_id) % 8 * tilesize
  684.  
  685.     sy = (tile_id) / 8 * tilesize
  686.  
  687.     @src_rect.set(sx, sy, tilesize, tilesize)
  688.  
  689.     @tile.clear
  690.  
  691.     @tile.blt(0, 0, @tilemap, @src_rect)
  692.  
  693.   end
  694.  
  695.  
  696.  
  697.   #--------------------------------------------------------------------------
  698.  
  699.   # * Get normal tiles B, C, D, E
  700.  
  701.   #--------------------------------------------------------------------------
  702.  
  703.   def normal_tile(tile_id)
  704.  
  705.     @tilemap = @bitmaps[5 + tile_id / 256]
  706.  
  707.     sx = (tile_id / 128 % 2 * 8 + tile_id % 8) * tilesize;
  708.  
  709.     sy = (tile_id % 256 / 8 % 16) * tilesize;
  710.  
  711.     @src_rect.set(sx, sy, tilesize, tilesize)
  712.  
  713.     @tile.clear
  714.  
  715.     @tile.blt(0, 0, @tilemap, @src_rect)
  716.  
  717.   end
  718.  
  719.  
  720.  
  721.   #--------------------------------------------------------------------------
  722.  
  723.   # * Get bitmap for the specified tile id
  724.  
  725.   #--------------------------------------------------------------------------
  726.  
  727.   def get_bitmap(id)
  728.  
  729.     if id < 1024
  730.  
  731.       normal_tile(id)
  732.  
  733.     elsif id < 1664
  734.  
  735.       autotile_A5(id - 1536)
  736.  
  737.     elsif id < 2816
  738.  
  739.       autotile_A1(id - 2048)
  740.  
  741.     elsif id < 4352
  742.  
  743.       autotile_A2(id - 2816)
  744.  
  745.     elsif id < 5888
  746.  
  747.       autotile_A3(id - 4352)
  748.  
  749.     else
  750.  
  751.       autotile_A4(id - 5888)
  752.  
  753.     end
  754.  
  755.   end
  756.  
  757. end
  758.  
  759.  
  760.  
  761. #==============================================================================
  762.  
  763. # **
  764.  
  765. #==============================================================================
  766.  
  767.  
  768.  
  769. class Game_Player < Game_Character
  770.  
  771.  
  772.  
  773.   alias :th_mapsaver_update :update
  774.  
  775.   def update
  776.  
  777.     th_mapsaver_update
  778.  
  779.     if Input.trigger?(TH::Map_Saver::Mapshot_Button)
  780.  
  781.       s = Map_Saver.new($game_map.map_id)
  782.  
  783.       s.set_scale(TH::Map_Saver::Mapshot_Scale)
  784.  
  785.       s.mapshot
  786.  
  787.     end
  788.  
  789.     if Input.trigger?(TH::Map_Saver::Screenshot_Button)
  790.  
  791.       s = Map_Saver.new($game_map.map_id)
  792.  
  793.       s.set_scale(TH::Map_Saver::Screenshot_Scale)
  794.  
  795.       s.screenshot
  796.  
  797.     end
  798.  
  799.   end
  800.  
  801. end
  802.  
  803.  
  804.  
  805. class Game_Vehicle < Game_Character
  806.  
  807.   attr_reader :map_id
  808.  
  809. end
  810.  
  811.  
  812.  
  813. class Game_Map
  814.  
  815.   attr_reader :map
  816.  
  817. end
  818.  
  819.  
  820.  
  821. #==============================================================================
  822.  
  823. # **
  824.  
  825. #==============================================================================
  826.  
  827.  
  828.  
  829. class Map_Saver
  830.  
  831.   include TH::Map_Saver
  832.  
  833.   include Map_Tiles
  834.  
  835.   #--------------------------------------------------------------------------
  836.  
  837.   # * Constants
  838.  
  839.   #--------------------------------------------------------------------------
  840.  
  841.  
  842.  
  843.   SHADOW_COLOR = TH::Map_Saver::Shadow_Color
  844.  
  845.   DAMAGE_COLOR = TH::Map_Saver::Damage_Color
  846.  
  847.  
  848.  
  849.   #--------------------------------------------------------------------------
  850.  
  851.   # * Public instance variables
  852.  
  853.   #--------------------------------------------------------------------------
  854.  
  855.   attr_reader :map_image
  856.  
  857.  
  858.  
  859.   def initialize(map_id=$game_map.map_id, x=$game_player.x, y=$game_player.y)
  860.  
  861.     @scale = 1
  862.  
  863.     @local_x = x
  864.  
  865.     @local_y = y
  866.  
  867.     @screen_local = false
  868.  
  869.     @shadow_bitmap = Bitmap.new(128, 128)
  870.  
  871.     @draw_layer0 = true
  872.  
  873.     @draw_layer1 = true
  874.  
  875.     @draw_layer2 = true
  876.  
  877.     @draw_events = Draw_Events
  878.  
  879.     @draw_vehicles = Draw_Vehicles
  880.  
  881.     @draw_player = Draw_Player
  882.  
  883.     @draw_followers = Draw_Followers
  884.  
  885.     @draw_shadow = Draw_Shadow
  886.  
  887.     @draw_damage = Highlight_Damage
  888.  
  889.     @draw_regions = Draw_Regions
  890.  
  891.     @draw_passages = Draw_Passages
  892.  
  893.     @tile = Bitmap.new(32, 32) #stores the current tile to be drawn
  894.  
  895.     @tilemap = nil
  896.  
  897.     @src_rect = Rect.new
  898.  
  899.     @auto_rect = Rect.new(0, 0, tilesize / 2, tilesize/ 2) #constant
  900.  
  901.     @tile_rect = Rect.new(0, 0, tilesize, tilesize)        #constant
  902.  
  903.   end
  904.  
  905.  
  906.  
  907.   def load_tilesets
  908.  
  909.     bitmaps = []
  910.  
  911.     tileset.tileset_names.each_with_index do |name, i|
  912.  
  913.       bitmaps[i] = Cache.tileset(name)
  914.  
  915.     end
  916.  
  917.     return bitmaps
  918.  
  919.   end
  920.  
  921.  
  922.  
  923.   #--------------------------------------------------------------------------
  924.  
  925.   # * Refresh, possibly with a new map
  926.  
  927.   #--------------------------------------------------------------------------
  928.  
  929.   def redraw(map_id=$game_map.map_id, x=$game_player.x, y=$game_player.y)
  930.  
  931.     @map_image.dispose if @map_image
  932.  
  933.     @map_id = map_id
  934.  
  935.     @local_x = x
  936.  
  937.     @local_y = y
  938.  
  939.     @game_map = Game_Map.new
  940.  
  941.     @game_map.setup(map_id)
  942.  
  943.     @map = @game_map.map
  944.  
  945.     @map_info = $data_mapinfos[map_id]
  946.  
  947.     @screen = $game_map.screen
  948.  
  949.     @tileset_id = @game_map.tileset.id
  950.  
  951.     @bitmaps = load_tilesets
  952.  
  953.  
  954.  
  955.     get_bounds
  956.  
  957.     @map_image = Bitmap.new(@width * tilesize, @height * tilesize)
  958.  
  959.     draw_map
  960.  
  961.     scale_map if @scale != 1
  962.  
  963.   end
  964.  
  965.  
  966.  
  967.   #--------------------------------------------------------------------------
  968.  
  969.   # * Pre-process. These will never change when drawing the map.
  970.  
  971.   #--------------------------------------------------------------------------
  972.  
  973.   def get_bounds
  974.  
  975.     @start_x = start_x
  976.  
  977.     @start_y = start_y
  978.  
  979.     @end_x = end_x
  980.  
  981.     @end_y = end_y
  982.  
  983.     @width = width
  984.  
  985.     @height = height
  986.  
  987.     @tilesize = tilesize
  988.  
  989.   end
  990.  
  991.  
  992.  
  993.   def screen_tile_x
  994.  
  995.     Graphics.width / 32
  996.  
  997.   end
  998.  
  999.  
  1000.  
  1001.   def screen_tile_y
  1002.  
  1003.     Graphics.height / 32
  1004.  
  1005.   end
  1006.  
  1007.  
  1008.  
  1009.   #--------------------------------------------------------------------------
  1010.  
  1011.   # * Sets the scale for the map
  1012.  
  1013.   #--------------------------------------------------------------------------
  1014.  
  1015.   def set_scale(scale)
  1016.  
  1017.     @scale = scale
  1018.  
  1019.   end
  1020.  
  1021.  
  1022.  
  1023.   #--------------------------------------------------------------------------
  1024.  
  1025.   # * Size of a tile
  1026.  
  1027.   #--------------------------------------------------------------------------
  1028.  
  1029.   def tilesize
  1030.  
  1031.     32
  1032.  
  1033.   end
  1034.  
  1035.  
  1036.  
  1037.   #--------------------------------------------------------------------------
  1038.  
  1039.   # * Width and height of the map, both locally and globally
  1040.  
  1041.   #--------------------------------------------------------------------------
  1042.  
  1043.   def width
  1044.  
  1045.     end_x - @start_x
  1046.  
  1047.   end
  1048.  
  1049.  
  1050.  
  1051.   def height
  1052.  
  1053.     end_y - @start_y
  1054.  
  1055.   end
  1056.  
  1057.  
  1058.  
  1059.   #--------------------------------------------------------------------------
  1060.  
  1061.   # * Starting and end positions, relative to the screen or map
  1062.  
  1063.   #--------------------------------------------------------------------------
  1064.  
  1065.   def start_x
  1066.  
  1067.     @screen_local ? [[$game_player.x - screen_tile_x / 2, @map.width - screen_tile_x].min, 0].max : 0
  1068.  
  1069.   end
  1070.  
  1071.  
  1072.  
  1073.   def start_y
  1074.  
  1075.     @screen_local ? [[$game_player.y - screen_tile_y / 2, @map.height - screen_tile_y].min, 0].max : 0
  1076.  
  1077.   end
  1078.  
  1079.  
  1080.  
  1081.   def end_x
  1082.  
  1083.     @screen_local ? [[screen_tile_x, @local_x + screen_tile_x / 2 + 1].max, @map.width].min : @map.width
  1084.  
  1085.   end
  1086.  
  1087.  
  1088.  
  1089.   def end_y
  1090.  
  1091.     @screen_local ? [[screen_tile_y, @local_y + screen_tile_y / 2 + 1].max, @map.height].min : @map.height
  1092.  
  1093.   end
  1094.  
  1095.  
  1096.  
  1097.   #--------------------------------------------------------------------------
  1098.  
  1099.   # * Draw tile onto image. x and y values are absolute coords. They should
  1100.  
  1101.   # be re-mapped based on the start_x and start_y values
  1102.  
  1103.   #--------------------------------------------------------------------------
  1104.  
  1105.   def draw_tile(x, y, tile, rect)
  1106.  
  1107.     ox = (x - @start_x) * tilesize
  1108.  
  1109.     oy = (y - @start_y) * tilesize
  1110.  
  1111.     @map_image.blt(ox, oy, tile, rect)
  1112.  
  1113.   end
  1114.  
  1115.  
  1116.  
  1117.   #--------------------------------------------------------------------------
  1118.  
  1119.   # * Get bitmap for the specified character
  1120.  
  1121.   #--------------------------------------------------------------------------
  1122.  
  1123.   def get_character_bitmap(name)
  1124.  
  1125.     charmap = Cache.character(name)
  1126.  
  1127.     sign = name[/^[\!\$]./]
  1128.  
  1129.     if sign && sign.include?('$')
  1130.  
  1131.       cw = charmap.width / 3
  1132.  
  1133.       ch = charmap.height / 4
  1134.  
  1135.     else
  1136.  
  1137.       cw = charmap.width / 12
  1138.  
  1139.       ch = charmap.height / 8
  1140.  
  1141.     end
  1142.  
  1143.     return charmap, cw, ch
  1144.  
  1145.   end
  1146.  
  1147.  
  1148.  
  1149.   #--------------------------------------------------------------------------
  1150.  
  1151.   # * Draw the character onto the tile
  1152.  
  1153.   #--------------------------------------------------------------------------
  1154.  
  1155.   def set_character_bitmap(character, x, y)
  1156.  
  1157.     charmap, cw, ch = get_character_bitmap(character.character_name)
  1158.  
  1159.     index = character.character_index
  1160.  
  1161.     pattern = character.pattern < 3 ? character.pattern : 1
  1162.  
  1163.     sx = (index % 4 * 3 + pattern) * cw
  1164.  
  1165.     sy = (index / 4 * 4 + (character.direction - 2) / 2) * ch
  1166.  
  1167.     @src_rect.set(sx, sy, cw, ch)
  1168.  
  1169.     x -= cw / (@tilesize * 2) if cw >= @tilesize
  1170.  
  1171.     y -= ch / (@tilesize * 2) if ch >= @tilesize  
  1172.  
  1173.     draw_tile(x, y, charmap, @src_rect)
  1174.  
  1175.   end
  1176.  
  1177.  
  1178.  
  1179.   #--------------------------------------------------------------------------
  1180.  
  1181.   # * create the shadow map
  1182.  
  1183.   #--------------------------------------------------------------------------
  1184.  
  1185.   def make_shadow_map
  1186.  
  1187.     for s in 0 ... 16
  1188.  
  1189.       x = s % 4
  1190.  
  1191.       y = s / 4
  1192.  
  1193.       if s & 0b1000 == 0b1000
  1194.  
  1195.         @shadow_bitmap.fill_rect(x*tilesize+16, y*@tilesize+16, 16, 16, SHADOW_COLOR)
  1196.  
  1197.       end
  1198.  
  1199.       if s & 0b0100 == 0b0100
  1200.  
  1201.         @shadow_bitmap.fill_rect(x*tilesize, y*@tilesize+16, 16, 16, SHADOW_COLOR)
  1202.  
  1203.       end
  1204.  
  1205.       if s & 0b0010 == 0b0010
  1206.  
  1207.         @shadow_bitmap.fill_rect(x*tilesize+16, y*@tilesize, 16, 16, SHADOW_COLOR)
  1208.  
  1209.       end
  1210.  
  1211.       if s & 0b0001 == 0b0001
  1212.  
  1213.         @shadow_bitmap.fill_rect(x*tilesize, y*@tilesize, 16, 16, SHADOW_COLOR)
  1214.  
  1215.       end
  1216.  
  1217.     end
  1218.  
  1219.   end
  1220.  
  1221.  
  1222.  
  1223.   def draw_parallax
  1224.  
  1225.     image = Cache.parallax(@map.parallax_name)
  1226.  
  1227.     @src_rect.set(0, 0, image.width, image.height)
  1228.  
  1229.     @map_image.blt(0, 0, image, @src_rect)
  1230.  
  1231.   end
  1232.  
  1233.  
  1234.  
  1235.   #--------------------------------------------------------------------------
  1236.  
  1237.   # * Draw the shadow map
  1238.  
  1239.   #--------------------------------------------------------------------------
  1240.  
  1241.   def draw_shadow_map
  1242.  
  1243.     for x in @start_x ... @end_x
  1244.  
  1245.       for y in @start_y ... @end_y
  1246.  
  1247.       _x, _y = x*@tilesize, y*@tilesize
  1248.  
  1249.         s = @map.data[x, y, 3]  & 0b1111
  1250.  
  1251.         if s != 0
  1252.  
  1253.           x_ = (s % 4) * @tilesize
  1254.  
  1255.           y_ = (s / 4) * @tilesize
  1256.  
  1257.           @src_rect.set(x_, y_, @tilesize, @tilesize)
  1258.  
  1259.           draw_tile(x, y, @shadow_bitmap, @src_rect)
  1260.  
  1261.         end
  1262.  
  1263.       end
  1264.  
  1265.     end
  1266.  
  1267.   end
  1268.  
  1269.  
  1270.  
  1271.   #--------------------------------------------------------------------------
  1272.  
  1273.   # * Draw the specified layer
  1274.  
  1275.   #--------------------------------------------------------------------------
  1276.  
  1277.   def draw_layer(layer)
  1278.  
  1279.     for x in @start_x ... @end_x
  1280.  
  1281.       for y in @start_y ... @end_y
  1282.  
  1283.         _x, _y = x*@tilesize, y*@tilesize
  1284.  
  1285.         tile_id = @map.data[x, y, layer]
  1286.  
  1287.         next if tile_id == 0
  1288.  
  1289.         get_bitmap(tile_id)
  1290.  
  1291.         draw_tile(x, y, @tile, @tile_rect)
  1292.  
  1293.       end
  1294.  
  1295.     end
  1296.  
  1297.   end
  1298.  
  1299.  
  1300.  
  1301.   #-----------------------------------------------------------------------------
  1302.  
  1303.   # Draw game regions
  1304.  
  1305.   #-----------------------------------------------------------------------------
  1306.  
  1307.   def draw_regions
  1308.  
  1309.     if $imported["TH_RegionOverlay"]
  1310.  
  1311.       image = SceneManager.scene.instance_variable_get(:@spriteset).instance_variable_get(:@region_map).bitmap
  1312.  
  1313.       @src_rect.set(@start_x * tilesize, @start_y * tilesize, image.width, image.height)
  1314.  
  1315.       @map_image.blt(0, 0, image, @src_rect, 255)
  1316.  
  1317.     end
  1318.  
  1319.   end
  1320.  
  1321.  
  1322.  
  1323.   def draw_passages
  1324.  
  1325.     if $imported["TH_OverlayPassageMap"]
  1326.  
  1327.       image = SceneManager.scene.instance_variable_get(:@spriteset).instance_variable_get(:@passage_map).bitmap
  1328.  
  1329.       @src_rect.set(@start_x * tilesize, @start_y * tilesize, image.width, image.height)
  1330.  
  1331.       @map_image.blt(0, 0, image, @src_rect, 255)
  1332.  
  1333.     end
  1334.  
  1335.   end
  1336.  
  1337.  
  1338.  
  1339.   #--------------------------------------------------------------------------
  1340.  
  1341.   # * Draw the game player
  1342.  
  1343.   #--------------------------------------------------------------------------
  1344.  
  1345.   def draw_player
  1346.  
  1347.     set_character_bitmap($game_player, $game_player.x, $game_player.y) if @map_id == $game_map.map_id
  1348.  
  1349.   end
  1350.  
  1351.  
  1352.  
  1353.   def draw_followers
  1354.  
  1355.   end
  1356.  
  1357.  
  1358.  
  1359.   #--------------------------------------------------------------------------
  1360.  
  1361.   # * Draw map events
  1362.  
  1363.   #--------------------------------------------------------------------------
  1364.  
  1365.   def draw_events
  1366.  
  1367.     @map.events.values.each do |event|
  1368.  
  1369.       id = event.pages[0].graphic.tile_id
  1370.  
  1371.       char_name = event.pages[0].graphic.character_name
  1372.  
  1373.       if id > 0
  1374.  
  1375.         normal_tile(id)
  1376.  
  1377.         draw_tile(event.x, event.y, @tilemap, @src_rect)
  1378.  
  1379.       elsif char_name != ""
  1380.  
  1381.         set_character_bitmap(event.pages[0].graphic, event.x, event.y)
  1382.  
  1383.       end
  1384.  
  1385.     end
  1386.  
  1387.   end
  1388.  
  1389.  
  1390.  
  1391.   #--------------------------------------------------------------------------
  1392.  
  1393.   # * Draw map vehicles
  1394.  
  1395.   #--------------------------------------------------------------------------
  1396.  
  1397.   def draw_vehicles
  1398.  
  1399.     $game_map.vehicles.each do |vehicle|
  1400.  
  1401.       set_character_bitmap(vehicle, vehicle.x, vehicle.y,) if @map_id == vehicle.map_id
  1402.  
  1403.     end
  1404.  
  1405.   end
  1406.  
  1407.  
  1408.  
  1409.   #--------------------------------------------------------------------------
  1410.  
  1411.   # * Draw map sprites
  1412.  
  1413.   #--------------------------------------------------------------------------
  1414.  
  1415.   def draw_sprites
  1416.  
  1417.     draw_events if @draw_events
  1418.  
  1419.     draw_vehicles if @draw_vehicles
  1420.  
  1421.     draw_player if @draw_player
  1422.  
  1423.     draw_followers if @draw_followers
  1424.  
  1425.   end
  1426.  
  1427.  
  1428.  
  1429.   #--------------------------------------------------------------------------
  1430.  
  1431.   # * Highlight damage tiles
  1432.  
  1433.   #--------------------------------------------------------------------------
  1434.  
  1435.   def draw_damage
  1436.  
  1437.     @tile.clear
  1438.  
  1439.     @tile.fill_rect(0, 0, @tilesize, @tilesize, DAMAGE_COLOR)
  1440.  
  1441.     @src_rect.set(0, 0, @tilesize, @tilesize)
  1442.  
  1443.     for x in @start_x ... @end_x
  1444.  
  1445.       for y in @start_y ... @end_y
  1446.  
  1447.         _x, _y = x*@tilesize, y*@tilesize
  1448.  
  1449.         if damage_floor?(x, y)
  1450.  
  1451.           draw_tile(x, y, @tile, @src_rect)
  1452.  
  1453.         end
  1454.  
  1455.       end
  1456.  
  1457.     end
  1458.  
  1459.   end
  1460.  
  1461.  
  1462.  
  1463.   def draw_screen_effects
  1464.  
  1465.   end
  1466.  
  1467.   #--------------------------------------------------------------------------
  1468.  
  1469.   # * Draw the map
  1470.  
  1471.   #--------------------------------------------------------------------------
  1472.  
  1473.   def draw_map
  1474.  
  1475.     make_shadow_map if @draw_shadow
  1476.  
  1477.     draw_parallax
  1478.  
  1479.     draw_layer(0)
  1480.  
  1481.     draw_layer(1)
  1482.  
  1483.     draw_shadow_map
  1484.  
  1485.     draw_layer(2)
  1486.  
  1487.     draw_damage if @draw_damage
  1488.  
  1489.     draw_regions if @draw_regions
  1490.  
  1491.     draw_passages if @draw_passages
  1492.  
  1493.     draw_sprites
  1494.  
  1495.     draw_screen_effects
  1496.  
  1497.   end
  1498.  
  1499.  
  1500.  
  1501.   #--------------------------------------------------------------------------
  1502.  
  1503.   # * Scale the map
  1504.  
  1505.   #--------------------------------------------------------------------------
  1506.  
  1507.   def scale_map
  1508.  
  1509.     nw = @width * @scale
  1510.  
  1511.     nh = @height * @scale
  1512.  
  1513.     @src_rect.set(0, 0, @width, @height)
  1514.  
  1515.     scaled_map = Bitmap.new(nw, nh)
  1516.  
  1517.     scaled_rect = Rect.new(0, 0, nw, nh)
  1518.  
  1519.     scaled_map.stretch_blt(scaled_rect, @map_image, @src_rect)
  1520.  
  1521.     @map_image = scaled_map
  1522.  
  1523.   end
  1524.  
  1525.  
  1526.  
  1527.   #--------------------------------------------------------------------------
  1528.  
  1529.   # * Take a mapshot of the map
  1530.  
  1531.   #--------------------------------------------------------------------------
  1532.  
  1533.   def mapshot
  1534.  
  1535.     @screen_local = false
  1536.  
  1537.     redraw
  1538.  
  1539.     export(TH::Map_Saver::Mapshot_Directory)
  1540.  
  1541.     $game_message.add("Mapshot taken")
  1542.  
  1543.   end
  1544.  
  1545.  
  1546.  
  1547.   #--------------------------------------------------------------------------
  1548.  
  1549.   # * Take a screenshot of the map
  1550.  
  1551.   #--------------------------------------------------------------------------
  1552.  
  1553.   def screenshot
  1554.  
  1555.     @screen_local = true
  1556.  
  1557.     redraw
  1558.  
  1559.     export(TH::Map_Saver::Screenshot_Directory)
  1560.  
  1561.     $game_message.add("Screenshot taken")
  1562.  
  1563.   end
  1564.  
  1565.  
  1566.  
  1567.   #--------------------------------------------------------------------------
  1568.  
  1569.   # * Get the format to export to
  1570.  
  1571.   #--------------------------------------------------------------------------
  1572.  
  1573.   def get_format
  1574.  
  1575.     TH::Map_Saver::Export_Format
  1576.  
  1577.   end
  1578.  
  1579.  
  1580.  
  1581.   #--------------------------------------------------------------------------
  1582.  
  1583.   # * Export the map to a file
  1584.  
  1585.   #--------------------------------------------------------------------------
  1586.  
  1587.   def export(dirName="")
  1588.  
  1589.     format = get_format
  1590.  
  1591.     name = @map.display_name != "" ? @map.display_name : @map_info.name
  1592.  
  1593.     Dir.mkdir(dirName) unless File.directory?(dirName)
  1594.  
  1595.     filename = "%s\\%s.%s" %[dirName, name, format]
  1596.  
  1597.     t1 = Time.now
  1598.  
  1599.     @map_image.save(filename)
  1600.  
  1601.     t2 = Time.now
  1602.  
  1603.     $game_message.add("Exported in %f seconds" %[t2 - t1])
  1604.  
  1605.   end
  1606.  
  1607. end
  1608.  
  1609.  
  1610.  
  1611. class Bitmap
  1612.  
  1613.  
  1614.  
  1615.   def save(filename, options = {})
  1616.  
  1617.     options.merge!(format: File.extname(filename)[1..-1].to_sym)
  1618.  
  1619.     retval = false
  1620.  
  1621.     #bitmap = Gdiplus::Bitmap.new(:hbitmap, hbitmap)
  1622.  
  1623.     #bitmap = Gdiplus::Bitmap.new(:gdidib, *gdidib)
  1624.  
  1625.     # this seems to be the fastest one (RGSS 3.0.1, Windows 8 64-bit)
  1626.  
  1627.     bitmap = Gdiplus::Bitmap.new(:scan0, width, height, scan0)
  1628.  
  1629.     if bitmap
  1630.  
  1631.       retval = bitmap.save(:file, filename, options[:format])
  1632.  
  1633.       bitmap.dispose
  1634.  
  1635.     end
  1636.  
  1637.     retval
  1638.  
  1639.   end
  1640.  
  1641.  
  1642.  
  1643. private
  1644.  
  1645.  
  1646.  
  1647.   def _data_struct(offset = 0)
  1648.  
  1649.     @_data_struct ||= (DL::CPtr.new((object_id << 1) + 16).ptr + 8).ptr
  1650.  
  1651.     (@_data_struct + offset).ptr.to_i
  1652.  
  1653.   end
  1654.  
  1655.  
  1656.  
  1657.   def gdidib
  1658.  
  1659.      [_data_struct(8), _data_struct(16)]
  1660.  
  1661.   end
  1662.  
  1663.  
  1664.  
  1665.   def hbitmap
  1666.  
  1667.     _data_struct(44)
  1668.  
  1669.   end
  1670.  
  1671.  
  1672.  
  1673.   def scan0
  1674.  
  1675.     _data_struct(12)
  1676.  
  1677.   end
  1678.  
  1679.  
  1680.  
  1681. end
  1682.  
  1683.  
  1684.  
  1685. # ★ GDI+ interface
  1686.  
  1687. # ★★★★★★★★★★★★
  1688.  
  1689. #
  1690.  
  1691. # Author : Cremno
  1692.  
  1693. #
  1694.  
  1695.  
  1696.  
  1697. module Gdiplus
  1698.  
  1699.   DLL = 'gdiplus.dll'
  1700.  
  1701.  
  1702.  
  1703.   def self.get_function name, import, export = 'L'
  1704.  
  1705.     Win32API.new DLL, name, import, export
  1706.  
  1707.   end
  1708.  
  1709.  
  1710.  
  1711.   FUNCTIONS = {
  1712.  
  1713.     GdiplusStartup: get_function('GdiplusStartup', 'PPP'),
  1714.  
  1715.     GdiplusShutdown: get_function('GdiplusShutdown', 'P', 'V'),
  1716.  
  1717.     GdipDisposeImage: get_function('GdipDisposeImage', 'P'),
  1718.  
  1719.     GdipSaveImageToFile: get_function('GdipSaveImageToFile', 'PPPP'),
  1720.  
  1721.     GdipCreateBitmapFromGdiDib: get_function('GdipCreateBitmapFromGdiDib', 'LLP'),
  1722.  
  1723.     GdipCreateBitmapFromHBITMAP: get_function('GdipCreateBitmapFromHBITMAP', 'LLP'),
  1724.  
  1725.     GdipCreateBitmapFromScan0: get_function('GdipCreateBitmapFromScan0', 'LLLLPP')
  1726.  
  1727.   }
  1728.  
  1729.  
  1730.  
  1731.   @@token = [0].pack('I')
  1732.  
  1733.   def self.token
  1734.  
  1735.     @@token
  1736.  
  1737.   end
  1738.  
  1739.  
  1740.  
  1741.   @@clsids = {}
  1742.  
  1743.   def self.clsids
  1744.  
  1745.     @@clsids
  1746.  
  1747.   end
  1748.  
  1749.  
  1750.  
  1751.   def self.gen_clsids
  1752.  
  1753.     return unless @@clsids.empty?
  1754.  
  1755.     func = Win32API.new('rpcrt4.dll', 'UuidFromString', 'PP', 'L')
  1756.  
  1757.     {
  1758.  
  1759.       bmp:  '557cf400-1a04-11d3-9a73-0000f81ef32e',
  1760.  
  1761.       jpeg: '557cf401-1a04-11d3-9a73-0000f81ef32e',
  1762.  
  1763.       gif:  '557cf402-1a04-11d3-9a73-0000f81ef32e',
  1764.  
  1765.       tiff: '557cf405-1a04-11d3-9a73-0000f81ef32e',
  1766.  
  1767.       png:  '557cf406-1a04-11d3-9a73-0000f81ef32e'
  1768.  
  1769.     }.each_pair do |k, v|
  1770.  
  1771.       clsid = [0].pack('I')
  1772.  
  1773.       func.call(v, clsid)
  1774.  
  1775.       @@clsids[k] = clsid
  1776.  
  1777.     end
  1778.  
  1779.     @@clsids[:jpg] = @@clsids[:jpeg]
  1780.  
  1781.     @@clsids[:tif] = @@clsids[:tiff]
  1782.  
  1783.   end
  1784.  
  1785.  
  1786.  
  1787.   # TODO: prepend prefix (Gdip or Gdiplus) automatically
  1788.  
  1789.   def self.call(*args)
  1790.  
  1791.     name = args.shift
  1792.  
  1793.     func = FUNCTIONS[name]
  1794.  
  1795.     v = func.call(*args)
  1796.  
  1797.     if v && v != 0
  1798.  
  1799.       msgbox "GDI+ error: #{v}\n\nFunction: #{name}\nArguments: #{args.inspect}"
  1800.  
  1801.       false
  1802.  
  1803.     else
  1804.  
  1805.       true
  1806.  
  1807.     end
  1808.  
  1809.   end
  1810.  
  1811.  
  1812.  
  1813.   def self.startup
  1814.  
  1815.     call :GdiplusStartup, @@token, [1, 0, 0, 0].pack('L4'), 0
  1816.  
  1817.   end
  1818.  
  1819.  
  1820.  
  1821.   def self.shutdown
  1822.  
  1823.     call :GdiplusShutdown, @@token
  1824.  
  1825.   end
  1826.  
  1827.  
  1828.  
  1829.   class Image
  1830.  
  1831.  
  1832.  
  1833.     attr_reader :instance
  1834.  
  1835.     def initialize
  1836.  
  1837.       @instance = 0
  1838.  
  1839.       true
  1840.  
  1841.     end
  1842.  
  1843.  
  1844.  
  1845.     def save(destination, *args)
  1846.  
  1847.       case destination
  1848.  
  1849.       when :file
  1850.  
  1851.         filename = args.shift << "\0"
  1852.  
  1853.         filename.encode!('UTF-16LE')
  1854.  
  1855.         argv = [:GdipSaveImageToFile, filename, Gdiplus.clsids[args.shift], 0]
  1856.  
  1857.       else
  1858.  
  1859.         raise ArgumentError, "unknown GDI+ image destination: #{source}"
  1860.  
  1861.       end
  1862.  
  1863.       argv.insert(1, @instance)
  1864.  
  1865.       Gdiplus.call *argv
  1866.  
  1867.     end
  1868.  
  1869.  
  1870.  
  1871.     def dispose
  1872.  
  1873.       Gdiplus.call :GdipDisposeImage, @instance
  1874.  
  1875.     end
  1876.  
  1877.   end
  1878.  
  1879.  
  1880.  
  1881.   class Bitmap < Image
  1882.  
  1883.  
  1884.  
  1885.     def initialize source, *args
  1886.  
  1887.       case source
  1888.  
  1889.       when :gdidib
  1890.  
  1891.         argv = [:GdipCreateBitmapFromGdiDib, args.shift, args.shift]
  1892.  
  1893.       when :hbitmap
  1894.  
  1895.         argv = [:GdipCreateBitmapFromHBITMAP, args.shift, 0]
  1896.  
  1897.       when :scan0
  1898.  
  1899.         w = args.shift
  1900.  
  1901.         h = args.shift
  1902.  
  1903.         argv = [:GdipCreateBitmapFromScan0, w, h, w * -4, 0x26200a, args.shift]
  1904.  
  1905.       else
  1906.  
  1907.         raise ArgumentError, "unknown GDI+ bitmap source: #{source}"
  1908.  
  1909.       end
  1910.  
  1911.       argv.push([0].pack('I'))
  1912.  
  1913.       retval = Gdiplus.call *argv
  1914.  
  1915.       @instance = retval ? argv.last.unpack('I').first : 0
  1916.  
  1917.       retval
  1918.  
  1919.     end
  1920.  
  1921.   end
  1922.  
  1923. end
  1924.  
  1925.  
  1926.  
  1927. if Gdiplus.startup
  1928.  
  1929.   Gdiplus.gen_clsids
  1930.  
  1931.   class << SceneManager
  1932.  
  1933.     alias_method :run_wo_gdip_shutdown, :run
  1934.  
  1935.     def run
  1936.  
  1937.       run_wo_gdip_shutdown
  1938.  
  1939.       Gdiplus.shutdown
  1940.  
  1941.     end
  1942.  
  1943.   end
  1944.  
  1945. end
  1946.  
  1947.  
  1948.  
  1949. #==============================================================================
  1950.  
  1951. # * Compatibility add-ons
  1952.  
  1953. #==============================================================================
  1954.  
  1955. #Yami overlays
  1956.  
  1957. if $imported["YSE-OverlayMapping"]
  1958.  
  1959.   class Map_Saver
  1960.  
  1961.     def draw_overlay_map_ground
  1962.  
  1963.       filename = YSA::OVERLAY::GROUND
  1964.  
  1965.       filename += $game_map.map_id.to_s
  1966.  
  1967.       filename += "-" + $game_variables[YSA::OVERLAY::GROUND_VARIABLE].to_s
  1968.  
  1969.       p filename
  1970.  
  1971.       image = Cache.overlay(filename)
  1972.  
  1973.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
  1974.  
  1975.       @map_image.blt(0, 0, image, @src_rect)
  1976.  
  1977.     end
  1978.  
  1979.  
  1980.  
  1981.     def draw_overlay_map_parallax
  1982.  
  1983.       filename = YSA::OVERLAY::PARALLAX
  1984.  
  1985.       filename += $game_map.map_id.to_s
  1986.  
  1987.       filename += "-" + $game_variables[YSA::OVERLAY::PARALLAX_VARIABLE].to_s
  1988.  
  1989.       image = Cache.overlay(filename)
  1990.  
  1991.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
  1992.  
  1993.       @map_image.blt(0, 0, image, @src_rect)
  1994.  
  1995.     end
  1996.  
  1997.  
  1998.  
  1999.     def draw_overlay_map_light
  2000.  
  2001.       filename = YSA::OVERLAY::LIGHT
  2002.  
  2003.       filename += $game_map.map_id.to_s
  2004.  
  2005.       filename += "-" + $game_variables[YSA::OVERLAY::LIGHT_VARIABLE].to_s
  2006.  
  2007.       image = Cache.overlay(filename)
  2008.  
  2009.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
  2010.  
  2011.       @map_image.blt(0, 0, image, @src_rect, 10)
  2012.  
  2013.     end
  2014.  
  2015.  
  2016.  
  2017.     def draw_overlay_map_shadow
  2018.  
  2019.       filename = YSA::OVERLAY::SHADOW
  2020.  
  2021.       filename += $game_map.map_id.to_s
  2022.  
  2023.       filename += "-" + $game_variables[YSA::OVERLAY::SHADOW_VARIABLE].to_s
  2024.  
  2025.       image = Cache.overlay(filename)
  2026.  
  2027.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
  2028.  
  2029.       @map_image.blt(0, 0, image, @src_rect, 10)
  2030.  
  2031.     end
  2032.  
  2033.  
  2034.  
  2035.     alias :th_map_overlay_draw_map :draw_map
  2036.  
  2037.     def draw_map
  2038.  
  2039.       th_map_overlay_draw_map
  2040.  
  2041.       draw_overlay_map_ground if $game_switches[YSA::OVERLAY::GROUND_SWITCH]
  2042.  
  2043.       draw_overlay_map_parallax if $game_switches[YSA::OVERLAY::PARALLAX_SWITCH]
  2044.  
  2045.       draw_overlay_map_shadow if $game_switches[YSA::OVERLAY::SHADOW_SWITCH]
  2046.  
  2047.       draw_overlay_map_light if $game_switches[YSA::OVERLAY::LIGHT_SWITCH]
  2048.  
  2049.     end
  2050.  
  2051.   end
  2052.  
  2053. end
  2054.  
  2055.  
  2056.  
  2057. if $imported["TH_AreaOverlay"]
  2058.  
  2059.   class Map_Saver
  2060.  
  2061.     def draw_overlay_area_map
  2062.  
  2063.       image = SceneManager.scene.instance_variable_get(:@spriteset).instance_variable_get(:@area_map).bitmap
  2064.  
  2065.       @src_rect.set(@start_x * tilesize, @start_y * tilesize, image.width, image.height)
  2066.  
  2067.       @map_image.blt(0, 0, image, @src_rect, 255)
  2068.  
  2069.     end
  2070.  
  2071.  
  2072.  
  2073.     alias :th_area_overlay_draw_map :draw_map
  2074.  
  2075.     def draw_map
  2076.  
  2077.       th_area_overlay_draw_map
  2078.  
  2079.       draw_overlay_area_map
  2080.  
  2081.     end
  2082.  
  2083.   end
  2084.  
  2085. end

脚本中的設定
予設F7地圖,F6当前畫面截圖,比例1:1,

    #Mapshot options. This takes an image of the entire map

    Mapshot_Button = Input::F7

    Mapshot_Scale =1

   

    #Screenshot options. This takes an image of the visible map

    Screenshot_Button = Input::F6

    Screenshot_Scale = 1


  設定  輸出文件夾

    #Folder that the map will be exported to

    Mapshot_Directory = "Mapshots"

    Screenshot_Directory = "Screenshots"

   設定   輸出文件格式

    # format you want to export to. You should stick with png.

    # Options: [bmp, png]

    Export_Format = "png"

点评

奇怪,我之前截图都好好的,后来多放了几个窗户截图就报错了  发表于 2015-2-10 14:05
截出来了,谢谢  发表于 2015-2-10 12:25

评分

参与人数 1梦石 +1 收起 理由
taroxd + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-15 17:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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