Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The first part of the lab is to write a program to read the complete contents of a bitmap to an array of char. This

image text in transcribed

The first part of the lab is to write a program to read the complete contents of a bitmap to an array of char. This code will be used in subsequent coding problems. You will need 3 functions: main(), read_bmp () and write_bmp(). The main function contains the menu code. The read bmp() function reads the complete contents of a bitmap file to data fields and a char array in a Bitmap struct. The write_bmp() writes the complete contents of a Bitmap struct to a file. The read_bmp() will require: 1. Open the file for reading binary 2. Calculating the size of a file using fseek(), ftell) and rewind() (as was done in previous lab) 3. Allocating memory to read the file to the char array in the Bitmap struct using malloc() 4. Reading the bitmaps contents to the data fields and allocated string using fread) 5. Close the file The contents of the bitmap file consist of a file header, the first 54 bytes of the file, and the image, all remaining bytes in the file. The constants below mark the size of the header, the size of the image, the width in pixels of the image and the height in pixels of the image. Note that each pixel is 3 bytes; a blue, green and red byte for each pixel. #define HEADERSIZE 54 #define SIZE, BEGIN 2 #define WIDTHBEGIN 18 #define HEIGHT-BEGIN 22 - - The Bitmap struct should contain the following: The file size in bytes The width of the bitmap image in pixels The height of the bitmap image in pixels A pointer to a char array to store the address of the char array containing the complete contents of the bitmap file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

Students also viewed these Databases questions