一般的bmp to jpeg 都是在生成jpg文件时使用,能否建立一个buffer,在bmp-buffer
和jpg--buffer中作转换.不需要openfile(X_file),fclose(X_file)等在硬盘的存取
操作.

解决方案 »

  1.   

    可以查阅WIC的资料或者利用GDI+也可以。
      

  2.   

    Bitmap   bmp( L"你的bmp文件" );Bitmap   bmp2( bmp.getWidth(), bmp.getHeight() );
    Graphics g( bmp2 );
    g.DrawImage( &bmp, 0, 0 );SaveToJpg( bmp2 );// 需要自己写SaveToJpg,还需要GetEncoderClsid等函数,查找GDI+相关例子。
      

  3.   

    vc60.支持gdi+吗?还是需要改为vc.net?
      

  4.   

    CreateStreamOnHGlobal
    Image::Save(IStream*,CLSID*,EncoderParameters*) 
      

  5.   

    支持,我刚在6.0下用gdi+做了转tiff格式的。
      

  6.   

    修正一下,我是装了windows sdk
      

  7.   

    谢谢sc3590,还想了解如何处理window.sdk,是如何下载,运行.
      

  8.   

    gdi+好像有单独的开发包,单下一个也行。
      

  9.   

    按照各位的指导,下载和配置sdk,vc6.0,winXP,
    按hellowithsmile
    的提示运行,但没有显示;
    请帮忙查看一下错在哪.1.  StdAfx.h#define ULONG_PTR unsigned long
    #include <Gdiplus.h>
    using namespace Gdiplus;
    //#define ULONG_PTR ULONG 
    //#include <gdiplus.h>
    //using namespace Gdiplus;
    #pragma comment(lib, "gdiplus.lib")2.   BOOL CTestgdiApp::InitInstance()   GdiplusStartupInput     m_gdiplusStartupInput;
        GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, NULL);
        m_pMainWnd->ShowWindow(SW_SHOW);
        m_pMainWnd->UpdateWindow();3.   int CTestgdiApp::ExitInstance() 
    {
    // TODO: Add your specialized code here and/or call the base class
    Gdiplus::GdiplusShutdown(m_gdiplusToken);
    return CWinApp::ExitInstance();
    }
    4.  testgdiDlg.cpp : implementation file
    #include "stdafx.h"
    #include "testgdi.h"
    #include "testgdiDlg.h"
    #include "GdiPlus.h"
    #include <windows.h>
    #include <dshow.h>
    #include <stdio.h>
    #include <conio.h>
    #include <qedit.h> // SampleGrabber用
    #include <math.h>
    #include <windowsx.h>
    #include <mmsystem.h>
    #include <stdlib.h>
    #include <string.h>
    #include <limits.h>
    #include <ctype.h>
    //#include "cv.h"
    //#include "cxcore.h"
    #pragma comment(lib, "strmiids.lib")
    #pragma comment(lib, "gdiplus.lib")
    5.  运行程序--
    Bitmap bmp( L"a.bmp" );
    //Bitmap bmp2( bmp.getWidth(), bmp.getHeight() );
    Bitmap bmp2( 320, 240 );
    Graphics g(hMemDC);
    //Graphics g(hDC);
    g.DrawImage( &bmp, 0, 0 );
      

  10.   

    gdiplus.h,gdiplus.dll 都按照vc的规定设定完成.
    前面4点都是参考上网查的资料配置sdk,第5点就是试验一下
    vc 对话框的运行的正确与否.麻烦各位先进了.
      

  11.   

    a.bmp 放在3个位置
    1. c:
    2. 原程序目录上.
    3. 和原程序的debug放在一起.
      

  12.   

    如果实在开发环境下执行,放在2路径,如果是在Debug下直接执行,放在3路径,你最好设定一个绝对路径。
      

  13.   

    HDC hdc,hMemDC;
    Bitmap bmp( L"a.bmp" );
    //Bitmap bmp2( bmp.getWidth(), bmp.getHeight() );
    Bitmap bmp2( 320, 240 );
    Graphics g(hMemDC);
    //Graphics g(hDC);
    g.DrawImage( &bmp, 0, 0 );各种路径都试过了,Bitmap bmp( L"c:\\a.bmp" );
    Bitmap bmp( L"c:\\test\\a.bmp" );
    Bitmap bmp( L"c:\\test\debug\\a.bmp" );
    我有点怀疑不一定是程序本身的问题,而是sdk配置还是不行
    ,麻烦您贴一个如上面这样的简单程序,让我在我的机上运行一下,
    以证实问题出在哪.
    麻烦了.谢谢.
      

  14.   

    可以在内存中转的的,好像有一个libjpeg库可以拿过来用的!