RPG Maker Forums

A long time ago i found this code that allowed to give a x2 zoom on bitmaps with a filter like the ones from the 16bits emulators



Code:
#==============================================================================
# ** Bitmap
#------------------------------------------------------------------------------
# This class handles and draws the bitmaps
#==============================================================================

class Bitmap
#--------------------------------------------------------------------------
# * New method: x2
#--------------------------------------------------------------------------
def x2
bitmap = Bitmap.allocate
bitmap.send(:initialize, width * 2, height * 2)
width.times do |x|
	 height.times do |y|
	 px = get_pixel(x, y)
	 x2 = x * 2
	 y2 = y * 2
	 p1 = x == 0		 ? px : get_pixel(x - 1, y)
	 p2 = x == width - 1 ? px : get_pixel(x + 1, y)
	 p3 = y == 0		 ? px : get_pixel(x, y - 1)
	 p4 = y == height - 1 ? px : get_pixel(x, y + 1)
	 if p3 != p4 && p1 != p2
		 bitmap.set_pixel(x2 , y2,	 p1 == p3 ? p1 : px)
		 bitmap.set_pixel(x2 + 1, y2,	 p3 == p2 ? p2 : px)
		 bitmap.set_pixel(x2 , y2 + 1, p1 == p4 ? p1 : px)
		 bitmap.set_pixel(x2 + 1, y2 + 1, p4 == p2 ? p2 : px)
	 else
		 bitmap.fill_rect(x2, y2, 2, 2, px)
	 end
	 end
end
bitmap
end
end


the result is great but since ruby get pixel and set pixel is slow as hell, it's not something usable.

I know that it's possible to make a dll to use winapi to do this work faster, but since my C/C++ knowlegde is near nil i can't seem to make this work.

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,090
Members
137,587
Latest member
Usagiis
Top