|
Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_PrintBitmapGDIPlus
#include "l_bitmap.h"
L_LTDIS_API L_INT L_PrintBitmapGDIPlus(hDC, pBitmap, nX, nY, nWidth, nHeight, uFlags)
|
L_HDC hDC; |
/* handle to the target device context (DC) */ |
|
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
|
L_INT nX; |
/* x position to start the print */ |
|
L_INT nY; |
/* y position to start the print*/ |
|
L_INT nWidth; |
/* printed width */ |
|
L_INT nHeight; |
/* printed height */ |
|
L_UINT32 uFlags; |
/* flags, reserved */ |
Prints the bitmap to the specified device context using GDI+.
|
Parameter |
Description |
|
hDC |
Handle to the device context (DC) where the bitmap is to print. The mapping mode of the device context must be MM_TEXT. |
|
pBitmap |
Pointer to the bitmap handle referencing the bitmap to print. |
|
nX |
Value that represents the X position to start the print. |
|
nY |
Value that represents the Y position to start the print. |
|
nWidth |
Value that represents the printed width, in pixels. The actual width depends on the dots per inch (DPI) of the printer. |
|
nHeight |
Value that represents the printed height, in pixels. The actual height depends on the dots per inch (DPI) of the printer. |
|
uFlags |
Reserved for future use. Pass 0. |
Returns
|
SUCCESS |
The function was successful. |
|
< 1 |
An error occurred. Refer to Return Codes. |
Comments
If GDI+ library is not installed to the system, an error code is returned.
Required DLLs and Libraries
|
LTDIS 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 98 / 98 / Me, Windows 2000 / XP, Windows CE.
See Also
|
Functions: |
|
|
Topics: |
|
|
|
|
|
|
Example
//This example determines the output size to fit the image on //half of a page, and prints the bitmap twice on the same page
L_INT PrintBitmapGDIPlusExample(L_VOID)
{
BITMAPHANDLE LeadBitmap; /* Bitmap handle for the image */
HDC PrinterDC; /* DC for the printer */
L_INT WidthAllowed, HeightAllowed, WidthFactor, HeightFactor; /* For size calculations */
L_INT PrintWidth, PrintHeight; /* Width and height of the printed image */
L_INT nRet;
/* Load a bitmap at its own bits per pixel */
nRet =L_LoadBitmap (TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\GIRL.TGA"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet !=SUCCESS)
return nRet;
/* Get the printer DC */
PrinterDC = L_PrintBitmapFast(NULL, NULL, 0, 0, 0, 0, FALSE);
/* Initialize variables for fitting the image on half a page */
WidthAllowed = GetDeviceCaps(PrinterDC,HORZRES);
HeightAllowed = GetDeviceCaps(PrinterDC,VERTRES) * 4/10;
HeightFactor = BITMAPHEIGHT(&LeadBitmap);
WidthFactor = BITMAPWIDTH(&LeadBitmap);
/* See if using the maximum width will make the image too tall */
if((L_INT) (((L_INT32) WidthAllowed * HeightFactor) / WidthFactor) < HeightAllowed)
{ /* Use the maximum width, and calculate the height value */
PrintWidth = WidthAllowed;
PrintHeight = (L_INT) (((L_INT32) PrintWidth * HeightFactor) / WidthFactor);
}
else
{ /* Use the maximum height, and calculate the width value */
PrintHeight = HeightAllowed;
PrintWidth = (L_INT) (((L_INT32) PrintHeight * WidthFactor) / HeightFactor);
}
/* Print the first image */
nRet =L_PrintBitmapGDIPlus(PrinterDC, &LeadBitmap, 1, 1, PrintWidth, PrintHeight, 0);
if(nRet !=SUCCESS)
return nRet;
/* Print the second image */
nRet =L_PrintBitmapGDIPlus(PrinterDC, &LeadBitmap, 1, HeightAllowed * 6/5, PrintWidth, PrintHeight, 0);
if(nRet !=SUCCESS)
return nRet;
EndPage(PrinterDC);
EndDoc( PrinterDC);
L_FreeBitmap( &LeadBitmap );
DeleteDC(PrinterDC);
return SUCCESS;
}