LInet::SendSaveCmd

#include " ltwrappr.h "

L_INT LInet::SendSaveCmd (plRemoteComp, uCommandID, pszFile, uBitmapID, nFormat, nBitsPerPixel, nQFactor, uFlags)

LInet L_FAR * plRemoteComp;

/* instance of a remote computer */

L_UINT uCommandID;

/* command id */

L_TCHAR L_FAR * pszFile;

/* file name */

L_UINT uBitmapID;

/* bitmap id */

L_INT nFormat;

/* file format */

L_INT nBitsPerPixel;

/* resulting file's pixel depth */

L_INT nQFactor;

/* quality factor */

L_UINT uFlags;

/* flags that determine the save behavior */

Sends a save command to a remote computer. This function is only available in the Internet toolkit.

Parameter

Description

plRemoteComp

Instance of the remote computer to which the command will be sent.

uCommandID

Command ID. Each command sent by a member of a connection should have a unique ID. Since a member of a connection may send several commands, this ID allows that member to identify when a specific command request has been completed.

pszFile

Character string containing the name of the image file to save.

uBitmapID

Id of the bitmap to save.

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 BitsPerPixel is 5, the file will be stored as 24 bit. Likewise, if the 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.

uFlags

Binary flags that determine the behavior of save. You can specify one of the following values listed below, or set user-defined flags.

 

Value

Meaning

 

SAVEFILE_FIXEDPALETTE

[0x0001] The function uses the fixed palette for images that are saved as 8 bits per pixel or less.

 

SAVEFILE_OPTIMIZEDPALETTE

[0x0002] The function uses the individual image's optimized palette for images that are saved as 8 bits per pixel or less. The optimized palette must be included in the bitmap handle.

 

SAVEFILE_MULTIPAGE

[0x0004] The function saves the image in a multi-page file. It appends the image as the last one in the file. You can save multi-page images in PCX, GIF, and most TIFF file formats (including JTIF, but excluding EXIF).

Returns

SUCCESS

This function was successful.

< 1

An occurred. Refer to Return Codes.

Comments

The remote computer should respond by calling LInet::SendLoadRspin its LInet::CommandCallBackfunction.

With this command, the local computer will signal the remote computer to save a bitmap.

To process responses to commands, a class must be derived from LInet and the LInet::ResponseCallBackmember function must be overridden.

The LInet::CommandCallBackfunction will receive the pszFile, uBitmapID, nFormat, nBitsPerPixel, nQFactor and uFlags information in the pParams parameter. The pszFile information will be in pParams[0]. The uBitmapID information will be in pParams[1], the nFormat information will be in pParams[2], and so forth.

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

Functions:

LInet::SendSaveRsp, LInet::ResponseCallBack, LInet::CommandCallBack, Class Members

Topics:

Sending Commands and Responses

 

A Client Server Diagram: Sending Commands and Responses

Example

//This example sends a message to a remote connection save a loaded bitmap locally
//It is assumed that:
//1.  m_Inet and m_pInetRemoteServer are an object of the class LInet
//2.  the network as been started (LInet::StartUp()) 
//3.  a connection has been established with a remote server (LInet::m_Inet.Connect())
//4.  GetNextCommandID() is a function that returns a unique command identifier
//5.  UpdateStatusbar() is a function that displays a message in the status bar
//6.  m_uBitmapID is a bitmap id that is received in the LInet::ResponseCallBack() as a result
//    of a call to m_Inet.SendLoadCmd()
void CMainFrame::OnRemoteSavebitmap () 
{
   L_INT nRet;
   nRet = m_Inet.SendSaveCmd(
      m_pInetRemoteServer, 
      GetNextCommandID(), 
      TEXT("c:\\temp\\remote.tif"), 
      m_uBitmapID, 
      FILE_TIF);
   
   if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED)
      UpdateStatusbar(TEXT("Error[%d]: OnRemoteSavebitmap"), nRet);
}

//The CommandCallBack() is processed on the server
//To process the commands sent to the computer, you must:
//1. Derive a class from LInet
//2. Override the CommandCallBack member function
//
//Assume that 
//1. m_Inet is an object of the class CMyNet (derived from LInet).
//2. the network as been started (LInet::StartUp()) 
//3. a connection has been established with a remote client
//4. UpdateStatusbar() displays a message in the status bar
//5. m_BitmapList maintains a list of LBitmapWindow objects
L_INT CMyNet::CommandCallBack (LInet L_FAR * plConnection,
                              CMDTYPE     uCommand,
                              L_UINT      uCommandID,
                              L_INT       nError,
                              L_UINT      uParams, 
                              pPARAMETER  pParams, 
                              L_UINT      uExtra,
                              L_CHAR L_FAR*pExtra)
{
   L_INT nStatus = ERROR_FEATURE_NOT_SUPPORTED; 
   L_UINT          uBitmapID = (L_UINT)-1; 
   
   CMainFrame *pMain; 
   pMain = GETMAINFRAME; 
   
   if(nError != SUCCESS) 
      nStatus = ERROR_TRANSFER_ABORTED; 
   else
      switch(uCommand) 
      {
      case CMD_SAVE: 
      {
            uBitmapID = pParams[1].uiValue; 
            
            //Here you would look up the uBitmapID in a list 
            //of BitmapWindow objects maintained on the server.  
            //If the ID is valid, save as a local file on the 
            //server (pParams[0]) 
            
            //Something like this... 
            /*
            LBitmapWindow *pBitmapWindow = m_BitmapList[uBitmapID]; 
            
            //pParams[0] file name
            //pParams[1] bitmap id
            //pParams[2] nFormat
            //pParams[3] nBitsPerPixel
            //pparams[4] nQFactor
            //pParams[5] uFlags
              
            if (pBitmapWindow != NULL) 
            {   
                   L_INT nRet; 
                   nRet = pBitmapWindow->Save(
                   pParams[0].pValue, 
                   pParams[2].iValue, 
                   pParams[3].iValue, 
                   pParams[4].iValue, 
                   pParams[5].iValue
                   ); 
                  if (nRet != SUCCESS) 
                       nStatus = FAILURE; 
            }
            */
         }
         return pMain->m_Inet.SendSaveRsp(
                   plConnection, 
                   uCommandID, 
                   0, 
                  NULL, 
                  nStatus); 
         break; 
         
      default: 
         {
            return nStatus; 
         }
   }
   return nStatus; 
}