L_InetHttpSendBitmap
#include "ltweb.h"
L_INT EXT_FUNCTION L_InetHttpSendBitmap(hHttp, pBitmap, nFormat, nBitsPerPixel, nQFactor, pszContentType, pNameValue, pSaveOptions)
HINET hHttp; |
/* handle to an HTTP connection*/ |
pBITMAPHANDLE pBitmap; |
/* pointer to a bitmap handle */ |
L_INT nFormat; |
/* output file format*/ |
L_INT nBitsPerPixel; |
/* output bits per pixel*/ |
L_INT nQFactor; |
/* quality factor*/ |
/* HTTP content type*/ | |
pNAMEVALUE pNameValue; |
/* pointer to a structure */ |
pSAVEFILEOPTION pSaveOptions; |
/* pointer to extended save options*/ |
Sends a bitmap to an HTTP server.
Parameter |
Description |
hHttp |
Handle to an HTTP connection. It is the same handle obtained using the L_InetHttpConnect function. |
pBitmap |
Pointer to the bitmap handle referencing the bitmap to send. The bitmap handle can contain the actual data, but does not have to, since your callback function can supply the data. However, the bitmap handle must contain values for the following fields: Width, Height, BitsPerPixel, BytesPerLine, nColors, ViewPerspective, Order, and DitheringMethod. (The BytesPerLine value must be a multiple of four.) |
nFormat |
Output file format. For valid values, refer to Formats of Output Files. |
nBitsPerPixel |
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. |
pszContentType |
A string describing the content type. This string is usually formatted type/subtype where type is the general content category and subtype is the specific content type. For a full list of supported content types, see your Internet browser documentation or the current HTTP specification. |
pNameValue |
A pointer to the structure that contains the name/value pair for this image. This information is used to get the information from a script on the server machine. This name is usually some user-defined name and the value is the filename of the image. |
pSaveOptions |
Pointer to optional extended save options. Pass NULL to use the default save options. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
It is up to a script on the server side to process the data when it is received. This script is specified in the L_InetHttpOpenRequest function. The script can be any type of file that is recognized by the HTTP Server.
This function actually saves a LEADTOOLS bitmap to a file in memory, and then sends the resulting memory file to an HTTP Internet server.
Note: The LEADTOOLS Uploading component can be used in an ASP page to extract the uploaded data.
Required DLLs and Libraries
LTWEB 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
Functions: |
L_InetHttpSendData, L_InetHttpSendForm, L_InetHttpSendRequest |
Topics: |
|
|
Example
void TestSendBitmap(pBITMAPHANDLE pBitmap)
{
HINET hInet;
L_INT nRet;
nRet = L_InetHttpConnect(TEXT("www.leadtools.com"),80,TEXT(""),TEXT(""),&hInet);
if(nRet==SUCCESS)
{
nRet = L_InetHttpOpenRequest(hInet,HTTP_GET,TEXT("/upload.asp"),TEXT(""),
TEXT("HTTP/1.0"),0);
if(nRet==SUCCESS)
{
L_TCHAR szResponse[2048];
L_UINT32 lsize;
L_UINT uStatus;
FILE *fp;
NAMEVALUE nv;
nv.pszName = TEXT("Photo");
nv.pszValue = TEXT("photo1.jpg");
nRet=L_InetHttpSendBitmap(hInet,pBitmap,FILE_JFIF,24,200,
TEXT("image/jpg"),&nv,NULL);
if(nRet!=SUCCESS)
{
MessageBox(NULL,
TEXT("Error Sending Form"), TEXT("Error"),MB_ICONEXCLAMATION);
L_InetHttpCloseRequest(hInet);
L_InetHttpDisconnect(hInet);
return;
}
L_InetHttpGetServerStatus(hInet,&uStatus);
if(uStatus==L_HTTP_STATUS_OK)
{
lsize
= 2048;
L_InetHttpGetResponse(hInet,szResponse,&lsize);
#ifdef
UNICODE
fp
= _wfopen(TEXT("output.htm"), TEXT("wb"));
#else
fp
= fopen("output.htm","wb");
#endif
while(lsize!=0)
{
fwrite(szResponse,lsize,1,fp);
lsize
= 1048;
L_InetHttpGetResponse
(hInet,szResponse,&lsize);
}
fclose(fp);
}
else
{
MessageBox(NULL,
TEXT("Problem With Server"), TEXT("Error"),MB_ICONEXCLAMATION);
lsize
= 2048;
L_InetHttpGetResponse
(hInet,szResponse,&lsize);
#ifdef
UNICODE
fp
= _wfopen(TEXT("error.htm"), TEXT("wb"));
#else
fp
= fopen("error.htm","wb");
#endif
while(lsize!=0)
{
fwrite(szResponse,lsize,1,fp);
lsize
= 1048;
L_InetHttpGetResponse(hInet,szResponse,&lsize);
}
fclose(fp);
}
L_InetHttpCloseRequest(hInet);
}
L_InetHttpDisconnect(hInet);
}
}
/*The following upload.asp page can be used to get access to the upload file. Upload.asp also makes use of the LEAD Upload control.*/
<%
Set Upload = Server.CreateObject("LEAD.Upload")
Lead.EnableMethodErrors = false
set files = Upload.Upload
Upload.Save "c:\inetpub\wwwroot\"
' Process all files received
For Each File in Files
Response.Write File.Name & "
= " & File.FileName & "<BR>"
Response.Write "Size = "
& File.Size & "<BR>"
Response.Write "<BR><BR>"
Next
%>