Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
LInet::SendBitmap
#include "ltwrappr.h"
L_INT LInet::SendBitmap(plRemoteComp, phBitmap, nFormat, nBitsPerPixel, nQFactor, pulImageLength)
LInet *plRemoteComp; |
/* instance of a remote computer */ |
pBITMAPHANDLE phBitmap; |
/* pointer to the bitmap handle */ |
L_INT nFormat; |
/* output file format */ |
L_INT nBitsPerPixel; |
/* resulting file's pixel depth */ |
L_INT nQFactor; |
/* quality factor */ |
L_SIZE_T *pulImageLength; |
/* 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 |
plRemoteComp |
Instance of the remote computer to which bitmap data is to be sent. |
phBitmap |
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 LInet::EnableAutoProcess, then the bitmap will be automatically loaded at the other end and the remote computer's LInet::OnImageReceived function will be called. 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 LMemoryFile::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 LInet::OnDataSent function is called can you be assured that all of the data has been sent to the remote computer.
You must initialize the LEADTOOLS Peer-to-Peer DLL using LInet::StartUp 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
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName // The user should derive a class from LInet to support the OnConnect callback function. // Suppose it was named as LUserInetSB class LUserInetSB : public LInet { protected: virtual L_INT OnConnect(LInet *plConnection, L_INT nError); }; L_INT LInet__SendBitmapExample() { L_INT nRet; LUserInetSB UserInet; nRet = UserInet.StartUp(); if(nRet != SUCCESS) return nRet; // connect to LEAD. nRet = UserInet.Connect("207.238.49.190", 1000); if(nRet != SUCCESS) return nRet; // other operations nRet = UserInet.ShutDown(); if(nRet != SUCCESS) return nRet; return SUCCESS; } L_INT LUserInetSB::OnConnect(LInet *plConnection, L_INT nError) { L_INT nRet = SUCCESS; LBitmapBase Bitmap; if (nError != SUCCESS) return nError; nRet = Bitmap.Load(MAKE_IMAGE_PATH(TEXT("image1.cmp")), 0, ORDER_BGR); if(nRet != SUCCESS) { LBase::DisplayError(NULL, TEXT("Error loading image!")); return nRet; } // now you can assume you are connected to remote computer nRet = SendBitmap(plConnection, Bitmap.GetHandle(), FILE_CMP, 24, 2, NULL); if (nRet != SUCCESS) LBase::DisplayError(NULL, TEXT("Error sending bitmap")); // other operations // close connection Close(plConnection); return nRet; }