diff --git a/src/loaders/jpg/tvgJpgLoader.cpp b/src/loaders/jpg/tvgJpgLoader.cpp index 685819b3..4a2ce3fe 100644 --- a/src/loaders/jpg/tvgJpgLoader.cpp +++ b/src/loaders/jpg/tvgJpgLoader.cpp @@ -76,8 +76,11 @@ bool JpgLoader::open(const string& path) if (fread(data, size, 1, jpegFile) < 1) goto failure; - if (tjDecompressHeader3(jpegDecompressor, data, size, &width, &height, &inSubsamp, &inColorspace) < 0) goto failure; + int width, height, subSample, colorSpace; + if (tjDecompressHeader3(jpegDecompressor, data, size, &width, &height, &subSample, &colorSpace) < 0) goto failure; + vw = w = static_cast(width); + vh = h = static_cast(height); ret = true; freeData = true; @@ -96,7 +99,8 @@ bool JpgLoader::open(const char* data, uint32_t size, bool copy) { clear(); - if (tjDecompressHeader3(jpegDecompressor, (unsigned char *) data, size, &width, &height, &inSubsamp, &inColorspace) < 0) return false; + int width, height, subSample, colorSpace; + if (tjDecompressHeader3(jpegDecompressor, (unsigned char *) data, size, &width, &height, &subSample, &colorSpace) < 0) return false; if (copy) { this->data = (unsigned char *) malloc(size); @@ -107,6 +111,8 @@ bool JpgLoader::open(const char* data, uint32_t size, bool copy) this->data = (unsigned char *) data; } + vw = w = static_cast(width); + vh = h = static_cast(height); this->size = size; return true; @@ -116,19 +122,16 @@ bool JpgLoader::open(const char* data, uint32_t size, bool copy) bool JpgLoader::read() { if (image) tjFree(image); - image = (unsigned char *)tjAlloc(width * height * tjPixelSize[TJPF_BGRX]); + image = (unsigned char *)tjAlloc(static_cast(w) * static_cast(h) * tjPixelSize[TJPF_BGRX]); if (!image) return false; //decompress jpg image - if (tjDecompress2(jpegDecompressor, data, size, image, width, 0, height, TJPF_BGRX, 0) < 0) { + if (tjDecompress2(jpegDecompressor, data, size, image, static_cast(w), 0, static_cast(h), TJPF_BGRX, 0) < 0) { tjFree(image); image = nullptr; return false; } - vw = w = width; - vh = h = height; - return true; } diff --git a/src/loaders/jpg/tvgJpgLoader.h b/src/loaders/jpg/tvgJpgLoader.h index 91218ba3..0063da2f 100644 --- a/src/loaders/jpg/tvgJpgLoader.h +++ b/src/loaders/jpg/tvgJpgLoader.h @@ -47,9 +47,6 @@ private: unsigned char *image = nullptr; unsigned long size = 0; bool freeData = false; - - int width, height; - int inSubsamp, inColorspace; }; #endif //_TVG_JPG_LOADER_H_