Syntax


 PXL_RETURN_CODE PxLSetPreviewSettings (

 HANDLE hCamera,

 LPCSTR pTitle  = "PixeLINK Preview",

 U32    style   = WS_OVERLAPPEDWINDOW | WS_VISIBLE,

 U32    left    = CW_USEDEFAULT,

 U32    top     = CW_USEDEFAULT,

 U32    width   = CW_USEDEFAULT,

 U32    height  = CW_USEDEFAULT,

 HWND   hParent = NULL,

 U32    childId = 0 );

 

Description


This function defines a preview window if none is present or redefines the settings of the current preview window for the specified camera. For C++, most parameters have default values.


  • hCamera is the camera handle.  This value is returned by PxLInitialize.


  • pTitle is the title of the preview window. It will appear in the title bar (if any) of the window.


  • style is the preview window style.  See the CreateWindow function of the Windows API for more information.


  • left specifies the left coordinate of the preview window.  This value is relative to the left side of the parent window, or of the screen if there is no parent window.  


  • top specifies the top coordinate of the preview window.  This value is relative to the top of the parent window, or of the screen if there is no parent window.  


  • width is the width of the client rectangle of the preview window.  


  • height is the height of the client rectangle of the preview window. 


  • hParent is the handle to the parent window, if any.


  • childId is the ID of the child window. 


Usage


Option 1) API creates a window previews into it:


Example 1:

  

/* Use all the defaults, but change the preview window title*/

rc = PxLSetPreviewSettings(

  hCamera, 

  "Preview Demo",

  WS_OVERLAPPEDWINDOW | WS_VISIBLE,

  CW_USEDEFAULT,

  CW_USEDEFAULT, 

  CW_USEDEFAULT,

  CW_USEDEFAULT,

  NULL,

  0);

  

Example 2: 


/* Have the API create a preview window of fixed dimensions */

rc = PxLSetPreviewSettings(

  hCamera, 

  "Preview Demo", // Title

  WS_OVERLAPPEDWINDOW | WS_VISIBLE, // Window Style

  0, // Left

  0, // Top 

  250, // Width

  400, // Height

  NULL, // Parent HWND

  0); // Child Resource Id

     

These examples and more can be seen in the C/C++ demonstration application 'preview'.  

 

Option 2) API previews into an existing window:

   

Example 1   

 

// We want to have the API display the preview in the window with handle hWndParent

GetClientRect(hWndParent, &rectParent);

 

// Take up X% of the window, and centre the preview image

int width  = (int)((float)rectParent.right  * PREVIEW_PERCENTAGE_OF_WINDOW / 100.0f);

int height = (int)((float)rectParent.bottom * PREVIEW_PERCENTAGE_OF_WINDOW / 100.0f);

int left = (rectParent.right - width) / 2;

int top  = (rectParent.bottom - height) / 2;

 

rc = PxLSetPreviewSettings(

  hCamera, 

  "", // Title will not be displayed 

  WS_CHILD | WS_VISIBLE, 

  left,top,width,height,

  hWndParent, 

  0);

     

This example and more can be see in the C/C++ demonstration applications 'previewtohwnd', 'MFCPreview', 'previewoverlay', and 'autoexposure'.   

   

Comments, Restrictions and Limitations


Callbacks

   

To add a callback function to the preview so that you can modify the image or overlay it, specify the callback function with PxLSetCallback, using the callback type to CALLBACK_PREVIEW.