Skip to content

Commit

Permalink
Support images other than PNG (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
akorobko authored Dec 28, 2023
1 parent 7db1260 commit df10126
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions StreamDeckSDK/ESDConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,15 @@ void ESDConnectionManager::SetImage(

json payload;
payload[kESDSDKPayloadTarget] = inTarget;
const std::string prefix = "data:image/png;base64,";
const std::string pngPrefix = "data:image/png;base64,";
const std::string prefix = "data:image/";
if (
inBase64ImageString.empty()
|| inBase64ImageString.substr(0, prefix.length()).find(prefix) == 0)
payload[kESDSDKPayloadImage] = inBase64ImageString;
else
payload[kESDSDKPayloadImage]
= "data:image/png;base64," + inBase64ImageString;
// assume Base64-encoded PNG image
payload[kESDSDKPayloadImage] = pngPrefix + inBase64ImageString;
if (inState >= 0) {
payload[kESDSDKPayloadState] = inState;
}
Expand Down

0 comments on commit df10126

Please sign in to comment.