Release v0.6.57: multi-PC input, shared clipboard and resilient Settings Save
This commit is contained in:
1 parent
82292c8a7e
commit
5de010ee44
39 files changed
+1707
-312
No files matched your search
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include "ocr.h"
|
||||
#include <algorithm>
|
||||
namespace ks::lan
|
||||
{
|
||||
// Send one lossless image, not PNG plus multiple uncompressed DIB copies.
|
||||
inline Clip compactClipboardImage(Clip clip)
|
||||
{
|
||||
auto png=std::find_if(clip.formats.begin(),clip.formats.end(),[](const Format &f){return f.name==L"PNG";});
|
||||
bool image=png!=clip.formats.end()||std::any_of(clip.formats.begin(),clip.formats.end(),[](const Format &f){return f.id==CF_DIB||f.id==CF_DIBV5;});
|
||||
if(!image)return clip;
|
||||
Bytes bytes=png!=clip.formats.end()?png->data:encodePng(decodeImage(clip));
|
||||
std::erase_if(clip.formats,[](const Format &f){return f.id==CF_DIB||f.id==CF_DIBV5||f.name==L"PNG";});
|
||||
clip.formats.push_back({RegisterClipboardFormatW(L"PNG"),L"PNG",std::move(bytes)});
|
||||
return clip;
|
||||
}
|
||||
// Older applications paste DIB rather than PNG; expand only at the destination.
|
||||
inline Clip clipboardImageForPaste(Clip clip)
|
||||
{
|
||||
bool dib=false,png=false;
|
||||
for(const auto &f:clip.formats){dib|=f.id==CF_DIB||f.id==CF_DIBV5;png|=f.name==L"PNG";}
|
||||
if(png&&!dib)clip.formats.push_back(imageDib(decodeImage(clip)));
|
||||
return clip;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user