Release v0.6.35: reduce resident memory and compact shared dictionaries

This commit is contained in:
2026-11-04 14:08:05 +02:00
parent 004fee4976
commit d13e9849a7
21 changed files with 469 additions and 100 deletions
+11 -6
View File
@@ -123,13 +123,16 @@ struct OcrStatics : IInspectable
Pixels decodeImage(const Clip &clip, UINT maxWidth, UINT maxHeight)
{
Bytes encoded;
const Bytes *input = &encoded;
for (const auto &f : clip.formats)
if (f.name == L"PNG")
{
encoded = f.data;
input = &f.data;
break;
}
if (encoded.empty())
if (input->empty())
{
input = &encoded;
for (const auto &f : clip.formats)
if ((f.id == CF_DIB || f.id == CF_DIBV5) && f.data.size() >= 40)
{
@@ -146,19 +149,21 @@ Pixels decodeImage(const Clip &clip, UINT maxWidth, UINT maxHeight)
file.bfType = 0x4d42;
file.bfSize = (DWORD)(sizeof(file) + f.data.size());
file.bfOffBits = (DWORD)offset;
encoded.resize(sizeof(file));
encoded.resize(sizeof(file) + f.data.size());
memcpy(encoded.data(), &file, sizeof(file));
encoded.insert(encoded.end(), f.data.begin(), f.data.end());
memcpy(encoded.data() + sizeof(file), f.data.data(), f.data.size());
break;
}
if (encoded.empty())
}
if (input->empty())
throw std::runtime_error("This clipboard item has no supported image");
Com<IWICImagingFactory> wic;
check(CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory,
(void **)wic.out()));
Com<IWICStream> stream;
check(wic->CreateStream(stream.out()));
check(stream->InitializeFromMemory(encoded.data(), (DWORD)encoded.size()));
// WIC decoding only reads the stream. The clip outlives every WIC object here.
check(stream->InitializeFromMemory(const_cast<BYTE *>(input->data()), (DWORD)input->size()));
Com<IWICBitmapDecoder> decoder;
check(wic->CreateDecoderFromStream(stream.p, nullptr, WICDecodeMetadataCacheOnLoad, decoder.out()));
Com<IWICBitmapFrameDecode> frame;