The open imaging DSP library
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
mpix/op_palettize.h

Implementing new palettization operations. More...

Data Structures

struct  mpix_palette
 Color palette as a list of pixels in the described format. More...
 
struct  mpix_palette_op
 
struct  mpix_qoi_convert_op
 
struct  mpix_qoi_palette_op
 

Macros

#define MPIX_REGISTER_PALETTE_OP(id, fn, format_in, format_out)
 Define a new palettization operation: from a pixel format to indexed colors.
 
#define MPIX_REGISTER_QOI_PALETTE_OP(id, op, fmt_src, fmt_dst)
 Define a new palettization operation: from a pixel format to indexed colors.
 
#define MPIX_REGISTER_QOI_CONVERT_OP(id, op, fmt_src, fmt_dst)
 Define a new palettization operation: from a pixel format to indexed colors.
 

Functions

void mpix_convert_rgb24_to_palette8 (const uint8_t *src, uint8_t *dst, uint16_t width, const struct mpix_palette *palette)
 Convert a line of pixel data from RGB24 to PALETTE8.
 
void mpix_convert_palette8_to_rgb24 (const uint8_t *src, uint8_t *dst, uint16_t width, const struct mpix_palette *palette)
 Convert a line of pixel data from PALETTE8 to RGB24.
 
void mpix_convert_rgb24_to_palette4 (const uint8_t *src, uint8_t *dst, uint16_t width, const struct mpix_palette *palette)
 Convert a line of pixel data from RGB24 to PALETTE4.
 
void mpix_convert_palette4_to_rgb24 (const uint8_t *src, uint8_t *dst, uint16_t width, const struct mpix_palette *palette)
 Convert a line of pixel data from PALETTE4 to RGB24.
 
void mpix_convert_rgb24_to_palette2 (const uint8_t *src, uint8_t *dst, uint16_t width, const struct mpix_palette *palette)
 Convert a line of pixel data from RGB24 to PALETTE2.
 
void mpix_convert_palette2_to_rgb24 (const uint8_t *src, uint8_t *dst, uint16_t width, const struct mpix_palette *palette)
 Convert a line of pixel data from PALETTE2 to RGB24.
 
void mpix_convert_rgb24_to_palette1 (const uint8_t *src, uint8_t *dst, uint16_t width, const struct mpix_palette *palette)
 Convert a line of pixel data from RGB24 to PALETTE1.
 
void mpix_convert_palette1_to_rgb24 (const uint8_t *src, uint8_t *dst, uint16_t width, const struct mpix_palette *palette)
 Convert a line of pixel data from PALETTE1 to RGB24.
 
void mpix_palettize_op (struct mpix_base_op *op)
 Helper to turn a line palettization function into an operation.
 
int mpix_image_qoi_depalettize (struct mpix_image *img, size_t max_sz, struct mpix_palette *plt)
 
int mpix_image_qoi_encode (struct mpix_image *img, size_t max_sz)
 

Detailed Description

Implementing new palettization operations.

SPDX-License-Identifier: Apache-2.0

Macro Definition Documentation

◆ MPIX_REGISTER_PALETTE_OP

#define MPIX_REGISTER_PALETTE_OP (   id,
  fn,
  format_in,
  format_out 
)
Value:
const struct mpix_palette_op mpix_palette_op_##id = { \
.base.name = ("palettize_" #id), \
.base.format_src = (MPIX_FMT_##format_in), \
.base.format_dst = (MPIX_FMT_##format_out), \
.base.window_size = 1, \
.base.run = mpix_palettize_op, \
.palette_fn = (fn), \
}
void mpix_palettize_op(struct mpix_base_op *op)
Helper to turn a line palettization function into an operation.
uint32_t format_src
Definition op.h:33
uint16_t window_size
Definition op.h:43
const uint8_t * name
Definition op.h:31
Definition op_palettize.h:26
struct mpix_base_op base
Definition op_palettize.h:28

Define a new palettization operation: from a pixel format to indexed colors.

Parameters
idShort identifier to differentiate operations of the same category.
fnFunction converting one input line.
format_inThe input format for that operation.
format_outThe Output format for that operation.

◆ MPIX_REGISTER_QOI_CONVERT_OP

#define MPIX_REGISTER_QOI_CONVERT_OP (   id,
  op,
  fmt_src,
  fmt_dst 
)
Value:
const struct mpix_qoi_convert_op mpix_qoi_convert_op_##id = { \
.base.name = ("qoi_convert_" #id), \
.base.format_src = (MPIX_FMT_##fmt_src), \
.base.format_dst = (MPIX_FMT_##fmt_dst), \
.base.window_size = 1, \
.base.run = (op), \
}
Definition op_qoi.h:16
struct mpix_base_op base
Definition op_qoi.h:18

Define a new palettization operation: from a pixel format to indexed colors.

Parameters
idShort identifier to differentiate operations of the same category.
fnFunction converting one input line.
format_inThe input format for that operation.
format_outThe Output format for that operation.

◆ MPIX_REGISTER_QOI_PALETTE_OP

#define MPIX_REGISTER_QOI_PALETTE_OP (   id,
  op,
  fmt_src,
  fmt_dst 
)
Value:
const struct mpix_qoi_palette_op mpix_qoi_palette_op_##id = { \
.base.name = ("qoi_palette_" #id), \
.base.format_src = (MPIX_FMT_##fmt_src), \
.base.format_dst = (MPIX_FMT_##fmt_dst), \
.base.window_size = 1, \
.base.run = op, \
}
Definition op_qoi.h:22
struct mpix_base_op base
Definition op_qoi.h:24

Define a new palettization operation: from a pixel format to indexed colors.

Parameters
idShort identifier to differentiate operations of the same category.
fnFunction converting one input line.
format_inThe input format for that operation.
format_outThe Output format for that operation.

Function Documentation

◆ mpix_convert_palette1_to_rgb24()

void mpix_convert_palette1_to_rgb24 ( const uint8_t *  src,
uint8_t *  dst,
uint16_t  width,
const struct mpix_palette palette 
)

Convert a line of pixel data from PALETTE1 to RGB24.

You only need to call this function to work directly on raw buffers. See mpix_image_palettize for a more convenient high-level API.

Parameters
srcBuffer of the input line, with the format XXX in mpix_palettize_XXX_to_YYY().
dstBuffer of the output line, with the format YYY in mpix_palettize_XXX_to_YYY().
widthWidth of the lines in number of pixels.
paletteColor palette to use for the conversion.

◆ mpix_convert_palette2_to_rgb24()

void mpix_convert_palette2_to_rgb24 ( const uint8_t *  src,
uint8_t *  dst,
uint16_t  width,
const struct mpix_palette palette 
)

Convert a line of pixel data from PALETTE2 to RGB24.

You only need to call this function to work directly on raw buffers. See mpix_image_palettize for a more convenient high-level API.

Parameters
srcBuffer of the input line, with the format XXX in mpix_palettize_XXX_to_YYY().
dstBuffer of the output line, with the format YYY in mpix_palettize_XXX_to_YYY().
widthWidth of the lines in number of pixels.
paletteColor palette to use for the conversion.

◆ mpix_convert_palette4_to_rgb24()

void mpix_convert_palette4_to_rgb24 ( const uint8_t *  src,
uint8_t *  dst,
uint16_t  width,
const struct mpix_palette palette 
)

Convert a line of pixel data from PALETTE4 to RGB24.

You only need to call this function to work directly on raw buffers. See mpix_image_palettize for a more convenient high-level API.

Parameters
srcBuffer of the input line, with the format XXX in mpix_palettize_XXX_to_YYY().
dstBuffer of the output line, with the format YYY in mpix_palettize_XXX_to_YYY().
widthWidth of the lines in number of pixels.
paletteColor palette to use for the conversion.

◆ mpix_convert_palette8_to_rgb24()

void mpix_convert_palette8_to_rgb24 ( const uint8_t *  src,
uint8_t *  dst,
uint16_t  width,
const struct mpix_palette palette 
)

Convert a line of pixel data from PALETTE8 to RGB24.

You only need to call this function to work directly on raw buffers. See mpix_image_palettize for a more convenient high-level API.

Parameters
srcBuffer of the input line, with the format XXX in mpix_palettize_XXX_to_YYY().
dstBuffer of the output line, with the format YYY in mpix_palettize_XXX_to_YYY().
widthWidth of the lines in number of pixels.
paletteColor palette to use for the conversion.

◆ mpix_convert_rgb24_to_palette1()

void mpix_convert_rgb24_to_palette1 ( const uint8_t *  src,
uint8_t *  dst,
uint16_t  width,
const struct mpix_palette palette 
)

Convert a line of pixel data from RGB24 to PALETTE1.

You only need to call this function to work directly on raw buffers. See mpix_image_palettize for a more convenient high-level API.

Parameters
srcBuffer of the input line, with the format XXX in mpix_palettize_XXX_to_YYY().
dstBuffer of the output line, with the format YYY in mpix_palettize_XXX_to_YYY().
widthWidth of the lines in number of pixels.
paletteColor palette to use for the conversion.

◆ mpix_convert_rgb24_to_palette2()

void mpix_convert_rgb24_to_palette2 ( const uint8_t *  src,
uint8_t *  dst,
uint16_t  width,
const struct mpix_palette palette 
)

Convert a line of pixel data from RGB24 to PALETTE2.

You only need to call this function to work directly on raw buffers. See mpix_image_palettize for a more convenient high-level API.

Parameters
srcBuffer of the input line, with the format XXX in mpix_palettize_XXX_to_YYY().
dstBuffer of the output line, with the format YYY in mpix_palettize_XXX_to_YYY().
widthWidth of the lines in number of pixels.
paletteColor palette to use for the conversion.

◆ mpix_convert_rgb24_to_palette4()

void mpix_convert_rgb24_to_palette4 ( const uint8_t *  src,
uint8_t *  dst,
uint16_t  width,
const struct mpix_palette palette 
)

Convert a line of pixel data from RGB24 to PALETTE4.

You only need to call this function to work directly on raw buffers. See mpix_image_palettize for a more convenient high-level API.

Parameters
srcBuffer of the input line, with the format XXX in mpix_palettize_XXX_to_YYY().
dstBuffer of the output line, with the format YYY in mpix_palettize_XXX_to_YYY().
widthWidth of the lines in number of pixels.
paletteColor palette to use for the conversion.

◆ mpix_convert_rgb24_to_palette8()

void mpix_convert_rgb24_to_palette8 ( const uint8_t *  src,
uint8_t *  dst,
uint16_t  width,
const struct mpix_palette palette 
)

Convert a line of pixel data from RGB24 to PALETTE8.

You only need to call this function to work directly on raw buffers. See mpix_image_palettize for a more convenient high-level API.

Parameters
srcBuffer of the input line, with the format XXX in mpix_palettize_XXX_to_YYY().
dstBuffer of the output line, with the format YYY in mpix_palettize_XXX_to_YYY().
widthWidth of the lines in number of pixels.
paletteColor palette to use for the conversion.

◆ mpix_image_qoi_depalettize()

int mpix_image_qoi_depalettize ( struct mpix_image img,
size_t  max_sz,
struct mpix_palette plt 
)

;

◆ mpix_image_qoi_encode()

int mpix_image_qoi_encode ( struct mpix_image img,
size_t  max_sz 
)

;

◆ mpix_palettize_op()

void mpix_palettize_op ( struct mpix_base_op op)

Helper to turn a line palettization function into an operation.

The line conversion function is to be provided in op->arg. It processes on the input line to convert it to the destination format.

The palette is to be provided in op->arg1.

Parameters
opCurrent operation in progress.