mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-31 18:35:41 +01:00 
			
		
		
		
	Merge "for ReadXXXX() image-readers, use the value of pic->use_argb"
This commit is contained in:
		| @@ -967,7 +967,11 @@ int main(int argc, const char *argv[]) { | |||||||
|     goto Error; |     goto Error; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Read the input |   // Read the input. We need to decide if we prefer ARGB or YUVA | ||||||
|  |   // samples, depending on the expected compression mode (this saves | ||||||
|  |   // some conversion steps). | ||||||
|  |   picture.use_argb = (config.lossless || config.preprocessing > 0 || | ||||||
|  |                       crop || (resize_w | resize_h) > 0); | ||||||
|   if (verbose) { |   if (verbose) { | ||||||
|     StopwatchReset(&stop_watch); |     StopwatchReset(&stop_watch); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -272,7 +272,6 @@ int ReadJPEG(FILE* in_file, WebPPicture* const pic, Metadata* const metadata) { | |||||||
|   // WebP conversion. |   // WebP conversion. | ||||||
|   pic->width = width; |   pic->width = width; | ||||||
|   pic->height = height; |   pic->height = height; | ||||||
|   pic->use_argb = 1;      // store raw RGB samples |  | ||||||
|   ok = WebPPictureImportRGB(pic, rgb, stride); |   ok = WebPPictureImportRGB(pic, rgb, stride); | ||||||
|   if (!ok) goto Error; |   if (!ok) goto Error; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ struct Metadata; | |||||||
| struct WebPPicture; | struct WebPPicture; | ||||||
|  |  | ||||||
| // Reads a JPEG from 'in_file', returning the decoded output in 'pic'. | // Reads a JPEG from 'in_file', returning the decoded output in 'pic'. | ||||||
| // The output is RGB. | // The output is RGB or YUV depending on pic->use_argb value. | ||||||
| // Returns true on success. | // Returns true on success. | ||||||
| int ReadJPEG(FILE* in_file, struct WebPPicture* const pic, | int ReadJPEG(FILE* in_file, struct WebPPicture* const pic, | ||||||
|              struct Metadata* const metadata); |              struct Metadata* const metadata); | ||||||
|   | |||||||
| @@ -270,7 +270,6 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha, | |||||||
|  |  | ||||||
|   pic->width = (int)width; |   pic->width = (int)width; | ||||||
|   pic->height = (int)height; |   pic->height = (int)height; | ||||||
|   pic->use_argb = 1; |  | ||||||
|   ok = has_alpha ? WebPPictureImportRGBA(pic, rgb, (int)stride) |   ok = has_alpha ? WebPPictureImportRGBA(pic, rgb, (int)stride) | ||||||
|                  : WebPPictureImportRGB(pic, rgb, (int)stride); |                  : WebPPictureImportRGB(pic, rgb, (int)stride); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -22,8 +22,9 @@ struct Metadata; | |||||||
| struct WebPPicture; | struct WebPPicture; | ||||||
|  |  | ||||||
| // Reads a PNG from 'in_file', returning the decoded output in 'pic'. | // Reads a PNG from 'in_file', returning the decoded output in 'pic'. | ||||||
|  | // Output is RGBA or YUVA, depending on pic->use_argb value. | ||||||
| // If 'keep_alpha' is true and the PNG has an alpha channel, the output is RGBA | // If 'keep_alpha' is true and the PNG has an alpha channel, the output is RGBA | ||||||
| // otherwise it will be RGB. | // or YUVA. Otherwise, alpha channel is dropped and output is RGB or YUV. | ||||||
| // Returns true on success. | // Returns true on success. | ||||||
| int ReadPNG(FILE* in_file, struct WebPPicture* const pic, int keep_alpha, | int ReadPNG(FILE* in_file, struct WebPPicture* const pic, int keep_alpha, | ||||||
|             struct Metadata* const metadata); |             struct Metadata* const metadata); | ||||||
|   | |||||||
| @@ -100,7 +100,6 @@ int ReadTIFF(const char* const filename, | |||||||
| #ifdef WORDS_BIGENDIAN | #ifdef WORDS_BIGENDIAN | ||||||
|       TIFFSwabArrayOfLong(raster, width * height); |       TIFFSwabArrayOfLong(raster, width * height); | ||||||
| #endif | #endif | ||||||
|       pic->use_argb = 1; |  | ||||||
|       ok = keep_alpha |       ok = keep_alpha | ||||||
|          ? WebPPictureImportRGBA(pic, (const uint8_t*)raster, stride) |          ? WebPPictureImportRGBA(pic, (const uint8_t*)raster, stride) | ||||||
|          : WebPPictureImportRGBX(pic, (const uint8_t*)raster, stride); |          : WebPPictureImportRGBX(pic, (const uint8_t*)raster, stride); | ||||||
|   | |||||||
| @@ -20,8 +20,9 @@ struct Metadata; | |||||||
| struct WebPPicture; | struct WebPPicture; | ||||||
|  |  | ||||||
| // Reads a TIFF from 'filename', returning the decoded output in 'pic'. | // Reads a TIFF from 'filename', returning the decoded output in 'pic'. | ||||||
|  | // Output is RGBA or YUVA, depending on pic->use_argb value. | ||||||
| // If 'keep_alpha' is true and the TIFF has an alpha channel, the output is RGBA | // If 'keep_alpha' is true and the TIFF has an alpha channel, the output is RGBA | ||||||
| // otherwise it will be RGB. | // or YUVA. Otherwise, alpha channel is dropped and output is RGB or YUV. | ||||||
| // Returns true on success. | // Returns true on success. | ||||||
| int ReadTIFF(const char* const filename, | int ReadTIFF(const char* const filename, | ||||||
|              struct WebPPicture* const pic, int keep_alpha, |              struct WebPPicture* const pic, int keep_alpha, | ||||||
|   | |||||||
| @@ -41,6 +41,8 @@ int ReadWebP(const char* const in_file, WebPPicture* const pic, | |||||||
|  |  | ||||||
|   if (ExUtilLoadWebP(in_file, &data, &data_size, bitstream)) { |   if (ExUtilLoadWebP(in_file, &data, &data_size, bitstream)) { | ||||||
|     const int has_alpha = keep_alpha && bitstream->has_alpha; |     const int has_alpha = keep_alpha && bitstream->has_alpha; | ||||||
|  |     // TODO(skal): use MODE_YUV(A), depending on the expected | ||||||
|  |     // input pic->use_argb. This would save some conversion steps. | ||||||
|     output_buffer->colorspace = has_alpha ? MODE_RGBA : MODE_RGB; |     output_buffer->colorspace = has_alpha ? MODE_RGBA : MODE_RGB; | ||||||
|  |  | ||||||
|     status = ExUtilDecodeWebP(data, data_size, 0, &config); |     status = ExUtilDecodeWebP(data, data_size, 0, &config); | ||||||
| @@ -49,7 +51,6 @@ int ReadWebP(const char* const in_file, WebPPicture* const pic, | |||||||
|       const int stride = output_buffer->u.RGBA.stride; |       const int stride = output_buffer->u.RGBA.stride; | ||||||
|       pic->width = output_buffer->width; |       pic->width = output_buffer->width; | ||||||
|       pic->height = output_buffer->height; |       pic->height = output_buffer->height; | ||||||
|       pic->use_argb = 1; |  | ||||||
|       ok = has_alpha ? WebPPictureImportRGBA(pic, rgba, stride) |       ok = has_alpha ? WebPPictureImportRGBA(pic, rgba, stride) | ||||||
|                      : WebPPictureImportRGB(pic, rgba, stride); |                      : WebPPictureImportRGB(pic, rgba, stride); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -20,8 +20,9 @@ struct Metadata; | |||||||
| struct WebPPicture; | struct WebPPicture; | ||||||
|  |  | ||||||
| // Reads a WebP from 'in_file', returning the decoded output in 'pic'. | // Reads a WebP from 'in_file', returning the decoded output in 'pic'. | ||||||
| // If 'keep_alpha' is true and the WebP has an alpha channel, the output is | // Output is RGBA or YUVA, depending on pic->use_argb value. | ||||||
| // RGBA otherwise it will be RGB. | // If 'keep_alpha' is true and the TIFF has an alpha channel, the output is RGBA | ||||||
|  | // or YUVA. Otherwise, alpha channel is dropped and output is RGB or YUV. | ||||||
| // Returns true on success. | // Returns true on success. | ||||||
| int ReadWebP(const char* const in_file, struct WebPPicture* const pic, | int ReadWebP(const char* const in_file, struct WebPPicture* const pic, | ||||||
|              int keep_alpha, struct Metadata* const metadata); |              int keep_alpha, struct Metadata* const metadata); | ||||||
|   | |||||||
| @@ -320,7 +320,7 @@ int ReadPictureWithWIC(const char* const filename, | |||||||
|     int ok; |     int ok; | ||||||
|     pic->width = width; |     pic->width = width; | ||||||
|     pic->height = height; |     pic->height = height; | ||||||
|     pic->use_argb = 1; |     pic->use_argb = 1;    // For WIC, we always force to argb | ||||||
|     ok = importer->import(pic, rgb, stride); |     ok = importer->import(pic, rgb, stride); | ||||||
|     if (!ok) hr = E_FAIL; |     if (!ok) hr = E_FAIL; | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ struct WebPPicture; | |||||||
|  |  | ||||||
| // Reads an image from 'filename', returning the decoded output in 'pic'. | // Reads an image from 'filename', returning the decoded output in 'pic'. | ||||||
| // If 'keep_alpha' is true and the image has an alpha channel, the output is | // If 'keep_alpha' is true and the image has an alpha channel, the output is | ||||||
| // RGBA otherwise it will be RGB. | // RGBA otherwise it will be RGB. pic->use_argb is always forced to true. | ||||||
| // Returns true on success. | // Returns true on success. | ||||||
| int ReadPictureWithWIC(const char* const filename, | int ReadPictureWithWIC(const char* const filename, | ||||||
|                        struct WebPPicture* const pic, int keep_alpha, |                        struct WebPPicture* const pic, int keep_alpha, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user