Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[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:
Ruby:
@spriteset = Spriteset_Map.new

@mapbitmap =  @spriteset.bitmap_from_viewport

Now this chunk looks very handy:
Ruby:
class << Graphics

  def snap_elements_to_bitmap(*elements)

    if !@snap_elements_back or @snap_elements_back.disposed?

      @snap_elements_back = Sprite.new

      @snap_elements_back.bitmap = Bitmap.new(1, 1)

      @snap_elements_back.bitmap.set_pixel(0, 0, Color.new(0, 0, 0))

      @snap_elements_back.z = 0x0FFF_FFFF

    end

    @snap_elements_back.zoom_x = width

    @snap_elements_back.zoom_y = height

    @snap_elements_back.visible = true

    elements.each {|element| element.z += 0x1FFF_FFFF}

    bmp = snap_to_bitmap rescue retry

    @snap_elements_back.visible = false

    elements.each {|element| element.z -= 0x1FFF_FFFF}

    return bmp

  end

end
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
Ruby:
#==============================================================================

# ** Spriteset_Map

#------------------------------------------------------------------------------

#  Adds a bitmap dump method to Spriteset_Map.

# Hopefully this works.

#==============================================================================

class Spriteset_Map

  #--------------------------------------------------------------------------

  # * Dump bitmap

  #--------------------------------------------------------------------------

  def bitmap_from_viewport

    @viewport1.z += 0x1FFF_FFFF

    bmp = Graphics.snap_to_bitmap rescue retry

    @viewport1.z -= 0x1FFF_FFFF

    return bmp

  end

end
 
Princess Amy":28qq0sqr said:
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?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top