Skip to content
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

PnnQuant + omggif create gif ? #2

Open
3400442579 opened this issue Mar 22, 2021 · 3 comments
Open

PnnQuant + omggif create gif ? #2

3400442579 opened this issue Mar 22, 2021 · 3 comments

Comments

@3400442579
Copy link
Contributor

PnnQuant + omggif create gif ?

@3400442579
Copy link
Contributor Author

_gif.addFrame(frame.x, frame.y, frame.width, frame.height, frame.pixels, {
num_colors: (frame.palette || _palette).length,
palette: frame.palette,
delay: frame.delay,
transparent: 0,
disposal: 1
})

PnnQuant :
frame.pixels?
frame.palette?

@3400442579
Copy link
Contributor Author

3400442579 commented Mar 22, 2021

            var pixels = new Uint32Array(frame.data.buffer);

            var pnnq = new PnnQuant({ colors: 256, dithering: true, width: _width, height: _height });
            pnnq.pnnquan(pixels, 256,1);
          
            var indexedPixels = pnnq.quantize_image(pixels, 128, _width, _height, true);
            var palette = pnnq.getPalette1();
            var V = 0;
            var J = new Uint8Array(4),
                M = new Uint32Array(J.buffer);
       
            for (var B = 0; B < palette.length; B++) {
                M[0] = palette[B];
                var K = J[0];
                J[0] = J[2];
                J[2] = K;
                palette[B] = M[0];
                if (M[0] == 0) V = B
            }

          frame.pixels=indexedPixels ;
          frame.palette=palette ;

anim1
anim2

@mcychan
Copy link
Owner

mcychan commented Mar 23, 2021

var pixels = new Uint32Array(frame.data.buffer);
var pnnq = new PnnLABQuant({colors: 256, dithering: true, pixels: pixels, width: _width, height: _height });
pnnq.quantizeImage();
frame.pixels = pnnq.getIndexedPixels();
frame.palette = pnnq.getPalette();

snow

mcychan pushed a commit that referenced this issue Mar 29, 2021
@mcychan mcychan reopened this Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants