RAW Data length error (PixelStorageSettings issue)

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
pablobhz
Posts: 67
Joined: 2016-05-07T06:47:14-07:00
Authentication code: 1151

RAW Data length error (PixelStorageSettings issue)

Post by pablobhz » 2019-02-28T12:34:09-07:00

Hello Everyone.
I'm trying to create a new MagickIMage object from some raw CMYK Data.
In order to do so, i'm creating some PixelStorageSettings (as i learned before somewhere else, i think on some MagickImage doc site).

However, if i create the PixelStorageSettings with their original size, i get an error saying the array length is wrong
To be more specific:
The image width is 1497, height 1216
The data is 1,820,510 bytes

When i try to create it, the exception thrown is:
"System.ArgumentException: 'The array length is 1820352 but should be at least 7281408."

But i don't have any more data rather than this. The data stripped from the file is this. Nothing else more.

I did an test dividing width and height by two ; when i did that i was able to create the image.

Is there anything i'm missing ?
I'm posting my code here as well link to the files:

Thanks !

Code: Select all

var currSettings = new PixelStorageSettings(1497, 1216, StorageType.Char,PixelMapping.CMYK);
                MagickImage cyan = new MagickImage(@"C:\test\cyantwo.raw",currSettings);
                MagickImage magenta = new MagickImage(@"C:\test\magentatwo.raw", currSettings);
                MagickImage yellow = new MagickImage(@"C:\test\yellowtwo.raw", currSettings);
                MagickImage black = new MagickImage(@"C:\test\blacktwo.raw", currSettings);
Files: https://drive.google.com/drive/folders/ ... sp=sharing

User avatar
dlemstra
Posts: 1540
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: RAW Data length error (PixelStorageSettings issue)

Post by dlemstra » 2019-02-28T20:36:41-07:00

Your settings says you want to read a whole CMYK image at once but your files only contain one channel. You should read them as gray add them to a MagickImageCollection and call Combine to make one image.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

pablobhz
Posts: 67
Joined: 2016-05-07T06:47:14-07:00
Authentication code: 1151

Re: RAW Data length error (PixelStorageSettings issue)

Post by pablobhz » 2019-03-01T11:30:49-07:00

Hmmm
So i can combine the four channels into a single image array and then read with the PixelStorageSettings ?
Nice ! I'll give it a try right now and i'll post here my results.

Post Reply