2023-10-03 20:37:00 +02:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "IImage.h"
|
|
|
|
#include "rect.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace video
|
|
|
|
{
|
|
|
|
|
|
|
|
//! check sanity of image dimensions to prevent issues later, for use by CImageLoaders
|
|
|
|
inline bool checkImageDimensions(u32 width, u32 height)
|
|
|
|
{
|
|
|
|
// 4 * 23000 * 23000 is just under S32_MAX
|
|
|
|
return width <= 23000 && height <= 23000;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! IImage implementation with a lot of special image operations for
|
|
|
|
//! 16 bit A1R5G5B5/32 Bit A8R8G8B8 images, which are used by the SoftwareDevice.
|
|
|
|
class CImage : public IImage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//! constructor from raw image data
|
|
|
|
/** \param useForeignMemory: If true, the image will use the data pointer
|
|
|
|
directly and own it from now on, which means it will also try to delete [] the
|
|
|
|
data when the image will be destructed. If false, the memory will by copied. */
|
2024-03-20 19:35:52 +01:00
|
|
|
CImage(ECOLOR_FORMAT format, const core::dimension2d<u32> &size, void *data,
|
|
|
|
bool ownForeignMemory = true, bool deleteMemory = true);
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! constructor for empty image
|
2024-03-20 19:35:52 +01:00
|
|
|
CImage(ECOLOR_FORMAT format, const core::dimension2d<u32> &size);
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! returns a pixel
|
|
|
|
SColor getPixel(u32 x, u32 y) const override;
|
|
|
|
|
|
|
|
//! sets a pixel
|
2024-03-20 19:35:52 +01:00
|
|
|
void setPixel(u32 x, u32 y, const SColor &color, bool blend = false) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! copies this surface into another, if it has the exact same size and format.
|
2024-03-20 19:35:52 +01:00
|
|
|
bool copyToNoScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch = 0) const override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! copies this surface into another, scaling it to fit.
|
2024-03-20 19:35:52 +01:00
|
|
|
void copyToScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch = 0) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! copies this surface into another, scaling it to fit.
|
2024-03-20 19:35:52 +01:00
|
|
|
void copyToScaling(IImage *target) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! copies this surface into another
|
2024-03-20 19:35:52 +01:00
|
|
|
void copyTo(IImage *target, const core::position2d<s32> &pos = core::position2d<s32>(0, 0)) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! copies this surface into another
|
2024-03-20 19:35:52 +01:00
|
|
|
void copyTo(IImage *target, const core::position2d<s32> &pos, const core::rect<s32> &sourceRect, const core::rect<s32> *clipRect = 0) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! copies this surface into another, using the alpha mask, an cliprect and a color to add with
|
2024-03-20 19:35:52 +01:00
|
|
|
virtual void copyToWithAlpha(IImage *target, const core::position2d<s32> &pos,
|
|
|
|
const core::rect<s32> &sourceRect, const SColor &color,
|
|
|
|
const core::rect<s32> *clipRect = 0, bool combineAlpha = false) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! copies this surface into another, scaling it to fit, applying a box filter
|
2024-03-20 19:35:52 +01:00
|
|
|
void copyToScalingBoxFilter(IImage *target, s32 bias = 0, bool blend = false) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! fills the surface with given color
|
|
|
|
void fill(const SColor &color) override;
|
|
|
|
|
|
|
|
private:
|
2024-03-20 19:35:52 +01:00
|
|
|
inline SColor getPixelBox(s32 x, s32 y, s32 fx, s32 fy, s32 bias) const;
|
2023-10-03 20:37:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace video
|
|
|
|
} // end namespace irr
|