Add missing bmp and gif mimetypes

This commit is contained in:
Omar C. F 2018-02-10 09:09:41 +02:00 committed by GitHub
parent 0d9a495fd1
commit f8a8d9caa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -449,7 +449,7 @@ struct Image {
int component; int component;
std::vector<unsigned char> image; std::vector<unsigned char> image;
int bufferView; // (required if no uri) int bufferView; // (required if no uri)
std::string mimeType; // (required if no uri) ["image/jpeg", "image/png"] std::string mimeType; // (required if no uri) ["image/jpeg", "image/png", "image/bmp", "image/gif"]
std::string uri; // (reqiored if no mimeType) std::string uri; // (reqiored if no mimeType)
Value extras; Value extras;
@ -1224,13 +1224,23 @@ static bool IsDataURI(const std::string &in) {
return true; return true;
} }
header = "data:image/jpeg;base64,";
if (in.find(header) == 0) {
return true;
}
header = "data:image/png;base64,"; header = "data:image/png;base64,";
if (in.find(header) == 0) { if (in.find(header) == 0) {
return true; return true;
} }
header = "data:image/jpeg;base64,"; header = "data:image/bmp;base64,";
if (in.find(header) == 0) { if(in.find(header) == 0) {
return true;
}
header = "data:image/gif;base64,";
if(in.find(header) == 0) {
return true; return true;
} }
@ -1265,6 +1275,20 @@ static bool DecodeDataURI(std::vector<unsigned char> *out,
} }
} }
if (data.empty()) {
header = "data:image/bmp;base64,";
if (in.find(header) == 0) {
data = base64_decode(in.substr(header.size())); // cut mime string.
}
}
if (data.empty()) {
header = "data:image/gif;base64,";
if (in.find(header) == 0) {
data = base64_decode(in.substr(header.size())); // cut mime string.
}
}
if (data.empty()) { if (data.empty()) {
header = "data:text/plain;base64,"; header = "data:text/plain;base64,";
if (in.find(header) == 0) { if (in.find(header) == 0) {