How to create MagickImage from a pixel array

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
Hong
Posts: 2
Joined: 2018-07-13T16:55:45-07:00
Authentication code: 1152

How to create MagickImage from a pixel array

Post by Hong »

I am sorry for this rudimentary question. I am new to ImageMagick.

Here is my code:

Code: Select all

MagickReadSettings mr = new MagickReadSettings();
mr.ColorType = ColorType.TrueColor;
mr.Width = iWidth;
mr.Height = 1;
var image = new MagickImage(abPixels, mr);
abPixels is iWidth*1*3 byte array (i.e. three bytes for each pixel). The last line throws the following exception:
no decode delegate for this image format `' @ error/blob.c/BlobToImage/456

Could anyone offer a tip on this?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: How to create MagickImage from a pixel array

Post by dlemstra »

You should set mr.Format to MagickFormat.Rgb but that will only work when you use the Q8 version of Magick.NET. Otherwise you should change the byte array to an ushort array (Q16) or float array (Q16-HDRI) first.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Hong
Posts: 2
Joined: 2018-07-13T16:55:45-07:00
Authentication code: 1152

Re: How to create MagickImage from a pixel array

Post by Hong »

Thanks a lot. I apparently installed a wrong package. More importantly, I could not find the documentation that is right there as the first folder of the github home page of Magick.NET.
All clear now.
Post Reply