Compare commits
13 Commits
dev-22e970
...
clipboard_
Author | SHA1 | Date | |
---|---|---|---|
e45b50befc | |||
77005cba4b | |||
c1af43ce54 | |||
2a94c72df9 | |||
b13a87a405 | |||
a5ec166794 | |||
35a0d97170 | |||
d0ab985349 | |||
b65b9b284b | |||
18db2e3aaa | |||
46ceb2cd61 | |||
979fd10b08 | |||
5f3bdde2dc |
21
.github/workflows/cd.yml
vendored
21
.github/workflows/cd.yml
vendored
@ -7,7 +7,8 @@ on:
|
|||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BUILD_TYPE: RelWithDebInfo
|
#BUILD_TYPE: RelWithDebInfo
|
||||||
|
BUILD_TYPE: Debug
|
||||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -28,7 +29,7 @@ jobs:
|
|||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
|
|
||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
@ -67,6 +68,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: update vcpkg
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd C:/vcpkg
|
||||||
|
git pull
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
||||||
|
|
||||||
@ -82,7 +89,7 @@ jobs:
|
|||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t tomato
|
||||||
|
|
||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
@ -121,6 +128,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: update vcpkg
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd C:/vcpkg
|
||||||
|
git pull
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
||||||
|
|
||||||
@ -136,7 +149,7 @@ jobs:
|
|||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
|
|
||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
|
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
|||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
@ -46,7 +46,7 @@ jobs:
|
|||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
@ -58,6 +58,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: update vcpkg
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd C:/vcpkg
|
||||||
|
git pull
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
||||||
|
|
||||||
@ -73,5 +79,5 @@ jobs:
|
|||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
||||||
|
|
||||||
|
5
external/sdl/CMakeLists.txt
vendored
5
external/sdl/CMakeLists.txt
vendored
@ -8,12 +8,17 @@ if (NOT TARGET SDL3::SDL3)
|
|||||||
#TODO: pic ?
|
#TODO: pic ?
|
||||||
|
|
||||||
FetchContent_Declare(SDL3
|
FetchContent_Declare(SDL3
|
||||||
|
#[[
|
||||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
||||||
#GIT_TAG 0429f5d6a36fc35b551bcc2acd4a40c2db6dab82 # tip when looking
|
#GIT_TAG 0429f5d6a36fc35b551bcc2acd4a40c2db6dab82 # tip when looking
|
||||||
#GIT_TAG 14f584a94bfd49cf1524db75bf3c419fdf9436cd # tip 26-04-2024
|
#GIT_TAG 14f584a94bfd49cf1524db75bf3c419fdf9436cd # tip 26-04-2024
|
||||||
GIT_TAG 06d6f2cb2518622593570985589700910cf4399f # 13-05-2024 - before
|
GIT_TAG 06d6f2cb2518622593570985589700910cf4399f # 13-05-2024 - before
|
||||||
# made changes that break imgui release 1.90.6
|
# made changes that break imgui release 1.90.6
|
||||||
#GIT_TAG 1103294d33f47ab4c697bb22a9cf27c79c658630 # tip 15-05-2024
|
#GIT_TAG 1103294d33f47ab4c697bb22a9cf27c79c658630 # tip 15-05-2024
|
||||||
|
]]
|
||||||
|
|
||||||
|
GIT_REPOSITORY https://github.com/Green-Sky/SDL.git
|
||||||
|
GIT_TAG windows_clipboard_fixes
|
||||||
FIND_PACKAGE_ARGS # for the future
|
FIND_PACKAGE_ARGS # for the future
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(SDL3)
|
FetchContent_MakeAvailable(SDL3)
|
||||||
|
2
external/solanaceae_message3
vendored
2
external/solanaceae_message3
vendored
Submodule external/solanaceae_message3 updated: 96b76dc67f...f03c4b1210
2
external/solanaceae_object_store
vendored
2
external/solanaceae_object_store
vendored
Submodule external/solanaceae_object_store updated: e26959c380...be24b3815b
2
external/solanaceae_tox
vendored
2
external/solanaceae_tox
vendored
Submodule external/solanaceae_tox updated: 2807239dea...676e50c61a
2
external/solanaceae_toxcore
vendored
2
external/solanaceae_toxcore
vendored
Submodule external/solanaceae_toxcore updated: cf3679018b...7cd6a2b0de
2
external/solanaceae_util
vendored
2
external/solanaceae_util
vendored
Submodule external/solanaceae_util updated: 2420af464f...4bda751f76
@ -152,7 +152,7 @@ void SendImagePopup::sendMemory(
|
|||||||
|
|
||||||
// copy paste data to memory
|
// copy paste data to memory
|
||||||
original_data.clear();
|
original_data.clear();
|
||||||
original_data.insert(original_data.begin(), data, data+data_size);
|
original_data.insert(original_data.cend(), data, data+data_size);
|
||||||
|
|
||||||
if (!load()) {
|
if (!load()) {
|
||||||
std::cerr << "SIP: failed to load image from memory\n";
|
std::cerr << "SIP: failed to load image from memory\n";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "./chat_gui4.hpp"
|
#include "./chat_gui4.hpp"
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
#include <solanaceae/message3/components.hpp>
|
#include <solanaceae/message3/components.hpp>
|
||||||
#include <solanaceae/tox_messages/components.hpp>
|
#include <solanaceae/tox_messages/components.hpp>
|
||||||
#include <solanaceae/contact/components.hpp>
|
#include <solanaceae/contact/components.hpp>
|
||||||
@ -26,6 +27,8 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <system_error>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
namespace Components {
|
namespace Components {
|
||||||
@ -89,6 +92,30 @@ static std::string file_path_url_escape(const std::string&& value) {
|
|||||||
return escaped.str();
|
return escaped.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string file_path_to_file_url(const std::filesystem::path& path) {
|
||||||
|
const auto can_path = std::filesystem::canonical(path);
|
||||||
|
std::string url {"file://"};
|
||||||
|
// special windows detection <.<
|
||||||
|
// we detect a drive letter here
|
||||||
|
if (can_path.has_root_name() && can_path.root_name().generic_u8string().back() == ':') {
|
||||||
|
const std::string root_name = can_path.root_name().generic_u8string();
|
||||||
|
// drive letters have a colon, which needs skipping the url escaping
|
||||||
|
url += "/";
|
||||||
|
url += root_name;
|
||||||
|
|
||||||
|
//url += "/";
|
||||||
|
// bugged, does not work (but it should, open msvc stl issue?)
|
||||||
|
//url += file_path_url_escape(can_path.lexically_proximate(can_path.root_name()).generic_u8string());
|
||||||
|
|
||||||
|
// remove drive letter
|
||||||
|
url += file_path_url_escape(can_path.generic_u8string().substr(root_name.size()));
|
||||||
|
} else {
|
||||||
|
url += file_path_url_escape(can_path.generic_u8string());
|
||||||
|
}
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
const void* clipboard_callback(void* userdata, const char* mime_type, size_t* size) {
|
const void* clipboard_callback(void* userdata, const char* mime_type, size_t* size) {
|
||||||
if (mime_type == nullptr) {
|
if (mime_type == nullptr) {
|
||||||
// cleared or new data is set
|
// cleared or new data is set
|
||||||
@ -130,13 +157,30 @@ void ChatGui4::setClipboardData(std::vector<std::string> mime_types, std::shared
|
|||||||
|
|
||||||
std::vector<const char*> tmp_mimetype_list;
|
std::vector<const char*> tmp_mimetype_list;
|
||||||
|
|
||||||
std::lock_guard lg{_set_clipboard_data_mutex};
|
{
|
||||||
for (const auto& mime_type : mime_types) {
|
std::lock_guard lg{_set_clipboard_data_mutex};
|
||||||
tmp_mimetype_list.push_back(mime_type.data());
|
for (const auto& mime_type : mime_types) {
|
||||||
_set_clipboard_data[mime_type] = data;
|
tmp_mimetype_list.push_back(mime_type.data());
|
||||||
|
_set_clipboard_data[mime_type] = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// release lock, since on some platforms the callback is called immediatly
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetClipboardData(clipboard_callback, nullptr, this, tmp_mimetype_list.data(), tmp_mimetype_list.size());
|
try {
|
||||||
|
SDL_SetClipboardData(clipboard_callback, nullptr, this, tmp_mimetype_list.data(), tmp_mimetype_list.size());
|
||||||
|
} catch (const std::runtime_error& e) {
|
||||||
|
std::cerr << "CG error: setting clipboard data threw runtime_error!\n";
|
||||||
|
std::cerr << "what: " << e.what() << "\n";
|
||||||
|
} catch (const std::system_error& e) {
|
||||||
|
std::cerr << "CG error: setting clipboard data threw system_error!\n";
|
||||||
|
std::cerr << "what: " << e.what() << "\n";
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "CG error: setting clipboard data threw exception!\n";
|
||||||
|
std::cerr << "what: " << e.what() << "\n";
|
||||||
|
} catch (...) {
|
||||||
|
std::cerr << "CG error: setting clipboard data threw!\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatGui4::ChatGui4(
|
ChatGui4::ChatGui4(
|
||||||
@ -974,12 +1018,12 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) {
|
|||||||
const auto& local_info = reg.get<Message::Components::Transfer::FileInfoLocal>(e);
|
const auto& local_info = reg.get<Message::Components::Transfer::FileInfoLocal>(e);
|
||||||
if (local_info.file_list.size() > i && ImGui::BeginPopupContextItem("##file_c")) {
|
if (local_info.file_list.size() > i && ImGui::BeginPopupContextItem("##file_c")) {
|
||||||
if (ImGui::MenuItem("open")) {
|
if (ImGui::MenuItem("open")) {
|
||||||
const std::string url{"file://" + file_path_url_escape(std::filesystem::canonical(local_info.file_list.at(i)).generic_u8string())};
|
const std::string url {file_path_to_file_url(local_info.file_list.at(i))};
|
||||||
std::cout << "opening file '" << url << "'\n";
|
std::cout << "opening file '" << url << "'\n";
|
||||||
SDL_OpenURL(url.c_str());
|
SDL_OpenURL(url.c_str());
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem("copy file")) {
|
if (ImGui::MenuItem("copy file")) {
|
||||||
const std::string url{"file://" + file_path_url_escape(std::filesystem::canonical(local_info.file_list.at(i)).generic_u8string())};
|
const std::string url {file_path_to_file_url(local_info.file_list.at(i))};
|
||||||
//ImGui::SetClipboardText(url.c_str());
|
//ImGui::SetClipboardText(url.c_str());
|
||||||
setClipboardData({"text/uri-list", "text/x-moz-url"}, std::make_shared<std::vector<uint8_t>>(url.begin(), url.end()));
|
setClipboardData({"text/uri-list", "text/x-moz-url"}, std::make_shared<std::vector<uint8_t>>(url.begin(), url.end()));
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ ImageLoaderQOI::ImageResult ImageLoaderQOI::loadFromMemoryRGBA(const uint8_t* da
|
|||||||
|
|
||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = 0;
|
new_frame.ms = 0;
|
||||||
new_frame.data.insert(new_frame.data.cbegin(), img_data, img_data+(desc.width*desc.height*4));
|
new_frame.data.insert(new_frame.data.cend(), img_data, img_data+(desc.width*desc.height*4));
|
||||||
|
|
||||||
free(img_data);
|
free(img_data);
|
||||||
return res;
|
return res;
|
||||||
|
@ -47,7 +47,7 @@ ImageLoaderSDLBMP::ImageResult ImageLoaderSDLBMP::loadFromMemoryRGBA(const uint8
|
|||||||
|
|
||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = 0;
|
new_frame.ms = 0;
|
||||||
new_frame.data.insert(new_frame.data.cbegin(), (const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (surf->w*surf->h*4));
|
new_frame.data.insert(new_frame.data.cend(), (const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (surf->w*surf->h*4));
|
||||||
|
|
||||||
SDL_UnlockSurface(conv_surf);
|
SDL_UnlockSurface(conv_surf);
|
||||||
SDL_DestroySurface(conv_surf);
|
SDL_DestroySurface(conv_surf);
|
||||||
|
@ -99,7 +99,7 @@ ImageLoaderSDLImage::ImageResult ImageLoaderSDLImage::loadFromMemoryRGBA(const u
|
|||||||
|
|
||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = anim->delays[i];
|
new_frame.ms = anim->delays[i];
|
||||||
new_frame.data.insert(new_frame.data.cbegin(), (const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (anim->w*anim->h*4));
|
new_frame.data.insert(new_frame.data.cend(), (const uint8_t*)conv_surf->pixels, ((const uint8_t*)conv_surf->pixels) + (anim->w*anim->h*4));
|
||||||
|
|
||||||
SDL_UnlockSurface(conv_surf);
|
SDL_UnlockSurface(conv_surf);
|
||||||
SDL_DestroySurface(conv_surf);
|
SDL_DestroySurface(conv_surf);
|
||||||
|
@ -41,7 +41,7 @@ ImageLoaderSTB::ImageResult ImageLoaderSTB::loadFromMemoryRGBA(const uint8_t* da
|
|||||||
for (int i = 0; i < z; i++) {
|
for (int i = 0; i < z; i++) {
|
||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = delays[i];
|
new_frame.ms = delays[i];
|
||||||
new_frame.data.insert(new_frame.data.cbegin(), img_data + (i*stride), img_data + ((i+1)*stride));
|
new_frame.data.insert(new_frame.data.cend(), img_data + (i*stride), img_data + ((i+1)*stride));
|
||||||
}
|
}
|
||||||
|
|
||||||
stbi_image_free(delays); // hope this is right
|
stbi_image_free(delays); // hope this is right
|
||||||
@ -62,7 +62,7 @@ ImageLoaderSTB::ImageResult ImageLoaderSTB::loadFromMemoryRGBA(const uint8_t* da
|
|||||||
|
|
||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = 0;
|
new_frame.ms = 0;
|
||||||
new_frame.data.insert(new_frame.data.cbegin(), img_data, img_data+(x*y*4));
|
new_frame.data.insert(new_frame.data.cend(), img_data, img_data+(x*y*4));
|
||||||
|
|
||||||
stbi_image_free(img_data);
|
stbi_image_free(img_data);
|
||||||
return res;
|
return res;
|
||||||
|
@ -78,7 +78,7 @@ ImageLoaderWebP::ImageResult ImageLoaderWebP::loadFromMemoryRGBA(const uint8_t*
|
|||||||
auto& new_frame = res.frames.emplace_back();
|
auto& new_frame = res.frames.emplace_back();
|
||||||
new_frame.ms = timestamp-prev_timestamp;
|
new_frame.ms = timestamp-prev_timestamp;
|
||||||
prev_timestamp = timestamp;
|
prev_timestamp = timestamp;
|
||||||
new_frame.data.insert(new_frame.data.end(), buf, buf+(res.width*res.height*4));
|
new_frame.data.insert(new_frame.data.cend(), buf, buf+(res.width*res.height*4));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(anim_info.frame_count == res.frames.size());
|
assert(anim_info.frame_count == res.frames.size());
|
||||||
|
@ -32,7 +32,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
// more RAII
|
// more RAII
|
||||||
std::unique_ptr<SDL_Window, decltype(&SDL_DestroyWindow)> window {
|
std::unique_ptr<SDL_Window, decltype(&SDL_DestroyWindow)> window {
|
||||||
SDL_CreateWindow("tomato", 640, 480, SDL_WINDOW_RESIZABLE),
|
SDL_CreateWindow("tomato", 1280, 720, SDL_WINDOW_RESIZABLE),
|
||||||
&SDL_DestroyWindow
|
&SDL_DestroyWindow
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user