GLBasic forum

Codesnippets => 2D-snippets => Topic started by: Kitty Hello on 2019-Aug-07

Title: ReSampler - high quality image scaling
Post by: Kitty Hello on 2019-Aug-07
The following is a C++ wrapper for a library, that does high-quality image scaling.
To use it, just add the gbas file to your project. The C++ lib is linked by REQUIRE.

Here's how to use it as a STRETCHSPRITE substitute:
Code (glbasic) Select

FUNCTION HQStretchSprite: id%, x%, y%, w%, h%
LOCAL s2% = GENSPRITE()
ReSampler(id, s2, w,h)
DRAWSPRITE s2, x,y
GRABSPRITE s2, 0,0,0,0
ENDFUNCTION

Warning - the above does not work (yet), if you're currently on an offscreen (USESCREEN x).
Title: Re: ReSampler - high quality image scaling
Post by: SnooPI on 2019-Aug-07
It's cool and very useful, thanks Gernot :good:
Title: Re: ReSampler - high quality image scaling
Post by: Qedo on 2020-Mar-06
I noticed that ReSampler source is no longer downloadable.
I would like to make available the optimized version that I modified and that avoids the transition from BGRA to RGBA and vice versa (for compatibility with the GLB standard) which makes it slow, but I don't know if I can share it.
Gernot are there problems to do it?
Ciao
Title: Re: ReSampler - high quality image scaling
Post by: bigsofty on 2020-Mar-06
I just tried to download the original as a test Qedo, seems to be working for me?
Title: Re: ReSampler - high quality image scaling
Post by: Qedo on 2020-Mar-06
sorry bigsofty I did not understand but yours is a question or a statement?
Can you download the original source?
because if you can, I have a problem
Title: Re: ReSampler - high quality image scaling
Post by: bigsofty on 2020-Mar-06
My bad, I just tested the if the download was working. It did download(on my IPad), not sure if it contains the source though, my dumb Ipad can't open zips.
Title: Re: ReSampler - high quality image scaling
Post by: Qedo on 2020-Mar-10
The great Resampler (thank Kitty Hello) is quite slow due to the different internal graphic format used between GLB and Resampler.
I raised the bottleneck of the transformation from the RGBA (GLB) to BGRA (Resampler) format  and vice versa.
Now it's a little faster.
The modified files are ReSamplerF.gbas and resamplerF_wrapper.cpp where  commented I left the old instructions
Furthermore it seems to me that the resampler.cpp code would also have to be optimized, but this is another matter and of greater complexity. We will see in the future.
Let me know, if you want, your feedback.
Ciao