mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 16:07:30 +03:00 
			
		
		
		
	adding RGBa->RGBA conversion
This commit is contained in:
		
							parent
							
								
									7077cd18af
								
							
						
					
					
						commit
						b9f94b7632
					
				|  | @ -289,6 +289,31 @@ rgba2rgba(UINT8* out, const UINT8* in, int xsize) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /* RGBa -> RGBA conversion to remove premultiplication 
 | ||||||
|  |    Needed for correct transforms/resizing on RGBA images */ | ||||||
|  | static void | ||||||
|  | rgba2rgbA(UINT8* out, const UINT8* in, int xsize) | ||||||
|  | { | ||||||
|  |     int x; | ||||||
|  |     unsigned int alpha; | ||||||
|  |     for (x = 0; x < xsize; x++, in+=4) { | ||||||
|  |         alpha = in[3]; | ||||||
|  |         if (alpha) { | ||||||
|  |             *out++ = CLIP((255 * in[0]) / alpha); | ||||||
|  |             *out++ = CLIP((255 * in[1]) / alpha); | ||||||
|  |             *out++ = CLIP((255 * in[2]) / alpha); | ||||||
|  |         } else { | ||||||
|  |             *out++ = in[0]; | ||||||
|  |             *out++ = in[1]; | ||||||
|  |             *out++ = in[2]; | ||||||
|  |         } | ||||||
|  |         *out++ = in[3]; | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| /* ---------------- */ | /* ---------------- */ | ||||||
| /* CMYK conversions */ | /* CMYK conversions */ | ||||||
| /* ---------------- */ | /* ---------------- */ | ||||||
|  | @ -619,6 +644,8 @@ static struct { | ||||||
|     { "RGBA", "CMYK", rgb2cmyk }, |     { "RGBA", "CMYK", rgb2cmyk }, | ||||||
|     { "RGBA", "YCbCr", ImagingConvertRGB2YCbCr }, |     { "RGBA", "YCbCr", ImagingConvertRGB2YCbCr }, | ||||||
| 
 | 
 | ||||||
|  |     { "RGBa", "RGBA", rgba2rgbA }, | ||||||
|  | 
 | ||||||
|     { "RGBX", "1", rgb2bit }, |     { "RGBX", "1", rgb2bit }, | ||||||
|     { "RGBX", "L", rgb2l }, |     { "RGBX", "L", rgb2l }, | ||||||
|     { "RGBA", "I", rgb2i }, |     { "RGBA", "I", rgb2i }, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user