indexed-image

Is there a way to merge palettes for indexed pygame.Surfaces?

邮差的信 提交于 2019-12-12 03:25:15
问题 I have a Surface BaseSurf with an indexed colour palette, and I want to blit another indexed-colour Surface to it (let's call it NewSurf ). BaseSurf's palette is different from NewSurf's, though, and pygame does not automatically add the missing colours to BaseSurf's palette. I therefore need some way to append NewSurf's colours to BaseSurf's palette without mangling either (overwriting palette indices which are actually used by the Surface's pixels). When I run this code: screen = pygame

How to convert an Indexed pixel format image to a 32-bit image?

∥☆過路亽.° 提交于 2019-12-10 23:09:12
问题 I have an image that I get and attempt to load into a graphics object using Graphics.FromImage(image), however this throws an exception if the image has an indexed pixel format. Is there a way to safely convert an indexed image? Update: Thanks to Joe for the tip to just draw the old image over the new one, instead I was trying to convert it. This makes a lot of sense. 回答1: One easy way is to create a new image of the same size (with a 32-bit pixel format). Then create a graphics object for

Graphics on indexed image

我们两清 提交于 2019-11-27 15:39:34
问题 I am getting error: "A Graphics object cannot be created from an image that has an indexed pixel format." in function: public static void AdjustImage(ImageAttributes imageAttributes, Image image) { Rectangle rect = new Rectangle(0, 0, image.Width, image.Height); Graphics g = Graphics.FromImage(image); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(image, rect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); g.Dispose(); } I would like to ask you