Skip to content

Commit

Permalink
Merge pull request #164 from KhronosGroup/fix-mime-types
Browse files Browse the repository at this point in the history
Fix png detection and strip period from extension for mime types
  • Loading branch information
lasalvavida authored Apr 4, 2018
2 parents 7e8a7da + 5558e24 commit 18bb9cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
Change Log
==========

### Next Release
### v2.1.1 - 2018-04-04

##### Additions :tada:
* Add support for exporting double sided materials [#133](https://github.com/KhronosGroup/COLLADA2GLTF/pull/133)

##### Fixes :wrench:
* Fixed issue where incorrect mime types were being generated [#162](https://github.com/KhronosGroup/COLLADA2GLTF/pull/164)

### v2.1.0 - 2018-03-15

##### Additions :tada:
Expand Down
5 changes: 3 additions & 2 deletions GLTF/src/GLTFImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ GLTF::Image::Image(std::string uri, std::string cacheKey) : uri(uri), cacheKey(c
GLTF::Image::Image(std::string uri) : Image(uri, "") {}

GLTF::Image::Image(std::string uri, std::string cacheKey, unsigned char* data, size_t byteLength, std::string fileExtension) : uri(uri), data(data), byteLength(byteLength), cacheKey(cacheKey) {
std::string dataSubstring((char*)data, 9);
if (dataSubstring.substr(1, 8) == "PNG\r\n\x1a\n") {
std::string dataSubstring((char*)data, 8);
if (dataSubstring.substr(1, 7) == "PNG\r\n\x1a\n") {
mimeType = "image/png";
}
else if (data[0] == 255 && data[1] == 216) {
Expand All @@ -41,6 +41,7 @@ GLTF::Image* GLTF::Image::load(path imagePath) {
return imageCacheIt->second;
}
std::string fileExtension = imagePath.extension().string();
fileExtension.erase(0, 1);
GLTF::Image* image = NULL;
FILE* file = fopen(fileString.c_str(), "rb");
if (file == NULL) {
Expand Down

0 comments on commit 18bb9cf

Please # to comment.