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
MagickNET and raw CMYK data
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: MagickNET and raw CMYK data
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
Re: MagickNET and raw CMYK data
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 ?
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 ?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: MagickNET and raw CMYK data
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
Re: MagickNET and raw CMYK data
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
Re: MagickNET and raw CMYK data
Thank you.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
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);
}