更完
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include "Pixel_Frame.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
#include <tmmintrin.h>
|
||||
@@ -26,24 +25,6 @@ std::uint8_t flatten(std::uint8_t premultiplied, std::uint8_t alpha,
|
||||
|
||||
} // namespace
|
||||
|
||||
Pixel_Frame_Copy copy_pixel_frame(Image_View image) {
|
||||
Pixel_Frame_Copy copy;
|
||||
if (image.empty() || image.format != Pixel_Format::Premultiplied_32 ||
|
||||
image.stride < image.width * static_cast<int>(sizeof(Pixel))) {
|
||||
return copy;
|
||||
}
|
||||
copy.width = image.width;
|
||||
copy.height = image.height;
|
||||
copy.pixels.resize(static_cast<std::size_t>(image.width) *
|
||||
static_cast<std::size_t>(image.height));
|
||||
for (int y = 0; y < image.height; ++y) {
|
||||
const auto* source = image.data + static_cast<std::ptrdiff_t>(y) * image.stride;
|
||||
std::memcpy(copy.pixels.data() + static_cast<std::size_t>(y) * image.width,
|
||||
source, static_cast<std::size_t>(image.width) * sizeof(Pixel));
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
std::string encode_pixel_frame(Image_View image, Color background) {
|
||||
if (image.empty() || image.format != Pixel_Format::Premultiplied_32 ||
|
||||
image.stride < image.width * static_cast<int>(sizeof(Pixel))) {
|
||||
@@ -129,13 +110,4 @@ std::string encode_pixel_frame(Image_View image, Color background) {
|
||||
return frame;
|
||||
}
|
||||
|
||||
std::string encode_pixel_frame(const Pixel_Frame_Copy& image, Color background) {
|
||||
if (image.empty())
|
||||
return {};
|
||||
return encode_pixel_frame(
|
||||
{reinterpret_cast<const std::byte*>(image.pixels.data()), image.width, image.height,
|
||||
image.width * static_cast<int>(sizeof(Pixel)), Pixel_Format::Premultiplied_32},
|
||||
background);
|
||||
}
|
||||
|
||||
} // namespace renderive::web
|
||||
|
||||
Reference in New Issue
Block a user