我的程序通过函数依次获取一个flash文件的HBITMAP,然后通过GDI+的drawimage拉伸图像,再通过Bitmap::LockBits函数获取BitmapData的Scan0,从而得到图像具体数据,但是我发现有的flash文件可以顺利得到图像数据,有的flash文件得到数据为全0,等于没有得到具体数据,不知道哪位大侠肯指点一二?

解决方案 »

  1.   

    没有代码不清楚问题出在哪.
    但我估计最大可能是获取FLASH文件的HBITMAP时出的问题.
    sign-----------------------------------------------------------------------

      

  2.   

    获取FLASH文件用的是一个DLL里面的函数,hbmp= GetNextImage(),返回的hbmp也不为空
      

  3.   

    dll是没有源代码的,没有人遇到过类似问题吗
      

  4.   

    int frameNum= 0,wid=rc.Width(),hei=rc.Height();
    #ifdef UNICODE  //120822,lpj
    char buf[1000];
    memset(buf, 0, 1000);
        WideCharToMultiByte(0, 0, path, -1, buf, 1000, 0, 0);
    HBITMAP hbmp = OpenSWF(buf, m_hWnd, frameNum, wid, hei);
    #else
    HBITMAP hbmp= OpenSWF(path,m_hWnd,frameNum,wid,hei);
    #endif
    BITMAP bm;
    ::GetObject(hbmp,sizeof(BITMAP),&bm);
    wid= bm.bmWidth;
    hei= bm.bmHeight; int i;
    int w2= theApp.cols*3+ theApp.cols%4;
    int sz= w2*rc.Height();
    CFrameData* p=NULL;
    bool same= ((wid==rc.Width())&&(hei==rc.Height()));
    if(wid<rc.Width()||hei<rc.Height())
    mode= 1;
    int sx= (wid-rc.Width())/2;
    int sy= (hei-rc.Height())/2;
    Rect rect(0,0,rc.Width(),rc.Height());
    BitmapData bitmapData; Bitmap bmp(rc.Width(),rc.Height());
    Graphics *pg= Graphics::FromImage(&bmp);

    Status s;
    //Bitmap* pBmp = NULL; 
    for(i=0;hbmp ;)
    {
    theApp.pMf->SendMessage(MYWM_PROGRESS,100*i/frmNum);

    p= new CFrameData(theApp.cols,theApp.rows,theApp.bgr);
    gFrm->InsertAt(++gcur,p);
    Bitmap src(hbmp,NULL);

    if(mode) //拉伸
    {
    s = pg->DrawImage(&src,rect,0,hei-1,wid,-hei,  UnitPixel, NULL,  NULL,  NULL);
    }
    else //居中
    pg->DrawImage(&src,rect,sx,sy+hei-1,wid,-hei,UnitPixel,NULL,NULL,NULL);

    Status s = bmp.LockBits(rect,ImageLockModeRead,PixelFormat24bppRGB,&bitmapData);
    BYTE* pixels = /*reinterpret_cast<BYTE*>*/(BYTE*)bitmapData.Scan0;
    #ifdef DEBUG
    ofstream fout("E:\\test\\swf.dat", ios::binary);
    fout.write((char*)bitmapData.Scan0, sz);
    fout.close();
    #endif
    memcpy(p->pix,pixels,sz);
    bmp.UnlockBits(&bitmapData); if(++i>=frmNum)
    break;
    if(GetAsyncKeyState(VK_ESCAPE)<0)
    break;
    hbmp= GetNextImage();
    } CloseSWF();