Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
imagesource.cpp File Reference
#include "imagesource.h"
#include <IFileSystem.h>
#include "imagefilters.h"
#include "mesh.h"
#include "renderingengine.h"
#include "settings.h"
#include "texturepaths.h"
#include "irrlicht_changes/printing.h"
#include "util/base64.h"
#include "util/numeric.h"
#include "util/strfnd.h"
+ Include dependency graph for imagesource.cpp:

Macros

#define CHECK_BASEIMG()
 
#define COMPLAIN_INVALID(description)
 
#define CHECK_DIM(w, h)
 

Functions

template<bool overlay = false>
static void blit_with_alpha (video::IImage *src, video::IImage *dst, v2s32 dst_pos, v2u32 size)
 Draw an image on top of another one with gamma-incorrect alpha compositing.
 
static void apply_colorize (video::IImage *dst, v2u32 dst_pos, v2u32 size, const video::SColor color, int ratio, bool keep_alpha)
 
static void apply_multiplication (video::IImage *dst, v2u32 dst_pos, v2u32 size, const video::SColor color)
 
static void apply_screen (video::IImage *dst, v2u32 dst_pos, v2u32 size, const video::SColor color)
 
static void apply_hue_saturation (video::IImage *dst, v2u32 dst_pos, v2u32 size, s32 hue, s32 saturation, s32 lightness, bool colorize)
 
static void apply_overlay (video::IImage *overlay, video::IImage *dst, v2s32 overlay_pos, v2s32 dst_pos, v2u32 size, bool hardlight)
 
static void apply_brightness_contrast (video::IImage *dst, v2u32 dst_pos, v2u32 size, s32 brightness, s32 contrast)
 
static void apply_mask (video::IImage *mask, video::IImage *dst, v2s32 mask_pos, v2s32 dst_pos, v2u32 size)
 
static void draw_crack (video::IImage *crack, video::IImage *dst, bool use_overlay, s32 frame_count, s32 progression, video::IVideoDriver *driver, u8 tiles=1)
 
void brighten (video::IImage *image)
 
u32 parseImageTransform (std::string_view s)
 
core::dimension2d< u32 > imageTransformDimension (u32 transform, core::dimension2d< u32 > dim)
 
void imageTransform (u32 transform, video::IImage *src, video::IImage *dst)
 
static void applyShadeFactor (video::SColor &color, u32 factor)
 
static video::IImage * createInventoryCubeImage (video::IImage *top, video::IImage *left, video::IImage *right)
 
static std::string unescape_string (const std::string &str, const char esc='\\')
 
void upscaleImagesToMatchLargest (video::IImage *&img1, video::IImage *&img2)
 
void blitBaseImage (video::IImage *&src, video::IImage *&dst)
 
template<bool overlay>
void blit_with_alpha (video::IImage *src, video::IImage *dst, v2s32 dst_pos, v2u32 size)
 Draw an image on top of another one with gamma-incorrect alpha compositing.
 
video::IImage * create_crack_image (video::IImage *crack, s32 frame_index, core::dimension2d< u32 > size, u8 tiles, video::IVideoDriver *driver)
 

Macro Definition Documentation

◆ CHECK_BASEIMG

#define CHECK_BASEIMG ( )
Value:
do { \
if (!baseimg) { \
errorstream << "generateImagePart(): baseimg == NULL" \
<< " for part_of_name=\"" << part_of_name \
<< "\", cancelling." << std::endl; \
return false; \
} \
} while(0)
thread_local LogStream errorstream

Referenced by ImageSource::generateImagePart().

◆ CHECK_DIM

#define CHECK_DIM ( w,
h )
Value:
do { \
if ((w) <= 0 || (h) <= 0 || (w) >= 0xffff || (h) >= 0xffff) { \
COMPLAIN_INVALID("width or height"); \
} \
} while(0)

Referenced by ImageSource::generateImagePart().

◆ COMPLAIN_INVALID

#define COMPLAIN_INVALID ( description)
Value:
do { \
errorstream << "generateImagePart(): invalid " << (description) \
<< " for part_of_name=\"" << part_of_name \
<< "\", cancelling." << std::endl; \
return false; \
} while(0)

Referenced by ImageSource::generateImagePart().

Function Documentation

◆ apply_brightness_contrast()

static void apply_brightness_contrast ( video::IImage * dst,
v2u32 dst_pos,
v2u32 size,
s32 brightness,
s32 contrast )
static

Referenced by ImageSource::generateImagePart().

+ Here is the caller graph for this function:

◆ apply_colorize()

static void apply_colorize ( video::IImage * dst,
v2u32 dst_pos,
v2u32 size,
const video::SColor color,
int ratio,
bool keep_alpha )
static

Referenced by ImageSource::generateImagePart().

+ Here is the caller graph for this function:

◆ apply_hue_saturation()

static void apply_hue_saturation ( video::IImage * dst,
v2u32 dst_pos,
v2u32 size,
s32 hue,
s32 saturation,
s32 lightness,
bool colorize )
static

Referenced by ImageSource::generateImagePart().

+ Here is the caller graph for this function:

◆ apply_mask()

static void apply_mask ( video::IImage * mask,
video::IImage * dst,
v2s32 mask_pos,
v2s32 dst_pos,
v2u32 size )
static

Referenced by ImageSource::generateImagePart().

+ Here is the caller graph for this function:

◆ apply_multiplication()

static void apply_multiplication ( video::IImage * dst,
v2u32 dst_pos,
v2u32 size,
const video::SColor color )
static

Referenced by ImageSource::generateImagePart().

+ Here is the caller graph for this function:

◆ apply_overlay()

static void apply_overlay ( video::IImage * overlay,
video::IImage * dst,
v2s32 overlay_pos,
v2s32 dst_pos,
v2u32 size,
bool hardlight )
static

References blend.

Referenced by ImageSource::generateImagePart().

+ Here is the caller graph for this function:

◆ apply_screen()

static void apply_screen ( video::IImage * dst,
v2u32 dst_pos,
v2u32 size,
const video::SColor color )
static

Referenced by ImageSource::generateImagePart().

+ Here is the caller graph for this function:

◆ applyShadeFactor()

static void applyShadeFactor ( video::SColor & color,
u32 factor )
inlinestatic

Referenced by createInventoryCubeImage().

+ Here is the caller graph for this function:

◆ blit_with_alpha() [1/2]

template<bool overlay = false>
static void blit_with_alpha ( video::IImage * src,
video::IImage * dst,
v2s32 dst_pos,
v2u32 size )
static

Draw an image on top of another one with gamma-incorrect alpha compositing.

This exists because IImage::copyToWithAlpha() doesn't seem to always work.

Template Parameters
overlayIf enabled, only modify pixels in dst which are fully opaque. Defaults to false.
Parameters
srcTop image. This image must have the ECF_A8R8G8B8 color format.
dstBottom image. The top image is drawn onto this base image in-place.
dst_posAn offset vector to move src before drawing it onto dst
sizeSize limit of the copied area

References RenderingEngine::get_video_driver().

Referenced by blitBaseImage(), draw_crack(), ImageSource::generateImage(), and ImageSource::generateImagePart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blit_with_alpha() [2/2]

template<bool overlay>
void blit_with_alpha ( video::IImage * src,
video::IImage * dst,
v2s32 dst_pos,
v2u32 size )

Draw an image on top of another one with gamma-incorrect alpha compositing.

This exists because IImage::copyToWithAlpha() doesn't seem to always work.

Template Parameters
overlayIf enabled, only modify pixels in dst which are fully opaque. Defaults to false.
Parameters
srcTop image. This image must have the ECF_A8R8G8B8 color format.
dstBottom image. The top image is drawn onto this base image in-place.
dst_posAn offset vector to move src before drawing it onto dst
sizeSize limit of the copied area

References RenderingEngine::get_video_driver().

Referenced by blitBaseImage(), draw_crack(), ImageSource::generateImage(), and ImageSource::generateImagePart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blitBaseImage()

void blitBaseImage ( video::IImage *& src,
video::IImage *& dst )

References blit_with_alpha(), and upscaleImagesToMatchLargest().

Referenced by ImageSource::generateImagePart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ brighten()

void brighten ( video::IImage * image)

Referenced by ImageSource::generateImagePart().

+ Here is the caller graph for this function:

◆ create_crack_image()

video::IImage * create_crack_image ( video::IImage * crack,
s32 frame_index,
core::dimension2d< u32 > size,
u8 tiles,
video::IVideoDriver * driver )

Referenced by draw_crack().

+ Here is the caller graph for this function:

◆ createInventoryCubeImage()

static video::IImage * createInventoryCubeImage ( video::IImage * top,
video::IImage * left,
video::IImage * right )
static

References applyShadeFactor(), RenderingEngine::get_video_driver(), npot2(), and sanity_check.

Referenced by ImageSource::generateImagePart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ draw_crack()

static void draw_crack ( video::IImage * crack,
video::IImage * dst,
bool use_overlay,
s32 frame_count,
s32 progression,
video::IVideoDriver * driver,
u8 tiles = 1 )
static

References blit_with_alpha(), and create_crack_image().

Referenced by ImageSource::generateImagePart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imageTransform()

void imageTransform ( u32 transform,
video::IImage * src,
video::IImage * dst )

References imageTransformDimension().

Referenced by ImageSource::generateImagePart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imageTransformDimension()

core::dimension2d< u32 > imageTransformDimension ( u32 transform,
core::dimension2d< u32 > dim )

Referenced by ImageSource::generateImagePart(), and imageTransform().

+ Here is the caller graph for this function:

◆ parseImageTransform()

u32 parseImageTransform ( std::string_view s)

References lowercase().

Referenced by ImageSource::generateImagePart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unescape_string()

◆ upscaleImagesToMatchLargest()

void upscaleImagesToMatchLargest ( video::IImage *& img1,
video::IImage *& img2 )

References RenderingEngine::get_video_driver().

Referenced by blitBaseImage(), and ImageSource::generateImagePart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: