Blender  V3.3
Classes | Typedefs | Functions
rectop.c File Reference
#include <stdlib.h>
#include "BLI_math_base.h"
#include "BLI_math_color.h"
#include "BLI_math_color_blend.h"
#include "BLI_math_vector.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_colormanagement.h"
#include "MEM_guardedalloc.h"

Go to the source code of this file.

Classes

struct  RectBlendThreadData
 

Typedefs

typedef void(* IMB_blend_func) (unsigned char *dst, const unsigned char *src1, const unsigned char *src2)
 
typedef void(* IMB_blend_func_float) (float *dst, const float *src1, const float *src2)
 
typedef struct RectBlendThreadData RectBlendThreadData
 

Functions

void IMB_blend_color_byte (unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], IMB_BlendMode mode)
 
void IMB_blend_color_float (float dst[4], const float src1[4], const float src2[4], IMB_BlendMode mode)
 
void IMB_rectclip (ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
 
static void imb_rectclip3 (ImBuf *dbuf, const ImBuf *obuf, const ImBuf *sbuf, int *destx, int *desty, int *origx, int *origy, int *srcx, int *srcy, int *width, int *height)
 
void IMB_rectcpy (ImBuf *dbuf, const ImBuf *sbuf, int destx, int desty, int srcx, int srcy, int width, int height)
 
void IMB_rectblend (ImBuf *dbuf, const ImBuf *obuf, const ImBuf *sbuf, unsigned short *dmask, const unsigned short *curvemask, const unsigned short *texmask, float mask_max, int destx, int desty, int origx, int origy, int srcx, int srcy, int width, int height, IMB_BlendMode mode, bool accumulate)
 
static void rectblend_thread_do (void *data_v, int scanline)
 
void IMB_rectblend_threaded (ImBuf *dbuf, const ImBuf *obuf, const ImBuf *sbuf, unsigned short *dmask, const unsigned short *curvemask, const unsigned short *texmask, float mask_max, int destx, int desty, int origx, int origy, int srcx, int srcy, int width, int height, IMB_BlendMode mode, bool accumulate)
 
void IMB_rectfill (ImBuf *drect, const float col[4])
 
void IMB_rectfill_area_replace (const ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2)
 
void buf_rectfill_area (unsigned char *rect, float *rectf, int width, int height, const float col[4], struct ColorManagedDisplay *display, int x1, int y1, int x2, int y2)
 
void IMB_rectfill_area (ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2, struct ColorManagedDisplay *display)
 
void IMB_rectfill_alpha (ImBuf *ibuf, const float value)
 
Crop
static void rect_crop_4bytes (void **buf_p, const int size_src[2], const rcti *crop)
 
static void rect_crop_16bytes (void **buf_p, const int size_src[2], const rcti *crop)
 
void IMB_rect_crop (ImBuf *ibuf, const rcti *crop)
 
static void rect_realloc_4bytes (void **buf_p, const uint size[2])
 
static void rect_realloc_16bytes (void **buf_p, const uint size[2])
 
void IMB_rect_size_set (ImBuf *ibuf, const uint size[2])
 

Typedef Documentation

◆ IMB_blend_func

typedef void(* IMB_blend_func) (unsigned char *dst, const unsigned char *src1, const unsigned char *src2)

Definition at line 490 of file rectop.c.

◆ IMB_blend_func_float

typedef void(* IMB_blend_func_float) (float *dst, const float *src1, const float *src2)

Definition at line 493 of file rectop.c.

◆ RectBlendThreadData

Function Documentation

◆ buf_rectfill_area()

void buf_rectfill_area ( unsigned char *  rect,
float rectf,
int  width,
int  height,
const float  col[4],
struct ColorManagedDisplay display,
int  x1,
int  y1,
int  x2,
int  y2 
)

This should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it.

Definition at line 1128 of file rectop.c.

References Freestyle::a, CLAMP, col, copy_v4_v4(), fb(), height, IMB_colormanagement_display_to_scene_linear_v3(), srgb_to_linearrgb_v4(), SWAP, unit_float_to_uchar_clamp(), width, x2, and y1.

Referenced by BKE_image_stamp_buf(), and IMB_rectfill_area().

◆ IMB_blend_color_byte()

void IMB_blend_color_byte ( unsigned char  dst[4],
const unsigned char  src1[4],
const unsigned char  src2[4],
IMB_BlendMode  mode 
)

◆ IMB_blend_color_float()

void IMB_blend_color_float ( float  dst[4],
const float  src1[4],
const float  src2[4],
IMB_BlendMode  mode 
)

Definition at line 112 of file rectop.c.

References blend_color_add_alpha_float(), blend_color_add_float(), blend_color_burn_float(), blend_color_color_float(), blend_color_darken_float(), blend_color_difference_float(), blend_color_dodge_float(), blend_color_erase_alpha_float(), blend_color_exclusion_float(), blend_color_hardlight_float(), blend_color_hue_float(), blend_color_lighten_float(), blend_color_linearburn_float(), blend_color_linearlight_float(), blend_color_luminosity_float(), blend_color_mix_float(), blend_color_mul_float(), blend_color_overlay_float(), blend_color_pinlight_float(), blend_color_saturation_float(), blend_color_screen_float(), blend_color_softlight_float(), blend_color_sub_float(), blend_color_vividlight_float(), IMB_BLEND_ADD, IMB_BLEND_ADD_ALPHA, IMB_BLEND_COLOR, IMB_BLEND_COLORBURN, IMB_BLEND_COLORDODGE, IMB_BLEND_DARKEN, IMB_BLEND_DIFFERENCE, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_EXCLUSION, IMB_BLEND_HARDLIGHT, IMB_BLEND_HUE, IMB_BLEND_LIGHTEN, IMB_BLEND_LINEARBURN, IMB_BLEND_LINEARLIGHT, IMB_BLEND_LUMINOSITY, IMB_BLEND_MIX, IMB_BLEND_MUL, IMB_BLEND_OVERLAY, IMB_BLEND_PINLIGHT, IMB_BLEND_SATURATION, IMB_BLEND_SCREEN, IMB_BLEND_SOFTLIGHT, IMB_BLEND_SUB, and IMB_BLEND_VIVIDLIGHT.

Referenced by do_paint_brush_task_cb_ex(), do_projectpaint_clone_f(), do_projectpaint_draw_f(), do_projectpaint_mask_f(), do_projectpaint_thread(), blender::ed::sculpt_paint::paint::image::PaintingKernel< ImageBuffer >::paint(), paint_2d_bucket_fill(), paint_2d_gradient_fill(), and sculpt_expand_colors_update_task_cb().

◆ IMB_rect_crop()

void IMB_rect_crop ( ImBuf ibuf,
const rcti crop 
)

◆ IMB_rect_size_set()

void IMB_rect_size_set ( struct ImBuf ibuf,
const uint  size[2] 
)

In-place size setting (caller must fill in buffer contents).

Definition at line 285 of file rectop.c.

References BLI_assert, ImBuf::rect, ImBuf::rect_float, rect_realloc_16bytes(), rect_realloc_4bytes(), size(), ImBuf::x, ImBuf::y, ImBuf::zbuf, and ImBuf::zbuf_float.

Referenced by ubuf_ensure_compat_ibuf().

◆ IMB_rectblend()

void IMB_rectblend ( ImBuf dbuf,
const ImBuf obuf,
const ImBuf sbuf,
unsigned short *  dmask,
const unsigned short *  curvemask,
const unsigned short *  texmask,
float  mask_max,
int  destx,
int  desty,
int  origx,
int  origy,
int  srcx,
int  srcy,
int  width,
int  height,
IMB_BlendMode  mode,
bool  accumulate 
)

Definition at line 495 of file rectop.c.

References blend_color_add_alpha_byte(), blend_color_add_alpha_float(), blend_color_add_byte(), blend_color_add_float(), blend_color_burn_byte(), blend_color_burn_float(), blend_color_color_byte(), blend_color_color_float(), blend_color_darken_byte(), blend_color_darken_float(), blend_color_difference_byte(), blend_color_difference_float(), blend_color_dodge_byte(), blend_color_dodge_float(), blend_color_erase_alpha_byte(), blend_color_erase_alpha_float(), blend_color_exclusion_byte(), blend_color_exclusion_float(), blend_color_hardlight_byte(), blend_color_hardlight_float(), blend_color_hue_byte(), blend_color_hue_float(), blend_color_interpolate_byte(), blend_color_interpolate_float(), blend_color_lighten_byte(), blend_color_lighten_float(), blend_color_linearburn_byte(), blend_color_linearburn_float(), blend_color_linearlight_byte(), blend_color_linearlight_float(), blend_color_luminosity_byte(), blend_color_luminosity_float(), blend_color_mix_byte(), blend_color_mix_float(), blend_color_mul_byte(), blend_color_mul_float(), blend_color_overlay_byte(), blend_color_overlay_float(), blend_color_pinlight_byte(), blend_color_pinlight_float(), blend_color_saturation_byte(), blend_color_saturation_float(), blend_color_screen_byte(), blend_color_screen_float(), blend_color_softlight_byte(), blend_color_softlight_float(), blend_color_sub_byte(), blend_color_sub_float(), blend_color_vividlight_byte(), blend_color_vividlight_float(), ImBuf::channels, divide_round_i(), float(), height, IMB_BLEND_ADD, IMB_BLEND_ADD_ALPHA, IMB_BLEND_COLOR, IMB_BLEND_COLORBURN, IMB_BLEND_COLORDODGE, IMB_BLEND_COPY, IMB_BLEND_COPY_ALPHA, IMB_BLEND_COPY_RGB, IMB_BLEND_DARKEN, IMB_BLEND_DIFFERENCE, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_EXCLUSION, IMB_BLEND_HARDLIGHT, IMB_BLEND_HUE, IMB_BLEND_INTERPOLATE, IMB_BLEND_LIGHTEN, IMB_BLEND_LINEARBURN, IMB_BLEND_LINEARLIGHT, IMB_BLEND_LUMINOSITY, IMB_BLEND_MIX, IMB_BLEND_MUL, IMB_BLEND_OVERLAY, IMB_BLEND_PINLIGHT, IMB_BLEND_SATURATION, IMB_BLEND_SCREEN, IMB_BLEND_SOFTLIGHT, IMB_BLEND_SUB, IMB_BLEND_VIVIDLIGHT, imb_rectclip3(), mask(), min_ff(), mul_v4_v4fl(), NULL, ImBuf::rect, ImBuf::rect_float, src, width, x, and ImBuf::x.

Referenced by IMB_rectblend_threaded(), IMB_rectcpy(), and rectblend_thread_do().

◆ IMB_rectblend_threaded()

void IMB_rectblend_threaded ( ImBuf dbuf,
const ImBuf obuf,
const ImBuf sbuf,
unsigned short *  dmask,
const unsigned short *  curvemask,
const unsigned short *  texmask,
float  mask_max,
int  destx,
int  desty,
int  origx,
int  origy,
int  srcx,
int  srcy,
int  width,
int  height,
IMB_BlendMode  mode,
bool  accumulate 
)

◆ IMB_rectclip()

void IMB_rectclip ( ImBuf dbuf,
const ImBuf sbuf,
int *  destx,
int *  desty,
int *  srcx,
int *  srcy,
int *  width,
int *  height 
)

Definition at line 305 of file rectop.c.

References height, NULL, width, ImBuf::x, and ImBuf::y.

◆ imb_rectclip3()

static void imb_rectclip3 ( ImBuf dbuf,
const ImBuf obuf,
const ImBuf sbuf,
int *  destx,
int *  desty,
int *  origx,
int *  origy,
int *  srcx,
int *  srcy,
int *  width,
int *  height 
)
static

Definition at line 367 of file rectop.c.

References height, NULL, width, ImBuf::x, and ImBuf::y.

Referenced by IMB_rectblend().

◆ IMB_rectcpy()

void IMB_rectcpy ( ImBuf dbuf,
const ImBuf sbuf,
int  destx,
int  desty,
int  srcx,
int  srcy,
int  width,
int  height 
)

Definition at line 462 of file rectop.c.

References height, IMB_BLEND_COPY, IMB_rectblend(), NULL, and width.

◆ IMB_rectfill()

void IMB_rectfill ( struct ImBuf drect,
const float  col[4] 
)
Attention
Defined in rectop.c Replace pixels of entire image with solid color.
Parameters
drectAn image to be filled with color. It must be 4 channel image.
colRGBA color, which is assigned directly to both byte (via scaling) and float buffers.

Definition at line 1050 of file rectop.c.

References col, ImBuf::rect, ImBuf::rect_float, ImBuf::x, and ImBuf::y.

Referenced by clear_single_image(), IMB_thumb_load_font(), and RE_bake_ibuf_clear().

◆ IMB_rectfill_alpha()

void IMB_rectfill_alpha ( ImBuf ibuf,
const float  value 
)

◆ IMB_rectfill_area()

void IMB_rectfill_area ( struct ImBuf ibuf,
const float  col[4],
int  x1,
int  y1,
int  x2,
int  y2,
struct ColorManagedDisplay display 
)

Blend pixels of image area with solid color.

For images with uchar buffer use color matching image color-space. For images with float buffer use color display color-space. If display color-space can not be referenced, use color in SRGB color-space.

Parameters
ibufan image to be filled with color. It must be 4 channel image.
colRGBA color.
x1,y1,x2,y2(x1, y1) defines starting point of the rectangular area to be filled, (x2, y2) is the end point. Note that values are allowed to be loosely ordered, which means that x2 is allowed to be lower than x1, as well as y2 is allowed to be lower than y1. No matter the order the area between x1 and x2, and y1 and y2 is filled.
displaycolor-space reference for display space.

Definition at line 1239 of file rectop.c.

References buf_rectfill_area(), col, ImBuf::rect, ImBuf::rect_float, ImBuf::x, x2, ImBuf::y, and y1.

◆ IMB_rectfill_area_replace()

void IMB_rectfill_area_replace ( const ImBuf ibuf,
const float  col[4],
int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 1082 of file rectop.c.

References BLI_assert, ImBuf::channels, CLAMP, col, height, offset, ImBuf::rect, ImBuf::rect_float, SWAP, width, x, ImBuf::x, x2, y, ImBuf::y, and y1.

◆ rect_crop_16bytes()

static void rect_crop_16bytes ( void **  buf_p,
const int  size_src[2],
const rcti crop 
)
static

Definition at line 220 of file rectop.c.

References BLI_rcti_size_x(), BLI_rcti_size_y(), MEM_reallocN, NULL, src, rcti::xmin, y, and rcti::ymin.

Referenced by IMB_rect_crop().

◆ rect_crop_4bytes()

static void rect_crop_4bytes ( void **  buf_p,
const int  size_src[2],
const rcti crop 
)
static

Definition at line 203 of file rectop.c.

References BLI_rcti_size_x(), BLI_rcti_size_y(), MEM_reallocN, NULL, src, rcti::xmin, y, and rcti::ymin.

Referenced by IMB_rect_crop().

◆ rect_realloc_16bytes()

static void rect_realloc_16bytes ( void **  buf_p,
const uint  size[2] 
)
static

Definition at line 276 of file rectop.c.

References MEM_freeN, MEM_mallocN, NULL, and size().

Referenced by IMB_rect_size_set().

◆ rect_realloc_4bytes()

static void rect_realloc_4bytes ( void **  buf_p,
const uint  size[2] 
)
static

Re-allocate buffers at a new size.

Definition at line 267 of file rectop.c.

References MEM_freeN, MEM_mallocN, NULL, and size().

Referenced by IMB_rect_size_set().

◆ rectblend_thread_do()

static void rectblend_thread_do ( void data_v,
int  scanline 
)
static

Definition at line 968 of file rectop.c.

References data, and IMB_rectblend().

Referenced by IMB_rectblend_threaded().