i did these code for overloading << and >> operators on my image class:
Code:
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
   UINT  num = 0;          // number of image encoders
   UINT  size = 0;         // size of the image encoder array in bytes

   ImageCodecInfo* pImageCodecInfo = NULL;

   GetImageEncodersSize(&num, &size);
   if(size == 0)
      return -1;  // Failure

   pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
   if(pImageCodecInfo == NULL)
      return -1;  // Failure

   GetImageEncoders(num, size, pImageCodecInfo);

   for(UINT j = 0; j < num; ++j)
   {
      if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
      {
         *pClsid = pImageCodecInfo[j].Clsid;
         free(pImageCodecInfo);
         return j;  // Success
      }
   }

   free(pImageCodecInfo);
   return -1;  // Failure
}
////............
//for save it on file
friend std::ostream& operator << (std::ostream& lhs, const image& rhs)
    {
        /*if(IfFileExists(rhs.strfilename)==true)
            lhs<<rhs.strfilename;
        else
        {*/
            IStorage* pIStorage = NULL;
            IStream* pIStream1 = NULL;
            HRESULT hr;
            Status stat = Ok;
            hr = CoInitialize(NULL);

            hr = StgCreateDocfile( L"CompoundFile.cmp", STGM_READWRITE|STGM_CREATE|STGM_SHARE_EXCLUSIVE,0, &pIStorage);

            CLSID jpgClsid;
            GetEncoderClsid(L"image/gif", &jpgClsid);
            pIStorage->CreateStream(L"StreamImage1", STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0,&pIStream1);
            rhs.img->Save(pIStream1, &jpgClsid, NULL);
        //}
        return lhs;
    }
or i miss something or i don't know.
i'm trying save the img data to file in stream way, instead file name.
i don't get anyerrors. the problem is that i don't get any image.