-
Notifications
You must be signed in to change notification settings - Fork 140
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
setTransparent #3
Comments
Like... what kind of number is it expecting for the color? I'm passing |
Anybody want to hack on https://wiki.mozilla.org/APNG_Specification encoding with me? |
This might be a bug: GIFEncoder.js#L351
That
With this I'm getting better, but still random results: |
Testing it today... colors were crap at 200x200 and fine at 300x300... maybe has something to do with this. Will look more. |
The quantization algorithm puts multiple entries into the color table for the same color, so then there are different indices for the same color. Because of that, color that should be transparent, has different index than the transparency index. I wrote a fix, that sets all the pixel indices, that should be transparent to transparency index. if (transparent != null) {
transIndex = findClosest(transparent);
var r = colorTab[transIndex*3];
var g = colorTab[transIndex*3+1];
var b = colorTab[transIndex*3+2];
var trans_indices = [];
for (var i=0; i<colorTab.length; i+=3)
{
var index = i / 3;
if (!usedEntry[index]) continue;
if (colorTab[i] == r && colorTab[i+1] == g && colorTab[i+2] == b)
trans_indices.push(index);
}
for (var i=0; i<indexedPixels.length; i++)
if (trans_indices.indexOf(indexedPixels[i]) >= 0)
indexedPixels[i] = transIndex;
} |
Also, to run, line 363 must use floor function here: var index/int/ = Math.floor(i / 3); |
Thanks @grego87, transparent works now: There is still a huge difference in the color quality at 200x200 vs 300x300... any leads on that bug? |
Have you tried out https://github.com/deanm/omggif |
It does look a little cleaner but you have to manually set the palette... I might port that part of yours to work with his... |
Hi, Any idea when the quality depending on the canvas size may get fixed? |
I'm pretty sure the size/color bug #6 is in NeuQuant.js, because I got it working with OMGGIF and they bug is still there. I'm going to start a bounty on Stack Overflow. |
@raducostea This patch should fix the color/size issue: https://github.com/antimatter15/jsgif/pull/8/files |
Note that there are TWO places that need to be changed from:
Without these two fixes the wrong color is chosen as the transparency color. (I discovered this when debugging why 0x000000 worked as a transparency color but 0xFFFFFF did not) |
You can try gifenc Because my react-native-gifencoder is also some fork of gif.js But in my react-native-runescape-text I |
Have you gotten
setTransparent(Number color)
to work?The text was updated successfully, but these errors were encountered: