0

I am writing a program to rotate an image. The Image format is Bitmap and according to the http://en.wikipedia.org/wiki/BMP_file_format the rowsize of a bitmap image should be multiple of 4. My input image isn't so and when I write new image to a file, it isn't what it should be. Of course first I read the data part to an array of pixels and after that I rotate that array. If more information is needed, please tell me.

Of course my previous problem had been solved but I don't know why c++ count the size of this structure 56 byte ?

Here is the structure:

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;
};
4

1 回答 1

0

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

于 2013-03-09T17:55:36.040 回答