LBitmapBase::GetRowColCompressed

#include "ltwrappr.h"

virtual L_SSIZE_T LBitmapBase::GetRowColCompressed(pLRunBuffer, nRow, nCol, uWidth, pWorkBuffer=NULL)

LBuffer * pLRunBuffer;

/* pointer to an LBuffer object */

L_INT nRow;

/* number of the row to retrieve */

L_INT nCol;

/* column offset within the row to retrieve */

L_UINT32 uWidth;

/* number of pixels to retrieve */

LBuffer * pWorkBuffer;

/* pointer to an optional work buffer */

Retrieves a row (or part of a row) of 1-bit compressed data from a class objects bitmap.

Parameter

Description

pLRunBuffer

Pointer to an LBuffer object that will receive the retrieved data. Calculate the required size of this buffer as follows: bytes required = (nWidth + 3) * 2.

nRow

The number of the row to retrieve. The first row is 0 and the last row is 1 less than the bitmap height.

nCol

The number of column from which to get the data. The first column offset is 0, and the last column offset is 1 less than the bitmap width.

uWidth

The number of pixels to retrieve.

pWorkBuffer

A pointer to an optional work buffer. You can also pass NULL. Allocating the work buffer speeds processing if you call this function more than once, because if you do not allocate a work buffer, the function allocates and frees a temporary buffer each time it is called. The size of this buffer should be the same as the value returned by LBitmapBase::GetBytesPerLine

Returns

> 0

The number of pixels processed.

< 1

An error occurred. Refer to Return Codes.

Comments

Retrieves a row (or part of a row) of 1-bit compressed data from a class objects bitmap that has been loaded in its compressed format.

This function is useful for working with 1-bit images that are loaded in their compressed formats for faster loading and display. For more information, refer to Speeding Up 1-Bit Documents.

Required DLLs and Libraries

LTDIS
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

Win32, x64.

See Also

Functions:

LBitmapBase::PutRow, LBitmapBase::PutRowCol, LBitmapBase::PutRowCompressed, LBitmapBase::GetRow, LBitmapBase::PutRowColCompressed, LBitmapBase::GetRowCol, LBitmapBase::GetRowCompressed, Class Members

Topics:

Speeding Up 1-Bit Documents

Example

This example demonstrates the low-level functions for accessing

1-bit compressed bitmap data. It demonstrates the ability to get and put

partial rows, and the ability to process partial rows in buffer-to-buffer

processing.

L_INT LBitmapBase__GetRowColCompressedExample(L_TCHAR  * pszFilename, HWND hWnd,
                                                               LBitmapBase LeadBitmap/* Bitmap handle for the image */)
{
   UNREFERENCED_PARAMETER(hWnd);
   L_INT nRet;
   L_INT XOffset; /* Column offset of the rectangle to process */
   L_INT XSize; /* Pixel width of the rectangle to process */
   L_INT YOffset; /* Row offset of the rectangle to process */
   L_INT YSize; /* Pixel height of the rectangle to process */
   LBuffer RunBuffer; /* Handle to the pRunBuffer */
   LBuffer WorkBuffer; /* Handle to the pWorkBuffer */
   L_INT i; /* Counters */
   
   /* Load the bitmap, at 1 bit per pixel */
   LeadBitmap.File()->SetFileName(pszFilename);
   nRet =LeadBitmap.File()->LoadFile(1,0,LOADFILE_COMPRESSED | LOADFILE_ALLOCATE | LOADFILE_STORE);
   if(nRet !=SUCCESS)
      return nRet;
   /* This example does not work with rotated view perspectives */
   if ( (LeadBitmap.GetViewPerspective() != TOP_LEFT) || (LeadBitmap.GetViewPerspective() != BOTTOM_LEFT) )
   {
      nRet =LeadBitmap.ChangeViewPerspective ( TOP_LEFT );
      if(nRet !=SUCCESS)
         return nRet;
   }
   /* Specify a rectangle in the middle right part of the displayed image */
   XOffset = LeadBitmap.GetWidth() / 3;
   XSize = LeadBitmap.GetWidth() * 2 / 3;
   YOffset = LeadBitmap.GetHeight() / 3;
   YSize = LeadBitmap.GetHeight() / 3;
   /* Adjust the YOffset if the view perspective is bottom left */
   if (LeadBitmap.GetViewPerspective() == BOTTOM_LEFT)
   {
      YOffset = LeadBitmap.GetHeight() - YOffset - YSize;
   }
   /* Allocate the buffers */
   nRet =RunBuffer.Reallocate( (XSize + 3) * 2);
   if(nRet !=SUCCESS)
      return nRet;
   nRet =WorkBuffer.Reallocate(LeadBitmap.GetBytesPerLine());
   if(nRet !=SUCCESS)
      return nRet;
   nRet =LeadBitmap.Access();
   if(nRet !=SUCCESS)
      return nRet;
   for(i=YOffset; i < (YOffset + YSize); i++)
   {
      nRet =(L_INT)LeadBitmap.GetRowColCompressed(&RunBuffer, i, XOffset, XSize, &WorkBuffer);
      if(nRet !=SUCCESS)
         return nRet;
      nRet =(L_INT)LeadBitmap.PutRowColCompressed(RunBuffer, i, XOffset, XSize/ 2,&WorkBuffer);
      if(nRet !=SUCCESS)
         return nRet;
   }
   nRet =LeadBitmap.Release();
   if(nRet !=SUCCESS)
      return nRet;
   return SUCCESS;
}