mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-27 08:33:03 +01:00 
			
		
		
		
	img2webp,get_disto: fix image decode w/WIC builds
similar to cwebp, attempt ReadPictureWithWIC() first Change-Id: Ifb83aaa457be59c95b201bf8bd6b0877a6a253ed
This commit is contained in:
		| @@ -69,6 +69,12 @@ static int ReadImage(const char filename[], WebPPicture* const pic) { | |||||||
|   size_t data_size = 0; |   size_t data_size = 0; | ||||||
|   WebPImageReader reader; |   WebPImageReader reader; | ||||||
|   int ok; |   int ok; | ||||||
|  | #ifdef HAVE_WINCODEC_H | ||||||
|  |   // Try to decode the file using WIC falling back to the other readers for | ||||||
|  |   // e.g., WebP. | ||||||
|  |   ok = ReadPictureWithWIC(filename, pic, 1, NULL); | ||||||
|  |   if (ok) return 1; | ||||||
|  | #endif | ||||||
|   if (!ImgIoUtilReadFile(filename, &data, &data_size)) return 0; |   if (!ImgIoUtilReadFile(filename, &data, &data_size)) return 0; | ||||||
|   reader = WebPGuessImageReader(data, data_size); |   reader = WebPGuessImageReader(data, data_size); | ||||||
|   ok = reader(data, data_size, pic, 1, NULL); |   ok = reader(data, data_size, pic, 1, NULL); | ||||||
|   | |||||||
| @@ -32,11 +32,19 @@ static int ReadPicture(const char* const filename, WebPPicture* const pic, | |||||||
|   const uint8_t* data = NULL; |   const uint8_t* data = NULL; | ||||||
|   size_t data_size = 0; |   size_t data_size = 0; | ||||||
|   WebPImageReader reader = NULL; |   WebPImageReader reader = NULL; | ||||||
|   int ok = ImgIoUtilReadFile(filename, &data, &data_size); |   int ok; | ||||||
|   if (!ok) goto Error; |  | ||||||
|  |  | ||||||
|   pic->use_argb = 1;  // force ARGB |   pic->use_argb = 1;  // force ARGB | ||||||
|  |  | ||||||
|  | #ifdef HAVE_WINCODEC_H | ||||||
|  |   // Try to decode the file using WIC falling back to the other readers for | ||||||
|  |   // e.g., WebP. | ||||||
|  |   ok = ReadPictureWithWIC(filename, pic, keep_alpha, NULL); | ||||||
|  |   if (ok) return 1; | ||||||
|  | #endif | ||||||
|  |   ok = ImgIoUtilReadFile(filename, &data, &data_size); | ||||||
|  |   if (!ok) goto Error; | ||||||
|  |  | ||||||
|   reader = WebPGuessImageReader(data, data_size); |   reader = WebPGuessImageReader(data, data_size); | ||||||
|   ok = reader(data, data_size, pic, keep_alpha, NULL); |   ok = reader(data, data_size, pic, keep_alpha, NULL); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user