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.

[XP] VX $game_temp.background_bitmap.blur for XP

$game_temp.background_bitmap.blur for XP
This is a request for a Game_Spriteset or Game_Temp edit, enabling the VX features of .blur and .radial_blur
Detailed Description:
In VX, there are $game_temp.background_bitmap.blur and $game_temp.background_bitmap.radial_blur, which contribute to creating a more visually appealing game. I was wondering if there as a script, Game_... edit, or dll bringing the feature into RMXP.
Screen shots:
vxblur.png

This is an example of the .blur effect, in the VX menu, I removed the Menu_Status to help you see
Other Scripts I am using (in order):
I am NOT using SDK and MACL
I am using the screenshot.dll for a custom save/load menu, but I don't have to.

If you could help, in any way, that would be great!

Thanks,
-Lonelyelf
 
You could have my Bitmap blur script. It, well, blurs Bitmaps =)
But I think it is not as fast as the one from VX.
Code:
#============================================================================

# **Blur Bitmap

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

# Neo-Bahamut

# thanks to Caesar

# V 1.0

# 07.08.2009

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

# This script blurs a Bitmap.

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

# TIME (in seconds)

#   1 Bitmap (64 x 64): 0.03 seconds

#   1 Bitmap (256 x 256): 0.28 seconds

#   1 Bitmap (640 x 480): 1.38 seconds

#   20 Bitmaps (64 x 64): 0.52 seconds

#   10 Bitmaps (224 x 224): 2.69 seconds

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

 

class Bitmap

  

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

  # * Blurs the Bitmap

  #     radius_x, radius_y: The blur radius.

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

  def blur!(radius_x, radius_y)

    clear

    blur = blur(radius_x, radius_y)

    blt(0, 0, blur, blur.bitmap)

  end

  

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

  # * Returns a blured Bitmap

  #     radius_x, radius_y: The blur radius.

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

  def blur(radius_x, radius_y)

    # Create Bitmap to blur

    bitmap = Bitmap.new(width, height)

    # Loop

    for x in 0...bitmap.width

      for y in 0...bitmap.height

        # Get pixels around

        color = average_color([0, x].max, [0, y].max, [640, x+radius_x].min, [480, y+radius_y].min)

        # Sets pixel

        bitmap.set_pixel(x, y, color)

      end

    end

    # Return

    bitmap

  end

  

  private

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

  # * Returns the average color from x1,y1 to x2,y2

  #     x1, y1, x2, y2: Coordinates

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

  def average_color(x1, y1, x2, y2)

    r, g, b, a = 0, 0, 0, 0

    n = 0

    for x in x1...x2

      for y in y1...y2

        n += 1

        pix = get_pixel(x, y)

        r, g, b, a = r+pix.red, g+pix.green, b+pix.blue, a+pix.alpha

      end

    end

    Color.new(r/n, g/n, b/n, a/n)

  end

  

end
 
Thank you, Neo. I'll try this!
But, what bitmap do I apply this to, so I can blur the map?

I'm pretty sure I have an RGSS compatibility around here somewhere, if that doesn't work...

Thanks for your help!
-Lonelyelf
 
A screnshot script?
Hmmm...
Several of my scripts are not compatable with SDK, and MACL requires it. I can find a screenshot script, I guess, but then what? What basic line of code could I use just to make a blurred screenshot of the map? Nothing but the map, though - windows must be visible.

Thanks again,
-Lonelyelf
 
MACL requires SDK? :O
Are you sure? When I use it without SDK I never get errors...

I can find a screenshot script, I guess, but then what? What basic line of code could I use just to make a blurred screenshot of the map? Nothing but the map, though - windows must be visible.
Well it takes a screenshot so you see everything on the Bitmap which you see in the RGSS Player as the screenshot is taken.
If you find a working screenshot script I can tell you what you have to do to show the blurred map in the menu as background
 
Alright, I've decided to use the MACL screenshot script. Thanks for your help. I just need the way to show the blurred map in the background. And could I do the same thing by Call script?

Thanks again,
-Lonelyelf
 
No, you can't. RMXP doesn't support this easy way of having background images in the menu.

Code:
class Game_Temp

  attr_reader :map_screenshot

  def map_screenshot=(i)

    @blurred = false

    @blur_map_screenshot = nil

    @map_screenshot = i

  end

  def blur_map_screenshot

    return @blur_map_screenshot unless @blurred

    @blur_map_screenshot ||= @map_screenshot.dup

    @blur_map_screenshot_thread = Thread.new {@blur_map_screenshot.blur!(1, 1); @blurred = true}

    @blur_map_screenshot

  end

end

 

class Scene_Map

  alias_method :lonelyelf_wants_to_have_a_menu_background_so_lets_give_him_one, :call_menu

  def call_menu

    Screenshot.shot

    $game_temp.map_screenshot = Bitmap.new("screenshot.png")

    File.delete("screenshot.png")

    lonelyelf_wants_to_have_a_menu_background_so_lets_give_him_one

  end

end

 

class Scene_Menu

  alias_method :lonelyelf_wants_to_have_a_menu_background_so_lets_give_him_one_second_one, :main

  def main

    @menu_bg = Sprite.new

    @menu_bg.bitmap = $game_temp.blur_map_screenshot

    lonelyelf_wants_to_have_a_menu_background_so_lets_give_him_one_second_one

  end

end

This code should do it. The problem is that my blur is very very slow so if you would call it at the beginning of the menu most times you would get a "Script is hanging" error. So this one shows the normal map in the background and while "surfing" through the menu it blurs the other one. As blurring is finished the blurred map will be shown but this takes about a full minute ^^
So I think the better way to solve this (if you really need a blurred map) is using RGSS2 in RMXP.
 
Hmmm.
Well...
I'm confused.

I suppose RGSS2 in RMXP would work, but it would not support my other scripts!
Thanks again for the help. If this doesn't work, I can just walk away from the idea.
 

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