急!急!急!急!VC++中有没有将jpg图直接载入转换成24位bmp图的函数

解决方案 »

  1.   

    CxImage
    http://www.codeproject.com/bitmap/cximage.aspCxImage Sample
    http://www.codeproject.com/listctrl/ThumbsViewer.aspGDI+ Sample
    http://www.codeproject.com/vcpp/gdiplus/GdiPThumbnailsViewer.asp
      

  2.   

    使用GDI+在内存中转换图片类型
    http://www.vckbase.com/document/viewdoc/?id=1177
      

  3.   

    如果仅仅是转换用IPicture是个不错的
      

  4.   

    http://www.codeguru.com/Cpp/G-M/bitmap/article.php/c4935/
      

  5.   

    This code has probably been superseded by MFC or OWL or whatever classes, which can load any image file. However, you will most probably do it with plain API, and converting a JPG file using Intel's library can be very painful.Here is a simple function that loads a JPG/GIF/BMP file into memory and returns a HBITMAP. The function uses IPicture, an OLE interface. #include <olectl.h> and <ole2.h> are also needed.// Function LoadAnImage: accepts a file name and returns a HBITMAP.
    // On error, it returns 0.
    HBITMAP LoadAnImage(char* FileName)
       {
       // Use IPicture stuff to use JPG / GIF files
       IPicture* p;
       IStream* s;
       IPersistStream* ps;
       HGLOBAL hG;
       void* pp;
       FILE* fp;
       // Read file in memory
       fp = fopen(FileName,"rb");
       if (!fp)
       return NULL;   fseek(fp,0,SEEK_END);
       int fs = ftell(fp);
       fseek(fp,0,SEEK_SET);
       hG = GlobalAlloc(GPTR,fs);
       if (!hG)
          {
          fclose(fp);
          return NULL;
          }
       pp = (void*)hG;
       fread(pp,1,fs,fp);
       fclose(fp);   // Create an IStream so IPicture can
       // CreateStreamOnHGlobal(hG,false,&s);
       if (!s)
          {
          GlobalFree(hG);
          return NULL;
          }   OleLoadPicture(s,0,false,IID_IPicture,(void**)&p);   if (!p)
          {
          s->Release();
          GlobalFree(hG);
          return NULL;
          }
       s->Release();
       GlobalFree(hG);   HBITMAP hB = 0;
       p->get_Handle((unsigned int*)&hB);   // Copy the image. Necessary, because upon p's release,
       // the handle is destroyed.
       HBITMAP hBB = (HBITMAP)CopyImage(hB,IMAGE_BITMAP,0,0,
                                        LR_COPYRETURNORG);   p->Release();
       return hBB;
       }