如何将Image或Bitmap 的对象转成二进制流???有没有好的一种方法。
希望大家贴下代码

解决方案 »

  1.   

    不能将GDI+ 类的Bitmap或Image 的内存中的对像保成为二进制么?Bitmap img; 
    img 为内存中的对像。只要能保存为二进制就行。。
      

  2.   

    我想把这个img 存为二进制不知有没有办法,然后弄到数据库里去。
    不能把它存为文件再转二进制,我想直接通过什么操作。。就可以达那种到目的的。。呵呵
      

  3.   

    Step 1: save your image in a stream with the function below:
    Image::Save(IStream*, CLSID*, EncoderParameters*) Step 2: read some bytes from the stream with the function below:
    ISequentialStream::Read(void* pv, ULONG cb, ULONG* pcbRead)Now you have got the binery date in the buffer pv.As the same, you can use the function below to write some bytes to a stream:
    ISequentialStream::Read(  void const* pv, ULONG cb, ULONG* pcbWritten)So, that is it. Help yourself.
      

  4.   

    Excuse me, the last function I mean this:
    ISequentialStream::Write(  void const* pv, ULONG cb, ULONG* pcbWritten) 
      

  5.   

    这个方法是我想要的。能不能贴点实际代码来??
    Bitmap img(L"pathname")); 
    COleStreamFile  img_stream  ;    
    img_stream.CreateMemoryStream(NULL);   //存在这里可不可以?? 
    img.Save(img_stream.GetStream(),  Gdiplus::ImageFormatBMP);//是不是这样然后对image_stream文件操作存入数据库中?但编译通不过? 
    接下去怎么写。分可以再加。。
      

  6.   

    CreateStreamOnHGlobal
    OleLoadPicture
      

  7.   


       CBitmap Bitmap;
       Bitmap.LoadBitmap (IDB_BITMAP1);
     
        BYTE BmpData[200][26];
    for(int i=0;i<200;i++)
    for(int j=0;j<25;j++)
    if(i%10<5)
    BmpData[i][j]=0xFF;
    else
    BmpData[i][j]=0x00;
    Bitmap.SetBitmapBits (200*26,BmpData);