SetFormatChangedCallback
Top  Previous  Next

Description

Sets up a callback function which will be called when the image format is changed by a client application.

[C++]
int
 SetFormatChangedCallback(void* context, FormatChangedCallback callback);

   
where FormatChangedCallback type is defined as

    bool (*FormatChangedCallback)(void* context);


Parameters
[C/C++]
 
[in] void* context  
Address of the context in which the callback function will operate.  
 
[in] FormatChangedCallback callback  
Address of the callback function  
 

Return Values


S_OK  
Success  
E_FAIL  
Failure  
 

Example


This fragment of an MFC code uses a format changed callback to intercept requests for the change of the image size and modifies the image buffer and acquisition parameters accordingly:

      int
 onFormatChangedCallback(void
* context, const
 char
* feature)
      {
          CGigemuDlg* dlg = (CGigemuDlg*) context;
          return
 dlg->onFormatChanged();
      }

int CGigemuDlg::onFormatChanged()  
{  
   delete imgBuf;  
   imgBuf=new (m_pCamera->GetPayloadSize())  
     return 0;  
  }  
}  

      BOOL CGigemuDlg::OnInitDialog()
      {
  ....        
  m_pCamera->SetWriteCallback(this, &::onFormatChangedCallback);  
  ....  
}  
 


Remarks


The write callback function is called after one or more features that affect the image format have been changed by a client application. Typically these features are SizeX, SizeY and PixelFormat. This callback can be used to reallocate the memory required by image buffers.

If you are using the callback function in the main thread of the simulation application, make sure that no lengthy processing is done in the body of the function as otherwise the connection to the remote client may become broken.