L_PutBitmapRowColCompressed

#include "l_bitmap.h"

L_INT32 EXT_FUNCTION L_PutBitmapRowColCompressed(pBitmap, pWorkBuffer, pRunBuffer, nRow, nCol, uWidth)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_UCHAR L_FAR * pWorkBuffer;

/* pointer to a work buffer */

L_UINT16 L_FAR * pRunBuffer;

/* pointer to the source buffer */

L_INT nRow;

/* number of the row to update */

L_INT nCol;

/* column offset within the row to update */

L_UINT32 uWidth;

/* number of pixels to update */

Puts a row (or part of a row) of 1-bit compressed data from a buffer to a bitmap that is maintained in its compressed format. This function is available in the Document/Medical Toolkits.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap to be updated.

pWorkBuffer

NULL or a pointer to an optional work buffer. 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 bitmap handle's BytesPerLine field.

pRunBuffer

Pointer to the input buffer, which contains 1-bit compressed image data.

nRow

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

nCol

The column offset within the row to update. 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.

Returns

> 0

The number of pixels processed.

< 1

An error occurred. Refer to Return Codes.

Comments

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

LTKRN

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 95 / 98 / Me, Windows 2000 / XP, Windows CE.

See Also

Functions:

L_ExpandRow, L_CompressRow, L_GetBitmapRowColCompressed, L_GetBitmapRowCompressed, L_PutBitmapRowCompressed

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. The result of the function is an inverted rectangle in the 
middle of the image. */

BITMAPHANDLE LeadBitmap;   /* Bitmap handle for the image */
void TestLoad(L_TCHAR L_FAR * pszFilename, HWND hWnd)
{
   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 */
   L_UCHAR L_HUGE * pBuffer; /* Buffer to hold the expanded row */
   L_UINT16 L_HUGE * pRunBuffer; /* Buffer to hold the compressed row */
   L_UCHAR L_HUGE * pWorkBuffer; /* Work buffer */
   HGLOBAL hBuffer; /* Handle to the pBuffer */
   HGLOBAL hRunBuffer; /* Handle to the pRunBuffer */
   HGLOBAL hWorkBuffer; /* Handle to the pWorkBuffer */
   int i, n; /* Counters */
   /* Load the bitmap, at 1 bit per pixel */
   L_LoadFile( pszFilename,&LeadBitmap, sizeof(BITMAPHANDLE),1,0,
               LOADFILE_COMPRESSED | LOADFILE_ALLOCATE | LOADFILE_STORE,
               NULL, NULL, NULL, NULL);
   /* This example does not work with rotated view perspectives */
   if ( (LeadBitmap.ViewPerspective != TOP_LEFT) || (LeadBitmap.ViewPerspective != BOTTOM_LEFT) )
   L_ChangeBitmapViewPerspective ( NULL, &LeadBitmap, sizeof(BITMAPHANDLE), TOP_LEFT );
   /* Specify a rectangle in the middle right part of the displayed image */
   XOffset = LeadBitmap.Width / 3;
   XSize = LeadBitmap.Width * 2 / 3;
   YOffset = LeadBitmap.Height / 3;
   YSize = LeadBitmap.Height / 3;
   /* Adjust the YOffset if the view perspective is bottom left */
   if (LeadBitmap.ViewPerspective == BOTTOM_LEFT)
   {
      YOffset = LeadBitmap.Height - YOffset - YSize;
   }
   /* Allocate the buffers */
   hBuffer = GlobalAlloc(GMEM_MOVEABLE, ( XSize + 7) / 8);
   pBuffer = (L_UCHAR L_FAR *)GlobalLock( hBuffer );
   hRunBuffer = GlobalAlloc(GMEM_MOVEABLE, (XSize + 3) * 2);
   pRunBuffer = (L_UINT16 L_HUGE *)GlobalLock( hRunBuffer );
   hWorkBuffer = GlobalAlloc(GMEM_MOVEABLE, LeadBitmap.BytesPerLine);
   pWorkBuffer = (L_UCHAR L_HUGE * )GlobalLock( hWorkBuffer );
   /* Invert the colors of pixels in the left half of the rectangle. */
   /* Notice that we get the whole rectangle, but process only half of it. */
   L_AccessBitmap(&LeadBitmap);
   for(i=YOffset; i < (YOffset + YSize); i++)
   {
      L_GetBitmapRowColCompressed(&LeadBitmap, pWorkBuffer,
      pRunBuffer, i, XOffset, XSize);
      L_ExpandRow(pRunBuffer, pBuffer, 0, XSize/2);
      for(n=0; n < (XSize /16); n++)
         pBuffer[n] = pBuffer[n] ^ 0xFF;
      L_CompressRow(pRunBuffer, pBuffer, 0, XSize/2);
      L_PutBitmapRowColCompressed(&LeadBitmap, pWorkBuffer, pRunBuffer, i, 
         XOffset, XSize/ 2);
   }
   L_ReleaseBitmap(&LeadBitmap);
   /* Free memory that we no longer need */
   GlobalFree(hBuffer);
   GlobalFree(hRunBuffer);
   GlobalFree(hWorkBuffer);
   /* Update the paint palette to force a repaint */
   SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L);
}