将数组写入位图 c++
Writing array into bitmap c++
我在再次将数组写入位图时遇到问题,所以基本上我从.bmp文件中读取数据,在那里我得到像素的数据,我想使 B 和 R = 0,所以这是我的代码:
int row_padded = ( Picture.biWidth*3 + 3) & (~3);
unsigned char* data = new unsigned char [row_padded];
unsigned char tmp;
for(int i = 0; i < Picture.biHeight; i++)
{
fread(data, sizeof(unsigned char), row_padded, plik);
for(int j = 0; j < Picture.biWidth*3; j += 3)
{
data[j] = 0;
data[j+2] = 0;
}
}
现在,当我的 B 和 R = 0 时,我想再次将其保存到同一个文件中,所以我使用:
for(int j = 0; j< Picture.biHeight; j++)
{
fwrite(data,1,Picture.biWidth, f);
}
但没有任何效果。
fwrite(data,1,Picture.biWidth, f)
必须fwrite(data,1,row_padded, f)
否? 否则只写入前三分之一的字节
注意:根据定义sizeof(unsigned char)
是1
相关文章:
- C / C++ 移位/偏移/向左或向右移动位图?
- 如何在快板的屏幕中显示子位图的绘制?
- CreateDIBSection为同一图像返回不一致的位图位值
- C++ 位图中的 ttc 字体
- 使用 GDI+ 旋转位图,然后转换为 HDC
- 难以从 CImageList 设置菜单项位图
- 如何将位图拉伸到父面板(wxWidgets 自定义)
- 如何使用 freetype2 访问单色位图中的像素状态
- 将位图 (bmp) 转换为具有透明度的 png (Windows c++)
- 安卓工作室 |CPP 文件错误错误: 位图库中对"AndroidBitmap_unlockPixels"的未定义引用
- 位图到垫子/2D 数组
- Gdiplus位图没有Alpha通道
- 如何从路径字符串加载Gdiplus::位图
- 在C++中使用Gdiplus创建透明位图
- 用C++压缩内存中的位图
- C++gdi::内存中的位图到PNG图像
- LoadImage 函数不适用于 ImageMagick 创建的位图图像
- (位图)LoadImage() 返回 NULL,GetLastError() 返回 0
- 将Qt qml文件转换为位图图像
- 如何从资源文件(.rc 文件)加载位图?