Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_InetHttpSendBitmap
#include "ltweb.h"
L_LTWEB_API L_INT 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*/ |
L_TCHAR *pszContentType; |
/* 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
L_INT InetHttpSendBitmapExample(pBITMAPHANDLE pBitmap) { HINET hInet; L_INT nRet; DWORD dwSizeWrite; 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; L_HANDLE 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); nRet = L_InetHttpCloseRequest(hInet); if(nRet != SUCCESS) return nRet; nRet = L_InetHttpDisconnect(hInet); if(nRet != SUCCESS) return nRet; return nRet; } nRet = L_InetHttpGetServerStatus(hInet,&uStatus); if(nRet != SUCCESS) return nRet; if(uStatus==L_HTTP_STATUS_OK) { lsize = 2048; nRet = L_InetHttpGetResponse(hInet,(L_CHAR *)szResponse,&lsize); if(nRet != SUCCESS) return nRet; fp =CreateFile(TEXT("output.htm"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); while(lsize!=0) { WriteFile(fp,szResponse, lsize, &dwSizeWrite, NULL); lsize = 1048; nRet = L_InetHttpGetResponse (hInet,(L_CHAR *)szResponse,&lsize); if(nRet != SUCCESS) return nRet; } CloseHandle(fp); } else { MessageBox(NULL, TEXT("Problem With Server"), TEXT("Error"),MB_ICONEXCLAMATION); lsize = 2048; nRet = L_InetHttpGetResponse (hInet,(L_CHAR *)szResponse,&lsize); if(nRet != SUCCESS) return nRet; fp =CreateFile(TEXT("error.htm"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); while(lsize!=0) { WriteFile(fp,szResponse, lsize, &dwSizeWrite, NULL); lsize = 1048; nRet = L_InetHttpGetResponse(hInet,(L_CHAR *)szResponse,&lsize); if(nRet != SUCCESS) return nRet; } CloseHandle(fp); } nRet = L_InetHttpCloseRequest(hInet); if(nRet != SUCCESS) return nRet; } else return nRet; nRet = L_InetHttpDisconnect(hInet); if(nRet != SUCCESS) return nRet; } else return nRet; return SUCCESS; } /*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 %>*/