01-30-2008, 01:00 PM
Blur Effect Script
by Hadriel
Jan 30 2008
Ok, ever since I've seen that blur effect in RMVX, I wanted to make a similar effect in RMXP.
I've found two options, and I'm going to share the simpler one with you.
Everything you should know about using the script is in the comments provided.
In case you have problems, feel free to post them.
Enjoy!
Without blur
Blured image of the map behind the transparent menu
Blured image behind the End Game window
Manual installation files:
by Hadriel
Jan 30 2008
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Ok, ever since I've seen that blur effect in RMVX, I wanted to make a similar effect in RMXP.
I've found two options, and I'm going to share the simpler one with you.
Everything you should know about using the script is in the comments provided.
In case you have problems, feel free to post them.
Enjoy!
Blur Effect DEMO Screenshots
Without blur
Blured image of the map behind the transparent menu
Blured image behind the End Game window
Manual installation files:
Blur Effect Required DLL
Inside the rar is the DLL which is required for this script to work. Place the DLL in the project folder of your RMXP game.
ssabe.rar (Size: 48.54 KB / Downloads: 3)
ssabe.rar (Size: 48.54 KB / Downloads: 3)
Blur Effect Script
Code:
#===============================================================================
#===============================================================================
# Blur Effect Script with Screenshot Script 2.0
#===============================================================================
# Hadriel || Andreas21 and Cybersam
# 30.01.08 ||
# Version 1.0 || Version 2.0
#===============================================================================
#===============================================================================
#===============================================================================
#===============================================================================
#==============================================================================
# Screenshot Script 2.5
#==============================================================================
# Andreas21, Cybersam and Hadriel
#
# Version 2.5
#==============================================================================
#===============================================================================
# Screenshot Script 1.0 & screenshot.dll 1.0 created by: Andreas21
# Screenshot Script 2.0 created/edited by: cybersam
# Screenshot Script 2.5 (modified for BlurEffect script) edited by: Hadriel
#===============================================================================
# Save your screenshot like this:
#
# Screenshot::make("filename", N)
# or
# Screenshot::make("filename", N, "folder/path")
#
# Substitute the filename with the desired name of the image file,
# replace N with (0 = .bmp, 1 = .jpg and 2 = .png), and "folder/path" with
# the path to the folder where you want the picture to be saved.
# If you don't use the third parameter, then the file will be saved in
# Graphics/Pictures/ inside your game directory.
# ----------------------------------------------------------------------------
# Example No.1:
# Screenshot::make("MySavedPosition", 2, "C:/")
#
# This will create the picture MySavedPosition.png on the C:\ partition of
# your hard disk.
# ----------------------------------------------------------------------------
# Example No.2:
# Screenshot::make("MySavedPosition", 2)
#
# This will create the picture MySavedPosition.png in Graphics/Pictures/
# inside your game directory.
# ----------------------------------------------------------------------------
module Screenshot
@screen = Win32API.new 'ssabe', 'Screenshot', %w(l l l l p l l), ''
@readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
@findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
module_function
def make(file = "screenshot", extension = 2, dir = "Graphics/Pictures/")
if extension == 0
extension_name = ".bmp"
elsif extension == 1
extension_name = ".jpg"
elsif extension == 2
extension_name = ".png"
end
file_index = 0
file_name = dir.to_s + file.to_s + extension_name.to_s
@screen.call(0,0,640,480,file_name,window_name,extension)
end
def window_name
game_name = "\0" * 256
@readini.call('Game','Title','',game_name,255,".\\Game.ini")
game_name.delete!("\0")
return @findwindow.call('RGSS Player',game_name)
end
end
#==============================================================================
# Blur Effect Script
#==============================================================================
# Hadriel
# 30.01.08
# Version 1.0
#==============================================================================
#===============================================================================
# Using this script is simple.
# To blur an image, use this:
#
# @blured_image = BlurEffect.new(x,y,"folder/filename.ext",blur_factor)
#
# I will explain the parameters.
# x ... the x position of the image on the screen
# y ... the y position of the image on the screen
# "folder/filename.ext" ... the format you should use to specify the image
# you want to blur. You can either use a full path
# or relative path. A full path would look like this
# "C:/My Pictures/picture_01.png" and a relative path
# is the one relative to the folder where your game
# is stored. So a relative path looking like this
# "Graphics/Titles/title.jpg" would be equal
# to a full path like:
# "C:/My RMXP Games/Project1/Graphics/Titles/title.jpg"
# NOTE: Use JPEG, BMP or PNG files because I'm not
# sure if RMXP can import other filetypes.
# blur_factor ... is a number from 1 to 4 which defines the strength of the
# blur effect. Going past 2 is not recommended because it can
# cause big lag and won't make the blur look much better.
# So I recommend using 1 or 2.
# ----------------------------------------------------------------------------
# To free the image from memory, use this:
# @blured_image.dispose
# if you used the variable @blured_image to store the BlurEffect class object.
# ----------------------------------------------------------------------------
class BlurEffect
def initialize(x=0,y=0,image=nil,factor=1)
if factor > 4 then
factor = 4
elsif factor < 0 then
factor = 0
end
@x=x
@y=y
@image=image
@factor=factor
@blurry_number = @factor*8
blurry=[]
@coords=[]
@coords=[
[1,0], [1,-1], [-1,-1], [-1,1], [-1,0], [-1,1], [0,1], [1,1]
]
@firstimage = Sprite.new
@firstimage.bitmap = Bitmap.new(@image)
@firstimage.x = @x
@firstimage.y = @y
@width = @firstimage.bitmap.width
@height = @firstimage.bitmap.height
@rect = Rect.new(@x,@y,@width,@height)
for i in 0...@blurry_number
blurry[i] = Bitmap.new(@image)
offset_x = @x + (@coords[i%8][0]*@factor)
offset_y = @y + (@coords[i%8][1]*@factor)
opa = 64
@firstimage.bitmap.blt(offset_x,offset_y,blurry[i],@rect,opa)
end
end
def dispose
@firstimage.dispose
end
end