21 int Width {}, Height {};
22 int ComponentsCount {};
41 bool IsEmpty()
const {
return Data ==
nullptr; }
50 if (Other.Data ==
nullptr)
return;
53 Height = Other.Height;
54 ComponentsCount = Other.ComponentsCount;
56 size_t size = (size_t)Width * Height * ComponentsCount;
58 memcpy(Data, Other.Data, size);
64 if (
this == &Other || Other.Data ==
nullptr)
return *
this;
65 if (Data !=
nullptr)
delete[] Data;
68 Height = Other.Height;
69 ComponentsCount = Other.ComponentsCount;
71 size_t size = (size_t)Width * Height * ComponentsCount;
73 memcpy(Data, Other.Data, size);
85 image(
int Width,
int Height,
int ComponentsCount,
bool AllocateMemory =
true) :
86 Width(Width), Height(Height), ComponentsCount(ComponentsCount)
99 image(
int Width,
int Height,
int ComponentsCount,
void *Data) :
100 Width(Width), Height(Height), ComponentsCount(ComponentsCount)
102 size_t size = (size_t)Width * Height * ComponentsCount;
103 this->Data =
new u8[size];
104 memcpy(this->Data, Data, size);
114 this->
Load(FileName);
131 Data =
new u8[(
u64)Width * Height * ComponentsCount];
142 Width = Height = ComponentsCount = 0;
143 if (Data !=
nullptr) stbi_image_free(Data);
153 bool Load(
const std::string &FileName)
156 if (Data !=
nullptr)
delete[] Data;
160 Data = stbi_load(FileName.c_str(), &w, &h, &c, 0);
163 SCL_CORE_ERROR(
"Error during loading image from file \"{}\"!", FileName);
164 Width = Height = ComponentsCount = 0;
165 if (Data) stbi_image_free(Data);
170 Width = w, Height = h, ComponentsCount = c;
182 u32 row_size = Width * ComponentsCount;
183 u8 *tmp =
new u8[row_size];
184 for (
u64 i = 0; i < Height / 2; ++i)
186 std::memmove(tmp, &Data[i * row_size], row_size);
187 std::memmove(&Data[i * row_size], &Data[(Height - i - 1) * row_size], row_size);
188 std::memmove(&Data[(Height - i - 1) * row_size], tmp, row_size);
Topology object basis class for mesh creating implementation module.
const u8 * GetRawData() const
int GetComponentsCount() const
image(const std::string &FileName)
image(const image &Other)
image(int Width, int Height, int ComponentsCount, void *Data)
bool Load(const std::string &FileName)
image(int Width, int Height, int ComponentsCount, bool AllocateMemory=true)
image & operator=(const image &Other)
#define SCL_CORE_ERROR(...)