Compare commits
No commits in common. "02600a3bc6d5e537a792102ac56abd5c19c28131" and "f97134b84181ae66ffa0344984bc255873811999" have entirely different histories.
02600a3bc6
...
f97134b841
@ -668,7 +668,7 @@ float ChatGui4::render(float time_delta) {
|
||||
// TODO: dedup?
|
||||
ImGui::TextDisabled("_");
|
||||
} else {
|
||||
const auto& list = msg_reg.get<Message::Components::ReceivedBy>(e).ts;
|
||||
const auto list = msg_reg.get<Message::Components::ReceivedBy>(e).ts;
|
||||
// wrongly assumes contacts never get removed from a group
|
||||
if (sub_contacts != nullptr && list.size() < sub_contacts->size()) {
|
||||
// if partically delivered
|
||||
@ -915,6 +915,7 @@ float ChatGui4::render(float time_delta) {
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
// TODO: add support for more than images
|
||||
// !!! polling each frame can be VERY expensive !!!
|
||||
//const auto* mime_type = clipboardHasImage();
|
||||
@ -925,6 +926,7 @@ float ChatGui4::render(float time_delta) {
|
||||
} else if (const auto* fpmt = clipboardHasFileList(); fpmt != nullptr) {
|
||||
pasteFile(fpmt);
|
||||
}
|
||||
//} else if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
||||
} else if (ImGui::BeginPopupContextItem(nullptr, ImGuiMouseButton_Right)) {
|
||||
// TODO: use list instead
|
||||
const static std::vector<const char*> image_mime_types {
|
||||
@ -946,6 +948,7 @@ float ChatGui4::render(float time_delta) {
|
||||
}
|
||||
//ImGui::EndDisabled();
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
#if 0
|
||||
|
@ -104,11 +104,8 @@ std::vector<uint8_t> ImageEncoderWebP::encodeToMemoryRGBA(const ImageResult& inp
|
||||
// Tune 'enc_options' as needed.
|
||||
enc_options.minimize_size = 1; // might be slow? optimize for size, no key-frame insertion
|
||||
|
||||
std::unique_ptr<WebPAnimEncoder, decltype(&WebPAnimEncoderDelete)> enc {
|
||||
WebPAnimEncoderNew(input_image.width, input_image.height, &enc_options),
|
||||
&WebPAnimEncoderDelete
|
||||
};
|
||||
if (!enc) {
|
||||
WebPAnimEncoder* enc = WebPAnimEncoderNew(input_image.width, input_image.height, &enc_options);
|
||||
if (enc == nullptr) {
|
||||
std::cerr << "IEWebP error: WebPAnimEncoderNew()\n";
|
||||
return {};
|
||||
}
|
||||
@ -116,8 +113,10 @@ std::vector<uint8_t> ImageEncoderWebP::encodeToMemoryRGBA(const ImageResult& inp
|
||||
int prev_timestamp = 0;
|
||||
for (const auto& frame : input_image.frames) {
|
||||
WebPConfig config;
|
||||
//WebPConfigInit(&config);
|
||||
if (!WebPConfigPreset(&config, WebPPreset::WEBP_PRESET_DEFAULT, quality)) {
|
||||
std::cerr << "IEWebP error: WebPConfigPreset()\n";
|
||||
WebPAnimEncoderDelete(enc);
|
||||
return {};
|
||||
}
|
||||
//WebPConfigLosslessPreset(&config, 6); // 9 for max compression
|
||||
@ -125,34 +124,39 @@ std::vector<uint8_t> ImageEncoderWebP::encodeToMemoryRGBA(const ImageResult& inp
|
||||
WebPPicture frame_webp;
|
||||
if (!WebPPictureInit(&frame_webp)) {
|
||||
std::cerr << "IEWebP error: WebPPictureInit()\n";
|
||||
WebPAnimEncoderDelete(enc);
|
||||
return {};
|
||||
}
|
||||
frame_webp.width = input_image.width;
|
||||
frame_webp.height = input_image.height;
|
||||
if (!WebPPictureImportRGBA(&frame_webp, frame.data.data(), 4*input_image.width)) {
|
||||
std::cerr << "IEWebP error: WebPPictureImportRGBA()\n";
|
||||
WebPAnimEncoderDelete(enc);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!WebPAnimEncoderAdd(enc.get(), &frame_webp, prev_timestamp, &config)) {
|
||||
if (!WebPAnimEncoderAdd(enc, &frame_webp, prev_timestamp, &config)) {
|
||||
std::cerr << "IEWebP error: WebPAnimEncoderAdd()\n";
|
||||
WebPPictureFree(&frame_webp);
|
||||
WebPAnimEncoderDelete(enc);
|
||||
return {};
|
||||
}
|
||||
prev_timestamp += frame.ms;
|
||||
WebPPictureFree(&frame_webp);
|
||||
}
|
||||
if (!WebPAnimEncoderAdd(enc.get(), NULL, prev_timestamp, NULL)) { // tell anim encoder its the end
|
||||
if (!WebPAnimEncoderAdd(enc, NULL, prev_timestamp, NULL)) { // tell anim encoder its the end
|
||||
std::cerr << "IEWebP error: WebPAnimEncoderAdd(NULL)\n";
|
||||
WebPAnimEncoderDelete(enc);
|
||||
return {};
|
||||
}
|
||||
|
||||
WebPData webp_data;
|
||||
WebPDataInit(&webp_data);
|
||||
if (!WebPAnimEncoderAssemble(enc.get(), &webp_data)) {
|
||||
if (!WebPAnimEncoderAssemble(enc, &webp_data)) {
|
||||
std::cerr << "IEWebP error: WebPAnimEncoderAdd(NULL)\n";
|
||||
WebPAnimEncoderDelete(enc);
|
||||
return {};
|
||||
}
|
||||
WebPAnimEncoderDelete(enc);
|
||||
|
||||
// Write the 'webp_data' to a file, or re-mux it further.
|
||||
// TODO: make it not a copy
|
||||
|
Loading…
Reference in New Issue
Block a user