integer math
This commit is contained in:
parent
4428cfe12c
commit
5ff43e240c
27 changed files with 922 additions and 1011 deletions
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
Crafter®.Graphics
|
||||
Copyright (C) 2025 Catcrafts®
|
||||
Catcrafts.net
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
module Crafter.Graphics:UiElementBufferBufferBase_impl;
|
||||
import :UiElement;
|
||||
import std;
|
||||
|
||||
using namespace Crafter;
|
||||
|
||||
UiElementBufferBufferBase::UiElementBufferBufferBase(std::uint_fast32_t width, std::uint_fast32_t height) : UiElementBuffer(width, height), buffer(width*height) {
|
||||
|
||||
}
|
||||
void UiElementBufferBufferBase::Create(std::uint_fast32_t width, std::uint_fast32_t height) {
|
||||
buffer.resize(width*height);
|
||||
}
|
||||
void UiElementBufferBufferBase::Resize(std::uint_fast32_t width, std::uint_fast32_t height) {
|
||||
buffer.resize(width*height);
|
||||
}
|
||||
void UiElementBufferBufferBase::Resize(std::uint_fast32_t width, std::uint_fast32_t height, std::uint_fast32_t offsetX, std::uint_fast32_t offsetY) {
|
||||
|
||||
}
|
||||
void UiElementBufferBufferBase::ResizeNearestNeighbour(std::uint_fast32_t width, std::uint_fast32_t height) {
|
||||
|
||||
}
|
||||
void UiElementBufferBufferBase::ResizeBicubic(std::uint_fast32_t width, std::uint_fast32_t height) {
|
||||
|
||||
}
|
||||
void UiElementBufferBufferBase::Destroy() {
|
||||
buffer.clear();
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
void UiElementBufferBufferBase::Copy(Pixel_BU8_GU8_RU8_AU8* dst) const {
|
||||
std::memcpy(dst, buffer.data(), width*height*sizeof(Pixel_BU8_GU8_RU8_AU8));
|
||||
}
|
||||
|
||||
void UiElementBufferBufferBase::CopyNearestNeighbour(Pixel_BU8_GU8_RU8_AU8* dst, std::uint_fast32_t dstWidth, std::uint_fast32_t dstHeight) const {
|
||||
for (std::uint_fast32_t y = 0; y < dstHeight; y++) {
|
||||
std::uint_fast32_t srcY = y * height / dstHeight;
|
||||
for (std::uint_fast32_t x = 0; x < dstWidth; x++) {
|
||||
std::uint_fast32_t srcX = x * width / dstWidth;
|
||||
dst[y * dstWidth + x] = buffer[srcY * width + srcX];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UiElementBufferBufferBase::CopyBicubic(Pixel_BU8_GU8_RU8_AU8* dst, std::uint_fast32_t dstWidth, std::uint_fast32_t dstHeight) const {
|
||||
|
||||
}
|
||||
void UiElementBufferBufferBase::Write(Pixel_BU8_GU8_RU8_AU8* pixels) {
|
||||
std::memcpy(buffer.data(), pixels, width*height*sizeof(Pixel_BU8_GU8_RU8_AU8));
|
||||
}
|
||||
void UiElementBufferBufferBase::Write(std::uint_fast32_t x, std::uint_fast32_t y, Pixel_BU8_GU8_RU8_AU8 pixel) {
|
||||
buffer[y * width + x] = pixel;
|
||||
}
|
||||
Pixel_BU8_GU8_RU8_AU8 UiElementBufferBufferBase::Read(std::uint_fast32_t x, std::uint_fast32_t y) const {
|
||||
return buffer[y * width + x];
|
||||
}
|
||||
const Pixel_BU8_GU8_RU8_AU8* UiElementBufferBufferBase::Read() const {
|
||||
return buffer.data();
|
||||
}
|
||||
Pixel_BU8_GU8_RU8_AU8* UiElementBufferBufferBase::Get() {
|
||||
return buffer.data();
|
||||
}
|
||||
void UiElementBufferBufferBase::Store() {
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue