Page 1 of 1

[Solved] Wondering about Surface#zoom_to

PostPosted: Fri Jan 14, 2011 11:50 am
by sgrevan
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 :
https://github.com/sgrevan/steeltk

Here is a visual result (with a cool image for testing purposes):
http://uppix.net/6/2/d/82f8297865008155 ... 54b4a.html
(original size: 64x64, target size: 120x120, no desired upscaling)

Should I file a bug report ?

Regards.

Re: Wondering about Surface#zoom_to

PostPosted: Fri Jan 14, 2011 4:35 pm
by jacius
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. :)

Re: Wondering about Surface#zoom_to

PostPosted: Sat Jan 15, 2011 11:28 am
by sgrevan
I should have read more carefully, I guess.

Thanks for the fix :)