Byte *pBuf;pBuf 是一个RGB数据 的指针。如何将RGB数据 显示出来(显示在界面上)?

解决方案 »

  1.   

    用这个函数可以讲RGB图像显示出来 StretchDIBits,但是还要给要显示的位图资源写一个位图信息头
      

  2.   

    CDC::StretchBltCopies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap if necessary to fit the dimensions of the destination rectangle.OrCDC::FillSolidRectCall this member function to fill the given rectangle with the specified solid color. 
     
      

  3.   

    use the GetRValue, GetGValue, and GetBValue macros, respectively
      

  4.   

    CDC::StretchBlt 等使用的前题是: CDC BITMAP等环境都搞好了的情况下. CDC BITMAP如何建得合理(在什么条件下或函数中)?
      

  5.   

    GetRValue //获取红色分量的值
    GetGValue //获取绿色分量的值
    GetBValue //获取蓝色分量的值如
    GetRValue(color);//COLORREF color = RGB(230,128,128);获取之后使用SetPixel或者SetPixelV都可以显示
      

  6.   

    谢谢. 开了眼界.YUV存文件后,正常,可以播。YUV2RGB后,未知错误, 出错退出, 估计是转换函数出了问题.有 176X144 下的YUV2RGB 转换函数的源码吗?
      

  7.   

    这种方法, 是不是要用GetRValue...SetPixel..循环操作内存Buf?
      

  8.   

    Byte *pDstRGBBuf; 
    pDstRGBBuf 是一个RGB数据 的指针。 以下不能把数据显示出来, 为什么? 要如何做?CWnd* pWnd = GetDlgItem(IDC_STATIC_BMP);
    CDC* pDC = pWnd->GetDC();int nS = 0;
    for (int i = 0; i < 176; i++)
      for (int j = 0; j <144;j++ )
      {
         pDC->SetPixel(i, j, RGB(GetRValue((int)pDstRGBBuf + nS), GetGValue((int)pDstRGBBuf + nS + 1),  GetBValue((int)pDstRGBBuf + nS + 2)) );
         nS = nS + 3;
      }
      

  9.   

    定义一个BITMAPINFO, 填写好对应的bmiHeader参数 这里的参数根据你的byte array来定义 比如RGB32的话就pbinfo->bmiHeader.biBitCount = 32; 
    然后调用CreateDIBSection来创建HBitmap 
    注意这里的第三个参数ppvBits 是out值有了HBitmap就好办了,要显示就太简单了。Google下还有种思路1、先声明一个BITMAP类型的变量如bitmap,并手工填充位图格式   
      2、用CreateBitmapIndirect()创建一个HBITMAP   
      3、用SetBitmapBits()或SetDIBits()为HBITMAP填充数据位   
      函数原形如下:   
      LONG   SetBitmapBits(   
          HBITMAP   hbmp,                 //   handle   to   bitmap   
          DWORD   cBytes,                 //   number   of   bytes   in   bitmap   array   
          CONST   VOID   *lpBits       //   array   with   bitmap   bits   
      );   
      HBITMAP   CreateBitmapIndirect(   
          CONST   BITMAP   *lpbm         //   bitmap   data   
      );   
      int   SetDIBits(   
          HDC   hdc,                                     //   handle   to   DC   
          HBITMAP   hbmp,                           //   handle   to   bitmap   
          UINT   uStartScan,                     //   starting   scan   line   
          UINT   cScanLines,                     //   number   of   scan   lines   
          CONST   VOID   *lpvBits,             //   array   of   bitmap   bits   
          CONST   BITMAPINFO   *lpbmi,     //   bitmap   data   
          UINT   fuColorUse                       //   type   of   color   indexes   to   use   
      );   
      

  10.   

    我原以为::SetPixel(hDC, i, j, RGB(GetRValue(X), GetGValue(X), GetBValue(X));速度快,效果好, 看样子不是.