Replies: 1 comment 2 replies
-
We don't have something build in to ImageMagick to read an image like this. But it might be something we could add in the future if you happen to have a reference document of the format. For now I would advise you to read the image like this. The code below is not tested but I hope it might give you a few ideas how you can solve this: byte[] bytes;
var lengthInBytes = 2000 * 3000 * 2;
var offset = 16;
var settings = new PixelReadSettings(2000, 3000, StorageType.Short, "r");
using var image = new MagickImage();
image.ReadPixels(bytes, offset, lengthInBytes, settings);
settings.Mapping = "g";
using var green = new MagickImage();
green.ReadPixels(bytes, (offset * 2) + lengthInBytes, lengthInBytes, settings);
image.Composite(green, Channels.Green);
settings.Mapping = "b";
using var blue = new MagickImage();
blue.ReadPixels(bytes, (offset * 3) + (2 * lengthInBytes), lengthInBytes, settings);
image.Composite(blue, Channels.Blue); I might also have an other idea to make this easier. Would it be possible to share an example file? Feel free to reach out by email if you don't want to share that file publicly. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Ok, been playing with this for a few days now, but don't seem able to find the correct magical combination of defines to this type of file.
It is a file from a Pakon scanner, 3000x2000 pixels, 16-bit, three channels with a 16 byte header. With those values Photoshop can open it, so these must be right.
In ImageMagick that would be a size of 3000x2000+16, but that does not seem to go well with Magick.NET, so I believe I need a way to define that 16 byte header/offset somewhere else. Or maybe I have made another mistake. I'm on Visual Basic BTW.
Tried a lot of things, now my code looks like this:
Dim bytes = My.Computer.FileSystem.ReadAllBytes(RawfileName)
Dim RAWDefines As New MagickReadSettings
RAWDefines.SetDefine(MagickFormat.Rgb, "size", "2000x3000")
RAWDefines.SetDefine(MagickFormat.Rgb, "depth", "16")
RAWDefines.SetDefine(MagickFormat.Rgb, "interlace", "plane")
'and we should add something here as the file has a 16 byte offset
Dim RawImage As New MagickImage(bytes, RAWDefines)
PictureBox1.Image = RawImage.ToBitmap
This results in the error "no decode delegate for this image format `' @ error/blob.c/BlobToImage/460". Maybe because of the .RAW extension?
Any insight would be greatly appreciated.
Thanks
Jeroen
Beta Was this translation helpful? Give feedback.
All reactions