MagickNET and raw CMYK data

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

MagickNET and raw CMYK data

Post by pablobhz » 2019-02-02T21:30:01-07:00

Hello
Does MagickNET offers support for reading RAW CMYK Image data ?
ex: I have raw binary for one channel (cyan). Is there a way for MagickNet or ImageMagick to read it ?

Thanks in advance

snibgo
Posts: 12169
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: MagickNET and raw CMYK data

Post by snibgo » 2019-02-02T22:13:21-07:00

What do you mean by "raw"? Perhaps: no header, each pixel stored as a 8-bit or 16-bit number with no compression. See the "gray" format on http://www.imagemagick.org/script/formats.php
snibgo's IM pages: im.snibgo.com

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

Re: MagickNET and raw CMYK data

Post by pablobhz » 2019-02-02T22:16:57-07:00

Thats what i meant, sorry for the bad information.
No header, just pixels. Each pixel stored as an 8-Bit number.

I tried to read a byte array on this format and it didn't worked =(
Can MagickNet interpret it or only ImageMagick command-line version ?

snibgo
Posts: 12169
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: MagickNET and raw CMYK data

Post by snibgo » 2019-02-02T23:02:50-07:00

Sorry, I don't use Magick.NET. But I expect it can read "gray:" format, in the same way as the command line.
snibgo's IM pages: im.snibgo.com

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

Re: MagickNET and raw CMYK data

Post by dlemstra » 2019-02-03T07:56:20-07:00

You can use the PixelStorageSettings class for that. You can find an example in this recent issue: https://github.com/dlemstra/Magick.NET/issues/381
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

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

Re: MagickNET and raw CMYK data

Post by pablobhz » 2019-02-03T21:10:26-07:00

dlemstra wrote:
2019-02-03T07:56:20-07:00
You can use the PixelStorageSettings class for that. You can find an example in this recent issue: https://github.com/dlemstra/Magick.NET/issues/381
Thank you.
It worked flawlessly.

But how can i extract each channel from this PixelStorageSettings ?
I can't create individual objects from each array - it throws an error (The array length is 500396 but should be at least 2001580). Basically saying it can read only the entire array.

I've read the documentation on:
https://imagemagick.org/script/miff.php

But i couldn't understood. If i split my array lets say 4 by 4 bytes, the header+image data for that channel will be there ?
Ex: The cyan channel would be 0,4,8,12...and so on. Converting the PixelStorageSettings to ByteArray and extracting then (this way i mentioned) would work ?

Here's what i tried:

Code: Select all

var currSettings = new PixelStorageSettings(841, 595, StorageType.Char,PixelMapping.CMYK);
            MagickImage something = new MagickImage(currTiff, currSettings);
            using (var imgTest = new MagickImage(currTiff, currSettings))
            {
                var currPx = imgTest.GetPixels();
                IPixelCollection pixels = currPx;
                var pxVAl = pixels.GetValues();             
                byte[] targetArray = new byte[pxVAl.Length * 2];
                Buffer.BlockCopy(pxVAl, 0, targetArray, 0, pxVAl.Length * 2);
                byte[] anotherCyanChannel = new byte[targetArray.Length / 4];
                anotherCyanChannel = byteArrayBuilder(0, targetArray);
                MagickImage maybeitworks = new MagickImage(anotherCyanChannel);                
            }
Error: no decode for this format

Post Reply