Support transparent color
Does it use premultiplied or non-premultiplied pixel color format?
It uses premultiplied ARGB32 and just throws away alpha channel.
@88aleksandr88 In fact, gif image format do not support alpha channel.
xiaozhuai, gif can have a transparent color. If format of source image is ARGB32 premultiplied, to get the real colors, except fully transparent you can throw out alpha channel and take RGB channels. If format is pure ARGB32 (most images have ARGB32 premultiplied format), you need multiply each R, G, B channel on alpha before making gif color table to get real colors of image.
Ahh, you are right! Gif can have a transparent color, but it don't have alpha channel. Which meas no translucent.
Can you update your algorithm, that it could support transparent background? I think for that NewQuant algorithm must split colors to 255 classes, not to 256, leaving one class to transparent color and transparent color should be mapped from image to gif-pixel data ignoring NewQuant algorithm, because for this algorithm black (0x 00 00 00) and transparent (0x 00 00 00) colors are the same.
@88aleksandr88 Good suggestion, I'll reopen this issue.
xiaozhuai, You have animation type of layers Combine. Can user change it from Combine to Replace?
In NewQuant.h exists line: #define minpicturebytes (3prime4) / minimum size for input image */ Can algorithm be changed to encode gifs of any size? May be adding somewhere pixelIdex%pixelsCount will be enough?
@88aleksandr88 I don't have time to release an update for now, feel free to make a pr if you want.
Can you update your algorithm, that it could support transparent background? I think for that NewQuant algorithm must split colors to 255 classes, not to 256, leaving one class to transparent color and transparent color should be mapped from image to gif-pixel data ignoring NewQuant algorithm, because for this algorithm black (0x 00 00 00) and transparent (0x 00 00 00) colors are the same.
Sounds good, I'll try to make it happen in the next couple of days
That will be great. I learned NewQuant algorhitm and make it in floats with Qt and OpenMP, but it works slower than yours, but has a little bit higher quality of result (may be this quality is result of floats use). My realization works with transparent images of any gif-compatible size, but it slow.
That will be great. I learned NewQuant algorhitm and make it in floats with Qt and OpenMP, but it works slower than yours, but has a little bit higher quality of result (may be this quality is result of floats use). My realization works with transparent images of any gif-compatible size, but it slow.
Can I take a look at your code for reference?
This algorithm, realized by xiaozhuai is highly-optimized. Mine is theory-straight. Its almost impossible to compare function-by-function code sens of them. Do you really need it?
I have expanded the encoder with a bunch of fatures, like cancellation token, parallelism, out of order frame pushing, and direct framebuffer. And now I've also added transparency support. I am going to try to open a pull request, but if anyone want to experiment with with before it could get approved, here's my modified files and examples: