Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 当位图文件';s行大小为';不是4的倍数吗?_C++_Bitmap_Byte_Rgb_24 Bit - Fatal编程技术网

C++ 当位图文件';s行大小为';不是4的倍数吗?

C++ 当位图文件';s行大小为';不是4的倍数吗?,c++,bitmap,byte,rgb,24-bit,C++,Bitmap,Byte,Rgb,24 Bit,我正在写一个旋转图像的程序。图像格式为位图,根据位图的大小,位图图像的行大小应为4的倍数。我的输入图像不是这样,当我将新图像写入文件时,它不是应该的。当然,首先我将数据部分读取到一个像素数组,然后旋转该数组。如果需要更多信息,请告诉我 当然,我以前的问题已经解决了,但我不知道为什么C++对这个结构的大小进行了56字节的计算? 结构如下: struct Bitmap_Header { char H_Signature[2]; unsigned int H_Filesize;

我正在写一个旋转图像的程序。图像格式为位图,根据位图的大小,位图图像的行大小应为4的倍数。我的输入图像不是这样,当我将新图像写入文件时,它不是应该的。当然,首先我将数据部分读取到一个像素数组,然后旋转该数组。如果需要更多信息,请告诉我

当然,我以前的问题已经解决了,但我不知道为什么C++对这个结构的大小进行了56字节的计算? 结构如下:

struct  Bitmap_Header
{
    char H_Signature[2];
    unsigned int H_Filesize;
    int H_Reserved;
    unsigned int H_DataOffset;
    unsigned int H_Size;
    int H_Width;
    int H_Height;
    short int H_Planes;
    short int H_BitCount;
    unsigned int H_Compression;
    unsigned int H_Imagesize;
    int H_XPixelsPerM;
    int H_YPixelsPerM;
    unsigned int H_ColorsUsed;
    unsigned int H_ColorsImportant;
};

当您将图像写入bmp文件时,应该填充每个扫描行,使其大小(以字节为单位)为4的倍数。只需在每行末尾添加额外的0字节。

我的输入图像是686*400。你能给我解释一下如何给二维阵列分配像素值吗?我找到了解决方案。谢谢你的回答。