L_GetMarker

#include "l_bitmap.h"

L_LTFIL_API L_INT L_GetMarker(hMarkers, uIndex, puMarker, puMarkerSize, pMarkerData)

Gets the specified marker in the collection.

Parameters

L_VOID* hMarkers

Handle to a collection of metadata markers. This handle is created by either the L_LoadMarkers function or the L_CreateMarkers function.

L_UINT uIndex

Index of the marker to retrieve.

L_UINT* puMarker

Pointer to a variable to be updated with a value that represents the type (ID) of marker to get. Recommended values are between 0xE0 and 0xFE. Other values are possible, but before using other values, study the JPEG specs to determine which markers are allowed.

L_UINT* puMarkerSize

Pointer to a variable to be updated with the marker size if pMarkerData is not NULL. The variable should be filled, by the user, with the size of the pMarkerData buffer.

L_UCHAR* pMarkerData

Pointer to a buffer to be updated with the marker data.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This function lets you get access to each individual marker without the use of a callback function.

This function is not as efficient as L_EnumMarkers because the data for each marker is copied to your buffer.

To get the size of the specified marker, call this function with pMarkerData set to NULL. puMarkerSize will be filled with the size of the marker data.

If pMarkerData is not NULL, then puMarkerSize should be filled with the size of pMarkerData. If the size is not large enough to hold the marker, the function will fail and return ERROR_BUFFER_TOO_SMALL.

If uIndex is larger than the number of markers present in hMarkers, the function will fail and return ERROR_MARKER_INDEX.

Typically, you would call this function twice:

You can also allocate a buffer of 0xFFFD bytes and use it to hold any marker. You can do this because the size of a marker is limited to 0xFFFD (65533) bytes.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example will get all the markers using a static buffer

  
L_INT GetMarkerExample(HANDLE hMarkers,HWND hWnd, 
                                       L_UCHAR MarkerBuf[]/* static buffer large enough to contain any marker*/ ) 
{ 
   L_UINT uCount; // number of markers present in hMarkers 
   L_UINT uIndex; // index of the marker I am retrieving 
   L_UINT uMarker; // marker ID (0x01 .. 0xFE) 
   L_UINT uMarkerSize; // size of marker (0 .. 0xFFFD) 
   L_INT nRet; // return code 
   L_TCHAR buf[256]; // buffer used for messages 
 
   nRet = L_GetMarkerCount(hMarkers, &uCount); 
   if(nRet == SUCCESS) 
   { 
      for(uIndex = 0; uIndex < uCount; uIndex++) 
      { 
         // Since I pass MarkerBuf, fill uMarkerSize with the buffer size 
         uMarkerSize = 0xFFFD; 
         nRet = L_GetMarker(hMarkers, uIndex, &uMarker, &uMarkerSize, MarkerBuf); 
         if(nRet != SUCCESS) 
         { 
            _itot_s(nRet, buf, 10); 
 
            MessageBox(hWnd, buf, TEXT("Error calling L_GetMarker"), MB_OK); 
            return nRet; 
         } 
         // the function succeeded 
         // display the results. Note that the some of  
         // the marker data displayed is meaningless if uMarkerSize is < 4 
         wsprintf(buf, TEXT("Marker %d: 0x%02X, size=%d, buf = %02X,%02X,%02X,%02X"), uIndex, uMarker, uMarkerSize, MarkerBuf[0], MarkerBuf[1], MarkerBuf[2], MarkerBuf[3]); 
         MessageBox(hWnd, buf, TEXT("SUCCESS"), MB_OK); 
      } 
      MessageBox(hWnd, TEXT("Done"), TEXT("SUCCESS"), MB_OK); 
   } 
   return SUCCESS; 
} 

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help