tools/pngtotex.c
static int quantize_texture(Texture *texture)
{
    unsigned int width  = texture->width;
    unsigned int height = texture->height;
    unsigned int stride = texture->stride;
    uint32_t *pixels_in = (uint32_t *)texture->pixels;
    uint8_t *pixels_out = texture->pixels;

    for (unsigned int level = 0; level <= texture->mipmaps; level++) {
        if (!quantize_image(pixels_in, stride, pixels_out, stride,
                            width, height, texture->palette, 256)) {
            fprintf(stderr, "quantize_image() failed for level %u\n", level);
            return 0;
        }
        pixels_in  += stride * height;
        pixels_out += stride * height;
        width  = lbound(width/2, 1);
        height = lbound(height/2, 1);
        stride = lbound(stride/2, 1);
    }

    texture->format = TEX_FORMAT_PALETTE8_RGBA8888;
    return 1;
}
/**
 * quantize_texture:  Convert the given texture to indexed-color 8bpp by
 * quantizing the color palette down to the 256 colors specified in
 * texture->palette.  The texture buffer is _not_ reallocated.
 *
 * [Parameters]
 *     texture: Texture to quantize.
 * [Return value]
 *     True on success, false on error.
 */
Convert the given texture to indexed-color 8bpp by
quantizing the color palette down to the 256 colors specified in
texture->palette.  The texture buffer is _not_ reallocated.

[Parameters]
texture: Texture to quantize.
[Return value]
True on success, false on error.
Convert the given texture to indexed - color 8bpp by quantizing the color palette down to the 256 colors specified in texture - > palette . The texture buffer is _not_ reallocated . [ Parameters ] texture : Texture to quantize . [ Return value ] True on success false on error .
static int quantize_texture(Texture *texture)
{
    unsigned int width  = texture->width;
    unsigned int height = texture->height;
    unsigned int stride = texture->stride;
    uint32_t *pixels_in = (uint32_t *)texture->pixels;
    uint8_t *pixels_out = texture->pixels;
    for (unsigned int level = 0; level <= texture->mipmaps; level++) {
        if (!quantize_image(pixels_in, stride, pixels_out, stride,
                            width, height, texture->palette, 256)) {
            fprintf(stderr, "quantize_image() failed for level %u\n", level);
            return 0;
        }
        pixels_in  += stride * height;
        pixels_out += stride * height;
        width  = lbound(width/2, 1);
        height = lbound(height/2, 1);
        stride = lbound(stride/2, 1);
    }
    texture->format = TEX_FORMAT_PALETTE8_RGBA8888;
    return 1;
}
static int quantize_texture ( Texture * texture ) { unsigned int width = texture -> width ; unsigned int height = texture -> height ; unsigned int stride = texture -> stride ; uint32_t * pixels_in = ( uint32_t * ) texture -> pixels ; uint8_t * pixels_out = texture -> pixels ; for ( unsigned int level = 0 ; level <= texture -> mipmaps ; level ++ ) { if ( ! quantize_image ( pixels_in , stride , pixels_out , stride , width , height , texture -> palette , 256 ) ) { fprintf ( stderr , " \n " , level ) ; return 0 ; } pixels_in += stride * height ; pixels_out += stride * height ; width = lbound ( width / 2 , 1 ) ; height = lbound ( height / 2 , 1 ) ; stride = lbound ( stride / 2 , 1 ) ; } texture -> format = TEX_FORMAT_PALETTE8_RGBA8888 ; return 1 ; }
quantize_texture:  Convert the given texture to indexed-color 8bpp by
 quantizing the color palette down to the 256 colors specified in
 texture->palette.
quantize_texture : Convert the given texture to indexed - color 8bpp by quantizing the color palette down to the 256 colors specified in texture - > palette .