Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Whenever I use Scale or FactorScale on an image (with the default bilinear=True), the resampling algorithm darkens some areas of the image because it's not taking transparency into account correctly when averaging. Using Nearest Neighbor sampling does not have this issue but of course Nearest Neighbor is hot garbage for actual use.
image test1 = "test.png"
image test2 = im.FactorScale("test.png", 1.1)
label start:
show test1 at right
show test2 at left
"The gray in the source image is #8C8C8C, exactly the same as the checkered background's light gray."
return
...and actually, I just checked, and it looks like the normal flat gray in the resampled image, even where there's no transparency at all, gets darkened to #8A8A8A instead of #8C8C8C. Lol
IIRC, I experienced the same thing a while back.
It was because images were being made partially transparent in developer mode and that was allowing me to see the checkerboard pattern behind the image, appearing to be darkening it.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
That's not the issue. I've seen this before in other engines. (also I packaged the game up, and had to custom-make the checkerboard grid since it isn't included in a build, and it still occurs)
The images aren't being made partially transparent - the image on the right, which isn't resampled, displays 100% correctly, and both images are opaque in the areas where the source image is opaque. (the gray is also the exact same color as the background's gray).
The resampling step darkens areas that are partially transparent in the source (such as antialiased borders of any sprite, as seen on the circle).
Specifically, what ren'py is generating here is an image with "premultiplied alpha" - the colors in each pixel are multiplied by the alpha value of the pixel, which results in darkening. This step can be done explicitly or it can be the byproduct of a naive resampling algorithm. Not necessarily a bad algorithm, since premultiplied alpha is useful - the renderer will have to do this multiplication anyway when drawing images to the screen. But the images produced by the resampling function are being treated the same as my other (source) image, which is not premultiplied, and so the multiplication is effectively being done again, which results in darkening.