2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2015 Aaron Suen <warr1024@gmail.com>
|
2015-03-09 09:32:11 -04:00
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2015-03-09 09:32:11 -04:00
|
|
|
|
2024-09-02 16:09:32 +02:00
|
|
|
#include "irrlichttypes.h"
|
|
|
|
#include <rect.h>
|
2024-12-30 22:17:52 +01:00
|
|
|
#include <SColor.h>
|
2024-09-02 16:09:32 +02:00
|
|
|
|
|
|
|
namespace irr::video
|
|
|
|
{
|
|
|
|
class IVideoDriver;
|
|
|
|
class IImage;
|
|
|
|
}
|
2015-03-09 09:32:11 -04:00
|
|
|
|
|
|
|
/* Fill in RGB values for transparent pixels, to correct for odd colors
|
|
|
|
* appearing at borders when blending. This is because many PNG optimizers
|
|
|
|
* like to discard RGB values of transparent pixels, but when blending then
|
2021-04-20 19:50:19 +02:00
|
|
|
* with non-transparent neighbors, their RGB values will show up nonetheless.
|
2015-03-09 09:32:11 -04:00
|
|
|
*
|
|
|
|
* This function modifies the original image in-place.
|
|
|
|
*
|
|
|
|
* Parameter "threshold" is the alpha level below which pixels are considered
|
2021-04-20 19:50:19 +02:00
|
|
|
* transparent. Should be 127 when the texture is used with ALPHA_CHANNEL_REF,
|
|
|
|
* 0 when alpha blending is used.
|
2015-03-09 09:32:11 -04:00
|
|
|
*/
|
|
|
|
void imageCleanTransparent(video::IImage *src, u32 threshold);
|
|
|
|
|
2024-12-30 22:17:52 +01:00
|
|
|
/* Returns the gamma-correct average color of the image, with transparent pixels
|
|
|
|
* ignored. */
|
|
|
|
video::SColor imageAverageColor(const video::IImage *img);
|
|
|
|
|
2015-03-09 09:32:11 -04:00
|
|
|
/* Scale a region of an image into another image, using nearest-neighbor with
|
|
|
|
* anti-aliasing; treat pixels as crisp rectangles, but blend them at boundaries
|
|
|
|
* to prevent non-integer scaling ratio artifacts. Note that this may cause
|
|
|
|
* some blending at the edges where pixels don't line up perfectly, but this
|
|
|
|
* filter is designed to produce the most accurate results for both upscaling
|
|
|
|
* and downscaling.
|
|
|
|
*/
|
|
|
|
void imageScaleNNAA(video::IImage *src, const core::rect<s32> &srcrect, video::IImage *dest);
|
2024-02-27 10:56:22 +01:00
|
|
|
|
|
|
|
/* Check and align image to npot2 if required by hardware
|
|
|
|
* @param image image to check for npot2 alignment
|
|
|
|
* @param driver driver to use for image operations
|
|
|
|
* @return image or copy of image aligned to npot2
|
|
|
|
*/
|
|
|
|
video::IImage *Align2Npot2(video::IImage *image, video::IVideoDriver *driver);
|
|
|
|
|