Search code examples
magick.netimagemagick.net

Is it possible to convert a Windows bitmap with an Alpha channel to a MagickImage?


Using Magick.Net, Is it possible to convert (in memory) a Windows bitmap with an Alpha channel to a MagickImage? When I try the following, it fails with .net formats Format32bppPARgb and Format32bppARgb, but works fine with Format24bppRgb. The error message is "no decode delegate for this image format `XWD'".

bmp = New System.Drawing.Bitmap(400, 300, PixelFormat.Format32bppPARgb)
img = New MagickImage(bmp)

Solution

  • You are getting this exception due to a bug in ImageMagick. It reads the stream and tries to determine the format. It incorrectly decides that the format is XWD instead of BMP. I submitted a patch to the GIT repository of ImageMagick to fix this. Your code will work in Magick.NET 7.0.0.0018 that has not been released at the time of writing.