FeedLoad example for C++ 5.0 and later

This example uses StartFeedLoad, FeedLoad, and StopFeedLoad and loads a file through a buffer to simulate receiving a transmitted image. 

#define BUFFERSIZE 1000
void CTutorDlg::OnFeedload()
{   
   LPSTR       lp;   /* pointer to the data */

   ILEADRasterIO *pRasterIO=NULL; 
   ILEADRasterVariant * pltRasVar = NULL; 

   CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, 
                                   IID_ILEADRasterVariant, (void **)&pltRasVar); 

   CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, 
                    IID_ILEADRasterIO, (void**)&pRasterIO); 


   pltRasVar->Type = VALUE_ARRAY_BYTE; 
   pltRasVar->ItemCount = BUFFERSIZE;   
   
   /* Now we have a variant and we can do the real work */
   HFILE    hf; 
   int      bytesread; 

 

#ifdef UNICODE

hf = _wopen (TEXT("v:\\images\\eagle.cmp"), OF_READ);

#else

hf = _lopen ("v:\\images\\eagle.cmp", OF_READ);

   #endif
   if(pRasterIO->StartFeedLoad(m_LEADRasterView1.GetRaster(), 0, 0, 1)) /* default bits per pixel and first page */
   {    
      _lclose( hf ); 
      MessageBox( TEXT("Error in StartFeedLoad !") ); 
      return; 
   }
   do
   {
      bytesread = (int)_hread( hf, lp, BUFFERSIZE ); 
      if(pRasterIO->FeedLoad(pltRasVar, bytesread)) 
      {    
         _lclose( hf ); 
         MessageBox(TEXT("Error in FeedLoad !") ); 
         return; 
      }
   } while (bytesread > 0); 
   if(pRasterIO->StopFeedLoad())
   {
      _lclose( hf ); 
      MessageBox(TEXT("Error in StopFeedLoad !") ); 
      return; 
   }
   pltRasVar->Release ();
   pRasterIO->Release();
 }