Graphics.DrawImage unexpectedly resizing image

后端 未结 3 1957
梦谈多话
梦谈多话 2020-12-19 07:10

I\'ve got some code that takes a png that is a greyscale image with transparency and attempts to create a new image that has a given background colour (looked up from a data

3条回答
  •  不思量自难忘°
    2020-12-19 08:08

    Did you save and compared the generated images on both side? This looks a bit like a 24bit/32bit color problem.

    What happens if you use this constructor:

    public Bitmap( int width, int height, PixelFormat format )

    using (Bitmap newImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppArgb))
    

    As i read the remarks on MSDN:

    Remarks
    This constructor creates a Bitmap with a PixelFormat enumeration value of Format32bppArgb.
    

    It shouldn't make any difference.

提交回复
热议问题