Author Topic: ReSampler - high quality image scaling  (Read 3239 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10753
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
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).

Offline SnooPI

  • Dr. Type
  • ****
  • Posts: 365
    • View Profile
Re: ReSampler - high quality image scaling
« Reply #1 on: 2019-Aug-07 »
It's cool and very useful, thanks Gernot :good:

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 268
  • UNUS SED LEO
    • View Profile
Re: ReSampler - high quality image scaling
« Reply #2 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

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2687
    • View Profile
Re: ReSampler - high quality image scaling
« Reply #3 on: 2020-Mar-06 »
I just tried to download the original as a test Qedo, seems to be working for me?
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 268
  • UNUS SED LEO
    • View Profile
Re: ReSampler - high quality image scaling
« Reply #4 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

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2687
    • View Profile
Re: ReSampler - high quality image scaling
« Reply #5 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.
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 268
  • UNUS SED LEO
    • View Profile
Re: ReSampler - high quality image scaling
« Reply #6 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
« Last Edit: 2020-Mar-11 by Qedo »