Saving images on the device adapter side


The situation:
We receive images from our device as raw binary data. Between the device and micromanager device adapter there is a low level driver program.
In micromanager we have “take image” command. Using this command results the low level driver program ending up loading the raw image binaries to computer into a file. Then when we press snap button in Micro-Manager and the SnapImage() in device adapter code is implemented so that it will locate the raw binary file and it will be rearranged so that it can be then placed into “ImgBuffer::SetPixels”. Micro-Manager then shows the image correctly in the new window opening with the inspection window.

The question:
We want the images to be saved here automatically and in tiff format preferably. Is this possible to do this in the device adapter cpp code?

The low level driver program uses readily made scripts and we would like to use micromanagers gui to set sliders and value fields to determine for example how many images to take and how much to move xy table in between.
It would be most convinient with our current setup to it so that this could be done by running a loop which controls the scripts used in lower level program. With each iteration it would build a save the received image. I am currently thinking of using external tiff creation cpp library, but wondered if saving images was possible with micromanagers available toolsets.

Thanks a lot if someone can help!