-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why don't you use gdImagePaletteToTrueColor? #23
Comments
... oh. Because that function is only available in newer versions of library. Still, maybe with some detection? |
These bindings were a minor reworking of the existing gd2 Ruby bindings that were written like 15 years ago, which used the old The Would something like this suffice? https://github.com/dark-panda/gd2-ffij/compare/fix-to-true-color |
I actually think that the copy_from is unnecessary, that you can just replace the image pointer ... I mean,
like it's used in to_indexed_color. But seems that this will work as well. Note that I also found another "solution" without using new function (so, for older gd2). If you replace copy_from(self, 0, 0, 0, 0, *sz) with copy_from(self, 0, 0, 0, 0, *sz, *sz) , forcing use of gdImageCopyResampled instead of gdImageCopy, it's slower but preserves transparency correctly. |
If these all work I'll just take the most performant then I suppose. |
Well, I'm doing both based on existence of gdImagePaletteToTrueColor. Don't want to risk I have old library hanging somewhere - note that the initialization code prefers oldest library it can find. |
I mean, both "init_with_image" version and "copy_from(self, 0, 0, 0, 0, *sz, *sz)" version. I'll skip the version with unnecessary copy_from. |
libGD has function gdImagePaletteToTrueColor. It's supposed to do exactly what your to_true_color is supposed to do, except that it actually WORKS for palette images with transparency.
Is there any reason why you aren't using it?
To provide example:
Load it with
Then compare following two outputs:
The text was updated successfully, but these errors were encountered: