使用CRenderTarget :: DrawBitmap和Byte Array(而不是文件)将位图绘制到屏幕上 [英] Drawing Bitmap on to screen using CRenderTarget::DrawBitmap and Byte Array (instead of file)

查看:243
本文介绍了使用CRenderTarget :: DrawBitmap和Byte Array(而不是文件)将位图绘制到屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在使用COSMCtrl来显示查看窗口上的地图。



在COSMCtrl中,文件名与CRenderTarget对象一起传递给CD2DBitmap构造函数。但我的应用程序没有图像文件。它将从数据库接收图像数据(以字节数组的形式)。



任何人都可以帮我找到解决方案吗?



示例代码如下:

Hi All,

I am working with COSMCtrl in order to display maps on to the viewing window.

In the COSMCtrl, a file name is passed on to the CD2DBitmap constructor along with CRenderTarget object. But my application doesnt have image file. It will receive image data (in the form of byte array) from a database.

Could any one please help me in finding out the solution ?

The sample code is below:

BOOL COSMCtrl::DrawTile(CRenderTarget* pRenderTarget, const CD2DRectF& rTile, int nTileX, int nTileY)
{
  //What will be the return value from this function (assume the worst)
  BOOL bSuccess = FALSE;

  //Form the path to the cache file which we want to draw
  int nZoom = static_cast<int>(m_fZoom);
  CString sFile(GetTileCachePath(m_sCacheDirectory, nZoom, nTileX, nTileY, FALSE));

  //Get the fractional value of the zoom
  double fInt = 0;
  double fFractionalZoom = modf(m_fZoom, &fInt);

  //Try to obtain the standard tile
  CD2DBitmap bitmap(pRenderTarget, sFile);

// I have a Byte Array. I should pass the byte array instead of file

  //Determine how the tile should be draw
  BOOL bStandardTile = FALSE;
  if (fFractionalZoom == 0 && SUCCEEDED(bitmap.Create(pRenderTarget)))
   bStandardTile = TRUE;

  //Load up the image from disk and display it if we can
  if (bStandardTile)
  {
    //Draw the image to the screen at the specified position
    pRenderTarget->DrawBitmap(&bitmap, rTile, 1.0);
    bSuccess = TRUE;
  }

return bSuccess;
}







1. I am not allowed to save the byte array to disk (as image).

2. I have tried using the other constructor of CD2DBitmap which accepts CRenderTarget and HBITMAP. but of no use

推荐答案

CBitmap :: SetBitmapBits [ ^ ]如果您的数据是RGB ...
CBitmap::SetBitmapBits[^] if your data is RGB ...


这篇关于使用CRenderTarget :: DrawBitmap和Byte Array(而不是文件)将位图绘制到屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆