mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-31 18:35:41 +01:00 
			
		
		
		
	export alpha channel (if present) when dumping to PGM format
Change-Id: Ica1818937fa03b29a749887d28f49fe675c8b1db
This commit is contained in:
		| @@ -573,7 +573,8 @@ static int DumpPicture(const WebPPicture* const picture, const char* PGM_name) { | ||||
|   const int uv_width = (picture->width + 1) / 2; | ||||
|   const int uv_height = (picture->height + 1) / 2; | ||||
|   const int stride = (picture->width + 1) & ~1; | ||||
|   const int height = picture->height + uv_height; | ||||
|   const int alpha_height = picture->a ? picture->height : 0; | ||||
|   const int height = picture->height + uv_height + alpha_height; | ||||
|   FILE* const f = fopen(PGM_name, "wb"); | ||||
|   if (!f) return 0; | ||||
|   fprintf(f, "P5\n%d %d\n255\n", stride, height); | ||||
| @@ -588,6 +589,11 @@ static int DumpPicture(const WebPPicture* const picture, const char* PGM_name) { | ||||
|     if (fwrite(picture->v + y * picture->uv_stride, uv_width, 1, f) != 1) | ||||
|       return 0; | ||||
|   } | ||||
|   for (y = 0; y < alpha_height; ++y) { | ||||
|     if (fwrite(picture->a + y * picture->a_stride, picture->width, 1, f) != 1) | ||||
|       return 0; | ||||
|     if (picture->width & 1) fputc(0, f);  // pad | ||||
|   } | ||||
|   fclose(f); | ||||
|   return 1; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user