Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no decode delegate for this image format #589

Open
simonbuehler opened this issue Mar 10, 2020 · 4 comments
Open

no decode delegate for this image format #589

simonbuehler opened this issue Mar 10, 2020 · 4 comments

Comments

@simonbuehler
Copy link

Description

I have a WriteableBitmap and want to create a MagickImage from it. I added the WriteableBitmapEx Extensions and using the ToByteArray Method like this:

var image = new MagickImage(Image.ToByteArray())

it does throw

ImageMagick.MagickMissingDelegateErrorException
  HResult=0x80131500
  Nachricht = no decode delegate for this image format `' @ error/blob.c/BlobToImage/458
  Quelle = Magick.NET-Q8-x64
  Stapelüberwachung:
   at ImageMagick.NativeInstance.CheckException(IntPtr exception, IntPtr result)
   at ImageMagick.MagickImage.NativeMagickImage.ReadBlob(MagickSettings settings, Byte[] data, Int32 offset, Int32 length)
   at ImageMagick.MagickImage.Read(Byte[] data, Int32 offset, Int32 length, MagickReadSettings readSettings, Boolean ping)
   at ImageMagick.MagickImage.Read(Byte[] data, MagickReadSettings readSettings)
   at ImageMagick.MagickImage..ctor(Byte[] data)

System Configuration

  • Magick.NET version: Magick.NET-Q8-x64
  • Environment (Operating system, version and so on): win10
@dlemstra
Copy link
Owner

What is the format of your Image? I suspect it is a format that is not recognized by Magick.NET by the header of the image data. Can you share a more complete example to demonstrate this issue?

@simonbuehler
Copy link
Author

hi,
a sample code would be:

BitmapImage bitmap = new BitmapImage(new Uri("1080x720.jpg")); // Just for demo, only WriteableBitmap  is available in real WPF Project
WriteableBitmap img = new WriteableBitmap(bitmap); // WPF Image Format
var image = new MagickImage(img .ToByteArray());

just reference the WriteableBitmapEx from nuget for the ToByteArray Extension Method

@simonbuehler
Copy link
Author

i added this method

public static byte[] ImageToBytee(WriteableBitmap imageSource)
        {
            var encoder = new BmpBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(imageSource));

            using (var ms = new MemoryStream())
            {
                encoder.Save(ms);
                return ms.ToArray();
            }
        }

and now the bmp data is accepted but its perfomance is bad, it would be great if a constructor for WriteableBitmap /BitmapSource like for Bitmap would be available

@dlemstra
Copy link
Owner

That it the same trick as that I am using in the Bitmap constructor but we could probably do this a lot more efficient by copying the pixels. Will take a look at this in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants