Forums Archived

The forums are being archived. See this topic for more information.

[Solved] Wondering about Surface#zoom_to

Get help and support with Rubygame

[Solved] Wondering about Surface#zoom_to

Postby sgrevan » Fri Jan 14, 2011 11:50 am

Hello there,

I'm encountering a problem and I'm wondering if I'm doing something wrong or if I'm facing a bugged piece of code in Rubygame/RSDL.

When I try to resize a surface loaded from a PNG file (or JPEG, or BMP, I tried both of these file formats), image pixels are not altered.
Instead, if the original image is smaller than the resulting surface, new space created by the resize will be filled in blank.
However, if the image is larger, it will be truncated if I reduce surface's size.

I also tried Surface#rotozoom, same issue.
I have a functional setting (well, I guess) and sdl_gfx installed and I tried the same code on three separate systems : a virtualized Arch Linux, a native Arch Linux on my MBP and on Windows 7.

In case you would like to see some code, here's the git repo :

Here is a visual result (with a cool image for testing purposes): ... 54b4a.html
(original size: 64x64, target size: 120x120, no desired upscaling)

Should I file a bug report ?

Last edited by sgrevan on Sat Jan 15, 2011 11:29 am, edited 1 time in total.
Posts: 6
Joined: Wed Jan 12, 2011 5:32 pm
Location: France

Re: Wondering about Surface#zoom_to

Postby jacius » Fri Jan 14, 2011 4:35 pm

Rubygame::Surface#zoom_to returns a new Surface, it doesn't modify the original. So, you just need to change widgets/mixins/bitmap.rb at line 22, to assign the result back to the @bitmap variable, like so:

Code: Select all
@bitmap = @bitmap.zoom_to new_width, new_height, @smooth

Hope that helps. :)
User avatar
Site Admin
Posts: 131
Joined: Fri Feb 06, 2009 11:13 pm

Re: Wondering about Surface#zoom_to

Postby sgrevan » Sat Jan 15, 2011 11:28 am

I should have read more carefully, I guess.

Thanks for the fix :)
Posts: 6
Joined: Wed Jan 12, 2011 5:32 pm
Location: France

Return to Help & Support

Who is online

Users browsing this forum: No registered users and 1 guest