Question: #ifndef _ _ ANSWER 0 4 _ H _ _ #define _ _ ANSWER 0 4 _ H _ _ #include #include #include #pragma pack
#ifndef ANSWERH
#define ANSWERH
#include
#include
#include
#pragma packpush save the original data alignment
#pragma pack Set data alignment to byte boundary
BMP files are laid out in the following fashion:
Header bytes
Image Data file size for bit images
BMP header bytes
uintt is bit unsigned integer
uintt is bit unsigned integer
intt is bit signed integer
typedef struct BMPheader
uintt type; Magic identifier
uintt size; File size in bytes
uintt reserved; Not used
uintt reserved; Not used
uintt offset; Offset to image data in bytes from
beginning of file bytes
uintt DIBheadersize; DIB header size in bytes bytes
intt width; Width of the image
intt height; Height of image
uintt planes; Number of color planes
uintt bits; Bits per pixel
uintt compression; Compression type
uintt imagesize; Image size in bytes
intt xresolution; Pixels per meter
intt yresolution; Pixels per meter
uintt ncolours; Number of colors
uintt importantcolours; Important colors
BMPheader;
#pragma packpop restore the previous pack setting
typedef struct BMPimage
BMPheader header;
unsigned char data;
BMPimage;
Given a BMPimage, create a new bit image that is converted from a given bit image BMPimage converttoBMPimageBMPimage image; For the given image, you may assume that it is a valid bit image; otherwise, this function should not be called at all. You have to take the bit representation and convert it into a bit representation. Note that you should not modify the original image. Instead, the function should allocate new memory spaces to store the new header information and the new image data. The header information of the new image should not be identical to that of the original image. In particular, you would have to compute the number of bytes in each row and the total image size, and therefore the file size. You have to downscale bits to bits for each color. You have to scale through to through A division of a color value by or a right shift of position should achieve similar outcome because you are ECE Purdue University c ChengKok Koh dealing with nonnegative numbers. You also have to combine the three colors into two bytes using perhaps bitwise OR operation Lastly, you have to store the two bytes into the data array of the new BMP image. It is important that the padding bytes, if required, are all assigned
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
