如何把位图的每一个像素读到一个矩阵数组中?

yzm8529 2006-10-08 08:44:14
目的是把资源文件做成背景透明纹理,所以想解决如题的问题。
...全文
164 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yzm8529 2006-12-05
  • 打赏
  • 举报
回复
yzm8529@163.com
guohua24 2006-10-17
  • 打赏
  • 举报
回复
这是我的程序中读取位置i,j处数据的代码。供参考。留个信箱我把完整的Cdib给你
guohua24 2006-10-17
  • 打赏
  • 举报
回复

unsigned char CDib::GetData(int i, int j)
{
ASSERT(i>=0 && i<m_pBIH->biWidth);
ASSERT(j>=0 && j<m_pBIH->biHeight);

unsigned char ret;
if(m_pBIH->biBitCount == 1)
{
int width;
if((((m_pBIH->biWidth-1)/8+1)%4) != 0)
{
width = (((m_pBIH->biWidth-1)/8+1)/4+1)*4;
}
else
{
width = m_pBIH->biWidth;
}


int index = (m_pBIH->biHeight - 1 -j) * (width) + (((i)/8));

int data = m_pDibBits[index];
unsigned char mod = i%8;
ret = data&(128>>mod);
ret = ret>>(7 - mod);
}

if(m_pBIH->biBitCount == 8)
{
int width = ((m_pBIH->biWidth-1)/4 + 1)*4;
int index = (m_pBIH->biHeight - 1 -j) * (width) + i;
int tempIndex = m_pDibBits[index];
RGBQUAD rgb = m_pPalette[tempIndex];
ret = rgb.rgbBlue;
}

return ret;

}

8,303

社区成员

发帖
与我相关
我的任务
社区描述
游戏开发相关内容讨论专区
社区管理员
  • 游戏开发
  • 呆呆敲代码的小Y
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧