OK, a few pointers for any other poor mortal who bites of more than they can chew.
-
Do I have to use DeviceImage, or can I use StreamImage?
This question related to the code here which uses DeviceImage. Given that the only ‘added value’ of DeviceImage is that it contains a reference to Device, I refactored the three classes from github, which ends up meaning that the signature of GetChunk isGetChunk(Image image, Device device)
. -
Do I really have to set PixelFormat to Raw to get the metadata?
It doesn’t look like it. -
Could someone point me towards documents which could at least give me the memory layout, offsets etc.?
I didn’t find any documents, but I’ve managed to get this far (as it’s all I need):
For the rest
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct NanoInfoChunk
{
public const uint ID = 0xCD000001;
public long Dummy;
public long ChunkExposureTime;
public long ChunkCyclingPresetCurrentActiveSet;
}
If you want to work on the rest, you can add the three middle lines to DeferenceNanoInfoOn (still inspired from the code posted on the other topic):
private static unsafe NanoInfoChunk DereferenceNanoInfoOn(Image image, GevChunk chunk)
{
var chunkPtr = new IntPtr(image.GetBufferBasePtr().ToInt64() + chunk.Offset);
byte[] bytes = new byte[chunk.Length];
Marshal.Copy(chunkPtr, bytes, 0, (int)chunk.Length);
System.Diagnostics.Debug.WriteLine(BitConverter.ToString(bytes));
return *(NanoInfoChunk*)chunkPtr;
}