L_GetMarker

#include "l_bitmap.h"

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

L_VOID* hMarkers;

/* marker handle */

L_UINT uIndex;

/* marker index */

L_UINT* puMarker;

/* marker type */

L_UINT* puMarkerSize;

/* marker size */

L_UCHAR* pMarkerData;

/* marker data */

Gets the specified marker in the collection.

Parameter

Description

hMarkers

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

uIndex

Index of the marker to retrieve.

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.

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.

pMarkerData

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

Returns

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:

image\sqrblit.gif Call it the first time with pMarkerData set to NULL, to find out the size of the marker.

image\sqrblit.gif Call it the second time with the pMarkerData set to the buffer you have allocated.

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

LTFIL

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 2000 / XP/Vista.

See Also

Functions:

L_LoadMarkers, L_CreateMarkers, L_InsertMarker, L_EnumMarkers, L_GetMarkerCount

Topics:

Raster Image Functions: Markers

 

Working with Markers

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;
}