L_InetSendBitmap
#include "l_bitmap.h"
#include "ltnet.h"
L_INT EXT_FUNCTION L_InetSendBitmap(hComputer, pBitmap, nFormat, nBitsPerPixel, nQFactor, pulImageLength)
L_COMP hComputer; |
/* handle of remote computer */ |
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
L_INT nFormat; |
/* output file format */ |
L_INT nBitsPerPixel; |
/* resulting file's pixel depth */ |
L_INT nQFactor; |
/* quality factor */ |
/* address of variable to update */ |
Saves a LEADTOOLS bitmap to a file in memory, and then sends the resulting memory file to a remote computer.
Parameter |
Description |
hComputer |
Handle of remote computer to which bitmap data is to be sent. |
pBitmap |
Pointer to the bitmap handle referencing the bitmap to send. |
nFormat |
Value indicating the output file format of the file to send. For valid values, refer to Formats of Output Files. |
nBitsPerPixel |
Value indicating the resulting file's pixel depth. Note that not all bits per pixel are available to all file formats. For valid values, refer to Formats of Output Files If nBitsPerPixel is 0, the file will be stored using the closet BitsPerPixel value supported by that format. For example, if a file format supports 1, 4, and 24 BitsPerPixel, and the pBitmap->BitsPerPixel is 5, the file will be stored as 24 bit. Likewise, if the pBitmap->BitsPerPixel is 2, the file will be stored as 4 bit. |
nQFactor |
This parameter is used when saving an image file to FILE_CMP, FILE_JFIF, FILE_LEAD1JFIF, FILE_LEAD2JFIF, FILE_JTIF, FILE_LEAD1JTIF, FILE_LEAD2JTIF, FILE_FPX_JPEG_QFACTOR, and FILE_EXIF_JPEG. Qfactor is a number that determines the degree of loss in the compression process. For possible values, refer to Compression Quality Factors. |
pulImageLength |
Address of the variable to be updated with the size of the output image file. Pass NULL if you are not interested in the resulting file's size in memory. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
The image in pBitmap is saved into a memory file in the format specified by nFormat. Then, the data is sent to the remote computer. LEADTOOLS headers are added to the beginning of the data before it is sent.
If the remote computer has enabled auto process by calling L_InetAutoProcess, then the bitmap will be automatically loaded at the other end and the remote computer's INETCALLBACK function will be called with the INET_IMAGE_RECEIVED message. If auto process is disabled by the remote computer, then the LEADTOOLS headers must be stripped by the receiver. The remote computer can then call L_LoadMemory to load the image, or the data can be saved directly into a file. In this case, the format of the file would be the value of nFormat.
If pulImageLength is not NULL, then the size of the resulting file in memory after it was saved is returned in pulImageLength.
Note that in most cases, the data will not be completely sent by the time this function returns. Only when the INETCALLBACK function is called with INET_DATA _SENT can you be assured that all of the data has been sent to the remote computer.
You must initialize the LEADTOOLS Internet DLL using L_InetStartUp before calling this function.
Required DLLs and Libraries
LTNET For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
See Also
Example
L_COMP hComp; /* handle of the remote computer */
L_INT nRet;
L_INT L_EXPORT EXT_CALLBACK InetCallback(L_COMP hComp,
L_INT nMessage, L_INT nError, L_CHAR L_FAR *pBuffer,
L_UINT32 lSize,L_VOID L_FAR*pUserData);
/* note: instead of server_address you need to put the IP
address
of the computer running the server. You can also put in
the computer name, if the server is running on a local network */
/* you do not need to use MakeProcInstance for 32 bit applications */
nRet = L_InetConnect("server_address",
1000, &hComp, InetCallback, NULL);
if(nRet != SUCCESS)
MessageBox(NULL, TEXT("Error attempting to connect"),
TEXT("ERROR"), MB_OK);
L_INT L_EXPORT EXT_CALLBACK InetCallback(L_COMP hComp,
L_INT nMessage, L_INT nError, L_CHAR L_FAR *pBuffer,
L_UINT32 lSize,L_VOID L_FAR*pUserData)
{
L_INT nRet;
BITMAPHANDLE Bitmap;
switch(nMessage)
{
case INET_CONNECT:
/* check the status
and send some data */
if(nError == SUCCESS)
{
/*
replace "image1.cmp" with the full path of the image */
nRet
= L_LoadBitmap(TEXT("image1.cmp"),
&Bitmap, sizeof(Bitmap), 0, ORDER_BGR, NULL, NULL);
if(nRet
!= SUCCESS)
MessageBox(NULL,
TEXT("Error loading image!"), TEXT("Error"), MB_OK);
else
{
/*
now you can assume you are connected to computer 'hComp' */
nRet
= L_InetSendBitmap(hComp, &Bitmap,
FILE_CMP, 24, 2, NULL);
if(nRet
!= SUCCESS)
MessageBox(NULL,
TEXT("Error sending bitmap"), TEXT("Error"), MB_OK);
/*
we don't need the bitmap anymore */
L_FreeBitmap(&Bitmap);
}
/*
remove the next line to keep the connection open */
L_InetClose(hComp,
TRUE);
}
else
MessageBox(NULL,
TEXT("You have failed to connect!"), TEXT("Error"),
MB_OK);
break;
}
return SUCCESS;
}