Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub

Functions for image drawing. More...

Functions

SIMD_API void SimdAlphaBlending (const uint8_t *src, size_t srcStride, size_t width, size_t height, size_t channelCount, const uint8_t *alpha, size_t alphaStride, uint8_t *dst, size_t dstStride)
 Performs alpha blending operation. More...
 
SIMD_API void SimdAlphaBlending2x (const uint8_t *src0, size_t src0Stride, const uint8_t *alpha0, size_t alpha0Stride, const uint8_t *src1, size_t src1Stride, const uint8_t *alpha1, size_t alpha1Stride, size_t width, size_t height, size_t channelCount, uint8_t *dst, size_t dstStride)
 Performs double alpha blending operation. More...
 
SIMD_API void SimdAlphaBlendingBgraToYuv420p (const uint8_t *bgra, size_t bgraStride, size_t width, size_t height, uint8_t *y, size_t yStride, uint8_t *u, size_t uStride, uint8_t *v, size_t vStride, SimdYuvType yuvType)
 Performs alpha blending of BGRA image to YUV420P. More...
 
SIMD_API void SimdAlphaBlendingUniform (const uint8_t *src, size_t srcStride, size_t width, size_t height, size_t channelCount, uint8_t alpha, uint8_t *dst, size_t dstStride)
 Performs uniform alpha blending operation. More...
 
SIMD_API void SimdAlphaFilling (uint8_t *dst, size_t dstStride, size_t width, size_t height, const uint8_t *channel, size_t channelCount, const uint8_t *alpha, size_t alphaStride)
 Performs alpha filling operation. More...
 
SIMD_API void SimdAlphaPremultiply (const uint8_t *src, size_t srcStride, size_t width, size_t height, uint8_t *dst, size_t dstStride, SimdBool argb)
 Performs premultiply operation. More...
 
SIMD_API void SimdAlphaUnpremultiply (const uint8_t *src, size_t srcStride, size_t width, size_t height, uint8_t *dst, size_t dstStride, SimdBool argb)
 Performs unpremultiply operation. More...
 
template<template< class > class A>
SIMD_INLINE void AlphaBlending (const View< A > &src, const View< A > &alpha, View< A > &dst)
 Performs alpha blending operation. More...
 
template<template< class > class A>
SIMD_INLINE void AlphaBlending2x (const View< A > &src0, const View< A > &alpha0, const View< A > &src1, const View< A > &alpha1, View< A > &dst)
 Performs double alpha blending operation. More...
 
template<template< class > class A>
SIMD_INLINE void AlphaBlendingBgraToYuv420p (const View< A > &bgra, View< A > &y, View< A > &u, View< A > &v, SimdYuvType yuvType=SimdYuvBt601)
 Performs alpha blending of BGRA image to YUV420P. More...
 
template<template< class > class A>
SIMD_INLINE void AlphaBlending (const View< A > &src, uint8_t alpha, View< A > &dst)
 Performs alpha blending operation. More...
 
template<template< class > class A, class Pixel >
SIMD_INLINE void AlphaFilling (View< A > &dst, const Pixel &pixel, const View< A > &alpha)
 Performs alpha filling operation. More...
 
template<template< class > class A>
SIMD_INLINE void AlphaPremultiply (const View< A > &src, View< A > &dst)
 Performs premultiply operation. More...
 
template<template< class > class A>
SIMD_INLINE void AlphaUnpremultiply (const View< A > &src, View< A > &dst)
 Performs unpremultiply operation. More...
 

Detailed Description

Functions for image drawing.

Function Documentation

◆ SimdAlphaBlending()

void SimdAlphaBlending ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
size_t  channelCount,
const uint8_t *  alpha,
size_t  alphaStride,
uint8_t *  dst,
size_t  dstStride 
)

Performs alpha blending operation.

All images must have the same width and height. Source and destination images must have the same format (8 bit per channel, for example GRAY8, UV16, BGR24 or BGRA32). Alpha must be 8-bit gray image.

For every point:

dst[x, y, c] = (src[x, y, c]*alpha[x, y] + dst[x, y, c]*(255 - alpha[x, y]))/255;

This function is used for image drawing.

Note
This function has a C++ wrapper Simd::AlphaBlending(const View<A>& src, const View<A>& alpha, View<A>& dst).
Parameters
[in]src- a pointer to pixels data of foreground image.
[in]srcStride- a row size of the foreground image.
[in]width- an image width.
[in]height- an image height.
[in]channelCount- a channel count for foreground and background images (1 <= channelCount <= 4).
[in]alpha- a pointer to pixels data of image with alpha channel.
[in]alphaStride- a row size of the alpha image.
[in,out]dst- a pointer to pixels data of background image.
[in]dstStride- a row size of the background image.

◆ SimdAlphaBlending2x()

void SimdAlphaBlending2x ( const uint8_t *  src0,
size_t  src0Stride,
const uint8_t *  alpha0,
size_t  alpha0Stride,
const uint8_t *  src1,
size_t  src1Stride,
const uint8_t *  alpha1,
size_t  alpha1Stride,
size_t  width,
size_t  height,
size_t  channelCount,
uint8_t *  dst,
size_t  dstStride 
)

Performs double alpha blending operation.

All images must have the same width and height. Source and destination images must have the same format (8 bit per channel, for example GRAY8, UV16, BGR24 or BGRA32). Alphas must be 8-bit gray image.

For every point:

tmp = (src0[x, y, c]*alpha0[x, y] + dst[x, y, c]*(255 - alpha0[x, y]))/255;
dst[x, y, c] = (src1[x, y, c]*alpha1[x, y] + tmp*(255 - alpha1[x, y]))/255;

This function is used for image drawing.

Note
This function has a C++ wrapper Simd::AlphaBlending(const View<A>& src0, const View<A>& alpha0, const View<A>& src1, const View<A>& alpha1, View<A>& dst).
Parameters
[in]src0- a pointer to pixels data of the first foreground image.
[in]src0Stride- a row size of the first foreground image.
[in]alpha0- a pointer to pixels data of image with the first alpha channel.
[in]alpha0Stride- a row size of the first alpha image.
[in]src1- a pointer to pixels data of the second foreground image.
[in]src1Stride- a row size of the second foreground image.
[in]alpha1- a pointer to pixels data of image with the second alpha channel.
[in]alpha1Stride- a row size of the second alpha image.
[in]width- an image width.
[in]height- an image height.
[in]channelCount- a channel count for foreground and background images (1 <= channelCount <= 4).
[in,out]dst- a pointer to pixels data of background image.
[in]dstStride- a row size of the background image.

◆ SimdAlphaBlendingBgraToYuv420p()

void SimdAlphaBlendingBgraToYuv420p ( const uint8_t *  bgra,
size_t  bgraStride,
size_t  width,
size_t  height,
uint8_t *  y,
size_t  yStride,
uint8_t *  u,
size_t  uStride,
uint8_t *  v,
size_t  vStride,
SimdYuvType  yuvType 
)

Performs alpha blending of BGRA image to YUV420P.

This function is used for image drawing. The input BGRA and output Y images must have the same width and height. The output U and V images must have the same width and height (half size relative to Y component).

Note
This function has a C++ wrapper Simd::AlphaBlendingBgraToYuv420p(const View& bgra, View& y, View& u, View& v, SimdYuvType yuvType = SimdYuvBt601).
Parameters
[in]bgra- a pointer to pixels data of foreground BGRA-32 image.
[in]bgraStride- a row size of the foreground BGRA-32 image.
[in]width- an image width. It must be even.
[in]height- an image height. It must be even.
[in,out]y- a pointer to pixels data of Y-component of background YUV420P image.
[in]yStride- a row size of Y-component.
[in,out]u- a pointer to pixels data of U-component of background YUV420P image.
[in]uStride- a row size of U-component.
[in,out]v- a pointer to pixels data of V-component of background YUV420P image.
[in]vStride- a row size of V-component.
[in]yuvType- a type of output YUV image (see descriprion of SimdYuvType).

◆ SimdAlphaBlendingUniform()

void SimdAlphaBlendingUniform ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
size_t  channelCount,
uint8_t  alpha,
uint8_t *  dst,
size_t  dstStride 
)

Performs uniform alpha blending operation.

All images must have the same width and height. Source and destination images must have the same format (8 bit per channel, for example GRAY8, UV16, BGR24 or BGRA32).

For every point:

dst[x, y, c] = (src[x, y, c]*alpha + dst[x, y, c]*(255 - alpha))/255;

This function is used for image drawing.

Note
This function has a C++ wrapper Simd::AlphaBlending(const View<A>& src, uint8_t alpha, View<A>& dst).
Parameters
[in]src- a pointer to pixels data of foreground image.
[in]srcStride- a row size of the foreground image.
[in]width- an image width.
[in]height- an image height.
[in]channelCount- a channel count for foreground and background images (1 <= channelCount <= 4).
[in]alpha- a pvalue of alpha.
[in,out]dst- a pointer to pixels data of background image.
[in]dstStride- a row size of the background image.

◆ SimdAlphaFilling()

void SimdAlphaFilling ( uint8_t *  dst,
size_t  dstStride,
size_t  width,
size_t  height,
const uint8_t *  channel,
size_t  channelCount,
const uint8_t *  alpha,
size_t  alphaStride 
)

Performs alpha filling operation.

All images must have the same width and height. Destination images must have 8 bit per channel (for example GRAY8, BGR24 or BGRA32). Alpha must be 8-bit gray image.

For every point:

dst[x, y, c] = (channel[c]*alpha[x, y] + dst[x, y, c]*(255 - alpha[x, y]))/255;

This function is used for image drawing.

Note
This function has a C++ wrapper Simd::AlphaFilling(View<A> & dst, const Pixel & pixel, const View<A> & alpha).
Parameters
[in,out]dst- a pointer to pixels data of background image.
[in]dstStride- a row size of the background image.
[in]width- an image width.
[in]height- an image height.
[in]channel- a pointer to pixel with foreground color.
[in]channelCount- a channel count for foreground color and background images (1 <= channelCount <= 4).
[in]alpha- a pointer to pixels data of image with alpha channel.
[in]alphaStride- a row size of the alpha image.

◆ SimdAlphaPremultiply()

void SimdAlphaPremultiply ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
uint8_t *  dst,
size_t  dstStride,
SimdBool  argb 
)

Performs premultiply operation.

All images must have the same width, height and format (BGRA32, RGBA32, ARGB32).

For every point (sample for BGRA32):

 dst[x, y, 0] = src[x, y, 0] * src[x, y, 3] / 255;
 dst[x, y, 1] = src[x, y, 1] * src[x, y, 3] / 255;
 dst[x, y, 2] = src[x, y, 2] * src[x, y, 3] / 255;
 dst[x, y, 3] = src[x, y, 3];

This function is used for image drawing as a part of alpha blending operation.

Note
This function has a C++ wrapper Simd::AlphaPremultiply(const View<A>& src, View<A>& dst).
Parameters
[in]src- a pointer to pixels data of input image.
[in]srcStride- a row size of the input image.
[in]width- an image width.
[in]height- an image height.
[out]dst- a pointer to pixels data of output premultiplyed image.
[in]dstStride- a row size of the output premultiplyed image.
[in]argb- a boolean flag describing image format (BGRA32, RGBA32 - SimdFalse; ARGB32 - SimdTrue).

◆ SimdAlphaUnpremultiply()

void SimdAlphaUnpremultiply ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
uint8_t *  dst,
size_t  dstStride,
SimdBool  argb 
)

Performs unpremultiply operation.

All images must have the same width, height and format (BGRA32, RGBA32, ARGB32).

For every point (sample for BGRA32):

 dst[x, y, 0] = src[x, y, 0] / src[x, y, 3] * 255;
 dst[x, y, 1] = src[x, y, 1] / src[x, y, 3] * 255;
 dst[x, y, 2] = src[x, y, 2] / src[x, y, 3] * 255;
 dst[x, y, 3] = src[x, y, 3];

This function is used for image drawing as a part of alpha blending operation.

Note
This function has a C++ wrapper Simd::AlphaUnpremultiply(const View<A>& src, View<A>& dst).
Parameters
[in]src- a pointer to pixels data of input image.
[in]srcStride- a row size of the input image.
[in]width- an image width.
[in]height- an image height.
[out]dst- a pointer to pixels data of output unpremultiplyed image.
[in]dstStride- a row size of the output unpremultiplyed image.
[in]argb- a boolean flag describing image format (BGRA32, RGBA32 - SimdFalse; ARGB32 - SimdTrue).

◆ AlphaBlending() [1/2]

void AlphaBlending ( const View< A > &  src,
const View< A > &  alpha,
View< A > &  dst 
)

Performs alpha blending operation.

All images must have the same width and height. Source and destination images must have the same format (8 bit per channel, for example GRAY8, UV16, BGR24 or BGRA32). Alpha must be 8-bit gray image.

For every point:

dst[x, y, c] = (src[x, y, c]*alpha[x, y] + dst[x, y, c]*(255 - alpha[x, y]))/255;

This function is used for image drawing.

Note
This function is a C++ wrapper for function SimdAlphaBlending.
Parameters
[in]src- a foreground image.
[in]alpha- an image with alpha channel.
[in,out]dst- a background image.

◆ AlphaBlending2x()

void AlphaBlending2x ( const View< A > &  src0,
const View< A > &  alpha0,
const View< A > &  src1,
const View< A > &  alpha1,
View< A > &  dst 
)

Performs double alpha blending operation.

All images must have the same width and height. Source and destination images must have the same format (8 bit per channel, for example GRAY8, UV16, BGR24 or BGRA32). Alphas must be 8-bit gray image.

For every point:

tmp = (src0[x, y, c]*alpha0[x, y] + dst[x, y, c]*(255 - alpha0[x, y]))/255;
dst[x, y, c] = (src1[x, y, c]*alpha1[x, y] + tmp*(255 - alpha1[x, y]))/255;

This function is used for image drawing.

Note
This function is a C++ wrapper for function SimdAlphaBlending2x.
Parameters
[in]src0- the first foreground image.
[in]alpha0- the first image with alpha channel.
[in]src1- the second foreground image.
[in]alpha1- the second image with alpha channel.
[in,out]dst- a background image.

◆ AlphaBlendingBgraToYuv420p()

void AlphaBlendingBgraToYuv420p ( const View< A > &  bgra,
View< A > &  y,
View< A > &  u,
View< A > &  v,
SimdYuvType  yuvType = SimdYuvBt601 
)

Performs alpha blending of BGRA image to YUV420P.

This function is used for image drawing. The input BGRA and output Y images must have the same width and height. The output U and V images must have the same width and height (half size relative to Y component).

Note
This function is a C++ wrapper for function SimdAlphaBlendingBgraToYuv420p.
Parameters
[in]bgra- a foreground BGRA-32 image.
[in,out]y- Y-component of background YUV420P image.
[in,out]u- U-component of background YUV420P image.
[in,out]v- V-component of background YUV420P image.
[in]yuvType- a type of output YUV image (see descriprion of SimdYuvType). By default it is equal to SimdYuvBt601.

◆ AlphaBlending() [2/2]

void AlphaBlending ( const View< A > &  src,
uint8_t  alpha,
View< A > &  dst 
)

Performs alpha blending operation.

All images must have the same width and height. Source and destination images must have the same format (8 bit per channel, for example GRAY8, UV16, BGR24 or BGRA32).

For every point:

dst[x, y, c] = (src[x, y, c]*alpha + dst[x, y, c]*(255 - alpha))/255;

This function is used for image drawing.

Note
This function is a C++ wrapper for function SimdAlphaBlendingUniform.
Parameters
[in]src- a foreground image.
[in]alpha- a value of alpha.
[in,out]dst- a background image.

◆ AlphaFilling()

void AlphaFilling ( View< A > &  dst,
const Pixel &  pixel,
const View< A > &  alpha 
)

Performs alpha filling operation.

All images must have the same width and height. Destination images must have 8 bit per channel (for example GRAY8, BGR24 or BGRA32). Alpha must be 8-bit gray image.

For every point:

dst[x, y, c] = (pixel[c]*alpha[x, y] + dst[x, y, c]*(255 - alpha[x, y]))/255;

This function is used for image drawing.

Note
This function is a C++ wrapper for function SimdAlphaFilling.
Parameters
[in,out]dst- a background image.
[in]pixel- a foreground color.
[in]alpha- an image with alpha channel.

◆ AlphaPremultiply()

void AlphaPremultiply ( const View< A > &  src,
View< A > &  dst 
)

Performs premultiply operation.

All images must have the same width, height and format (BGRA32, RGBA32, ARGB32).

For every point (sample for BGRA32):

 dst[x, y, 0] = src[x, y, 0] * src[x, y, 3] / 255;
 dst[x, y, 1] = src[x, y, 1] * src[x, y, 3] / 255;
 dst[x, y, 2] = src[x, y, 2] * src[x, y, 3] / 255;
 dst[x, y, 3] = src[x, y, 3];

This function is used for image drawing as a part of alpha blending operation.

Note
This function is a C++ wrapper for function SimdAlphaPremultiply.
Parameters
[in]src- an input image.
[out]dst- an output premultiplyed image.

◆ AlphaUnpremultiply()

void AlphaUnpremultiply ( const View< A > &  src,
View< A > &  dst 
)

Performs unpremultiply operation.

All images must have the same width, height and format (BGRA32, RGBA32, ARGB32).

For every point (sample for BGRA32):

 dst[x, y, 0] = src[x, y, 0] / src[x, y, 3] * 255;
 dst[x, y, 1] = src[x, y, 1] / src[x, y, 3] * 255;
 dst[x, y, 2] = src[x, y, 2] / src[x, y, 3] * 255;
 dst[x, y, 3] = src[x, y, 3];

This function is used for image drawing as a part of alpha blending operation.

Note
This function is a C++ wrapper for function SimdAlphaUnpremultiply.
Parameters
[in]src- an input image.
[out]dst- an output unpremultiplyed image.