Hello all,
I have imaging particle detector with API in DLL.
This code working, device get image and return 0 indicating acquisition was OK
Declare Function pxcMeasureSingleFrameTpx3 Lib "pxcore.dll" (deviceIndex as Integer, frameTime as double, frameToaITot as Ptr, frameTotEvent as Ptr, size as Ptr, trgStg as integer) As Integer
(...)
Dim arr2 As New MemoryBlock(65536*2)
(...)
Dim a1, a2, si as Ptr
a1 = arr1
a2 = arr2
(...)
listbox1.addrow("pxcMeasureSingleFrameTpx3...")
App.DoEvents(100)
rc = pxcMeasureSingleFrameTpx3(0, 1.5, a1, a2, si, 0)
listbox1.addrow("rc " + rc.tostring)
Now is image data 256x256 pixels in memory blocks arr1 (double 0-1.5) and arr2 (short int 0-1022).
The arr2 is simple grayscale image.
How can i show it in the ImageViewer?
Thanks
If it is a recognised image format (JPEG / PNG) then use Picture.FromData
If it is raw pixel data then you could possibly use one of the MBS or Einhuger plugins.
Alternatively, you could probably do this by assigning the pixel values manually. Something like:
Dim memoryBlockOffset As Int32
Dim p As Picture
Dim r As RGBSurface
Dim x, y As Int32
Dim value As Int32
p = New Picture(256, 256)
r = p.RGBSurface
memoryBlockOffset = 0
For y = 0 To 255
For x = 0 To 255
value = theMemoryBlock.UInt8Value(memoryBlockOffset)
r.Pixel(y, x) = RGB(value, value, value)
memoryBlockOffset = memoryBlockOffset + 1
Next
Next
If I understand correctly, Picture.FromData requires a file format including a header. So Xojo itself does not allow you to display an image from simple pixel data.
Your for cycle is good solution, I usually need to do some more data processing ant it also need for cycle.
Thank you, data from our particle detectors can have various bit depths from 4 to 24 bits or is in the double format. If it used for xray imaging, a bad pixels correction is typically used, flat-field correction, range selection and gamma or logaritmization may be applied. If it used in particle research, data will be colorized by some color series.That’s why I’m comfortable using a for loop.