Consider turning on bilinear interpolation for the CG gallery thumbnails. #182

Closed
opened 2022-10-14 06:10:08 +00:00 by GManon · 10 comments
Contributor

Currently the CG thumbnails are scaled down using nearest neighbor, this makes the thumbanail look blocky and way too sharp, consider using bilinear interpolation instead.

(Diferences are more noticable if you open the images in a new tab)
Currenlty:

Bilinear:

Since it's a very simple fix, give me the go-ahead and I'll make a PR for it.

Currently the CG thumbnails are scaled down using nearest neighbor, this makes the thumbanail look blocky and way too sharp, consider using bilinear interpolation instead. (Diferences are more noticable if you open the images in a new tab) Currenlty: ![](https://git.snootgame.xyz/attachments/4e328f8d-20a7-40c9-ba57-23d895bd8b85) Bilinear: ![](https://git.snootgame.xyz/attachments/2bbd2a77-79d3-4f86-bae8-d2662a0ed1c0) Since it's a very simple fix, give me the go-ahead and I'll make a PR for it.
Member

Turned off due to performance (Ren'Py blows so hard on this department), turning it back on would cause a long stutter with tons of images unlocked.
Although could be solved with in engine or post texture atlas / sprite sheet, instead of grabbing the original images and scaling them down.

Turned off due to performance (Ren'Py blows so hard on this department), turning it back on would cause a long stutter with tons of images unlocked. Although could be solved with in engine or post texture atlas / sprite sheet, instead of grabbing the original images and scaling them down.
Member

I don't think this is an egrigious performance difference, testing it myself gave me a very slightly longer delay in opening the menu. If anyone has a really big problem with it, ideally it's something that's toggleable, and that's pretty easy to implement into the options menu.

I don't think this is an egrigious performance difference, testing it myself gave me a _very_ slightly longer delay in opening the menu. If anyone has a really big problem with it, ideally it's something that's toggleable, and that's pretty easy to implement into the options menu.
Owner

Turned off due to performance (Ren'Py blows so hard on this department), turning it back on would cause a long stutter with tons of images unlocked.
Although could be solved with in engine or post texture atlas / sprite sheet, instead of grabbing the original images and scaling them down.

perhaps a cringe idea but could we parallelize the loading a bit?

> Turned off due to performance (Ren'Py blows so hard on this department), turning it back on would cause a long stutter with tons of images unlocked. > Although could be solved with in engine or post texture atlas / sprite sheet, instead of grabbing the original images and scaling them down. perhaps a cringe idea but could we parallelize the loading a bit?
Member

Turned off due to performance (Ren'Py blows so hard on this department), turning it back on would cause a long stutter with tons of images unlocked.
Although could be solved with in engine or post texture atlas / sprite sheet, instead of grabbing the original images and scaling them down.

perhaps a cringe idea but could we parallelize the loading a bit?

Maybe within the screen language, not too sure. Worst case doing either the texture atlas or paralleization require rewriting the gallery to be a custom displayable.

> > Turned off due to performance (Ren'Py blows so hard on this department), turning it back on would cause a long stutter with tons of images unlocked. > > Although could be solved with in engine or post texture atlas / sprite sheet, instead of grabbing the original images and scaling them down. > > perhaps a cringe idea but could we parallelize the loading a bit? Maybe within the screen language, not too sure. Worst case doing either the texture atlas or paralleization require rewriting the gallery to be a custom displayable.
Author
Contributor

I think you're overestimating how intensive bilinear filtering is, testing it on a full save file on my 5 year-old Chinese cellphone only resulted in a delay of 2-3 seconds when opening the gallery for the first time. It also made me realize that phone screens are so small that both bilinear filtering and nearest neighbor look almost the, so this should probably stay this way for the 'small' variant.

Either way, if it is that much of a concern you could always add the thumbnails to the game files or just generate them when the game is launched for the first time and save them in a cache folder.

I think you're overestimating how intensive bilinear filtering is, testing it on a full save file on my 5 year-old Chinese cellphone only resulted in a delay of 2-3 seconds when opening the gallery for the first time. It also made me realize that phone screens are so small that both bilinear filtering and nearest neighbor look almost the, so this should probably stay this way for the 'small' variant. Either way, if it is that much of a concern you could always add the thumbnails to the game files or just generate them when the game is launched for the first time and save them in a cache folder.
Owner

The generated thumbnail option seems like it'd be the best since you wouldn't need to rescale constantly. You'd just need to import the imagemagick library and then convert them. Only issue would be perfectly scaling them so they don't look like some deepfried shitpost.

The generated thumbnail option seems like it'd be the best since you wouldn't need to rescale constantly. You'd just need to import the imagemagick library and then convert them. Only issue would be perfectly scaling them so they don't look like some deepfried shitpost.
MichaelYick added the
enhancement
Low Priority
labels 2022-10-16 23:50:08 +00:00
Author
Contributor

You'd just need to import the imagemagick library and then convert them.

Not even, you can just use Ren'pys im.factorscale on the images and then save the result to a file on startup.

Though now that I think about it, doing it this way might be a problem for phones.

Anyway, since you agree with me that bilinear interpolation is the better option I'll begin testing things out. Will make a PR when I find an acceptable solution.

>You'd just need to import the imagemagick library and then convert them. Not even, you can just use Ren'pys im.factorscale on the images and then save the result to a file on startup. Though now that I think about it, doing it this way might be a problem for phones. Anyway, since you agree with me that bilinear interpolation is the better option I'll begin testing things out. Will make a PR when I find an acceptable solution.
GManon changed title from Consider turning on biliner interpolation for the CG gallery thumbnails. to Consider turning on bilinear interpolation for the CG gallery thumbnails. 2022-10-17 01:54:18 +00:00
Author
Contributor

Would this be considered too hacky to implement? Renpy doesn't seem to have a way to get the raw data from a displayable so I had to resort to getting the surface object from the resulting scaling.

I mean, the code does work and it even works on android

python:
    import pygame

    # (src_image: FactorScale; name: string, ext: string) FactorScale refers to an image scaled using im.FactorScale()
    def save_thumb(src_image, name, ext):
        savepath = config.basedir.replace("\\","/") + "/game/cache/"
        if renpy.android:
            savepath = os.environ['ANDROID_PUBLIC'] + "/cache/"

        data = src_image.load() #Returns a pygame surface
        pygame.image.save(data, savepath+"thmb_"+name+ext) #Saves the image to file


$save_thumb(NOT_UNLOCKED_COVER,"default",".jpg")
Would this be considered too hacky to implement? Renpy doesn't seem to have a way to get the raw data from a displayable so I had to resort to getting the surface object from the resulting scaling. I mean, the code does work and it even works on android ```py python: import pygame # (src_image: FactorScale; name: string, ext: string) FactorScale refers to an image scaled using im.FactorScale() def save_thumb(src_image, name, ext): savepath = config.basedir.replace("\\","/") + "/game/cache/" if renpy.android: savepath = os.environ['ANDROID_PUBLIC'] + "/cache/" data = src_image.load() #Returns a pygame surface pygame.image.save(data, savepath+"thmb_"+name+ext) #Saves the image to file $save_thumb(NOT_UNLOCKED_COVER,"default",".jpg") ```
Owner

I've seen worse in my life, just make sure that function has doc strings.

I'll let the others weigh in as well.

I've seen worse in my life, just make sure that function has doc strings. I'll let the others weigh in as well.
Author
Contributor

This has been fixed.

This has been fixed.
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Cavemanon/SnootGame#182
No description provided.