xerpi / libvita2d

Simple and Fast (using the GPU) 2D library for the PSVita
MIT License
137 stars 52 forks source link

Improve logic for scale jpg images #83

Closed fjtrujy closed 3 years ago

fjtrujy commented 3 years ago

Description

This PR basically improves the logic for scaling down jpg images. Now it checks instead by width or height, by matrix size, making better scaling down for any kind of image aspect ratio.

I have checked the documentation of libjpeg-turbo and they mention this:

unsigned int scale_num, scale_denom
        Scale the image by the fraction scale_num/scale_denom.  Default is
        1/1, or no scaling.  Currently, the only supported scaling ratios
        are M/8 with all M from 1 to 16, or any reduced fraction thereof (such
        as 1/2, 3/4, etc.)  (The library design allows for arbitrary
        scaling ratios but this is not likely to be implemented any time soon.)
        Smaller scaling ratios permit significantly faster decoding since
        fewer pixels need be processed and a simpler IDCT method can be used.

I have done some tests and the library admit any value of scale_denom greater than 1, maybe documentation is outdated

Thanks