[Request VXA] Dump map to Bitmap

I have been looking at ways to copy the map Bitmap, the closest I have found is this implementation here:
Map Effects.rb
Map Effects Doc En.txt

That script has a lot around it for its use (Map post-processing effects) and I don't want any of that, I just want to be able to say:
  1. @spriteset = Spriteset_Map.new
  2. @mapbitmap =  @spriteset.bitmap_from_viewport
Expand to see the code.


Now this chunk looks very handy:
  1. class << Graphics
  2.   def snap_elements_to_bitmap(*elements)
  3.     if !@snap_elements_back or @snap_elements_back.disposed?
  4.       @snap_elements_back = Sprite.new
  5.       @snap_elements_back.bitmap = Bitmap.new(1, 1)
  6.       @snap_elements_back.bitmap.set_pixel(0, 0, Color.new(0, 0, 0))
  7.       @snap_elements_back.z = 0x0FFF_FFFF
  8.     end
  9.     @snap_elements_back.zoom_x = width
  10.     @snap_elements_back.zoom_y = height
  11.     @snap_elements_back.visible = true
  12.     elements.each {|element| element.z += 0x1FFF_FFFF}
  13.     bmp = snap_to_bitmap rescue retry
  14.     @snap_elements_back.visible = false
  15.     elements.each {|element| element.z -= 0x1FFF_FFFF}
  16.     return bmp
  17.   end
  18. end
Expand to see the code.

What I understand from this is that it is shifting the viewports given via elements so their .z value overflows, leaving .z == 0 as the top viewport, then it calls snap_to_bitmap to grab the screen as a bitmap, then it reshifts the viewport .z values back to where they started from.

It looks like an excellent start to what I want to do, could someone lend a hand please?

Thanks!

EDIT: Looks like I may have figured something out on my own, if anyone wants to improve on this then please do
  1. #==============================================================================
  2. # ** Spriteset_Map
  3. #------------------------------------------------------------------------------
  4. #  Adds a bitmap dump method to Spriteset_Map.
  5. # Hopefully this works.
  6. #==============================================================================
  7. class Spriteset_Map
  8.   #--------------------------------------------------------------------------
  9.   # * Dump bitmap
  10.   #--------------------------------------------------------------------------
  11.   def bitmap_from_viewport
  12.     @viewport1.z += 0x1FFF_FFFF
  13.     bmp = Graphics.snap_to_bitmap rescue retry
  14.     @viewport1.z -= 0x1FFF_FFFF
  15.     return bmp
  16.   end
  17. end
Expand to see the code.
I think Graphics.snap_to_bitmap is the right way to do it, and the method missing from RMXP I needed for this. Not sure there is a better way than that.
Princess Amy wrote:
I think Graphics.snap_to_bitmap is the right way to do it, and the method missing from RMXP I needed for this. Not sure there is a better way than that.

It's annoying because it's a very slow way to do it and I'd like to use this to try out some real time effects.

I get FPS of around 25 on my NVidia laptop, which isn't good at all.

The right way to do it is to grab the GPU page directly after it has rendered @viewport1, but no way of doing that without reimplementing some of the private classes

This is what I've used it for;
hbgames/GL33 Shaders.zip

Perhaps there is a faster, more effective location to use snap_to_bitmap?

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=78472