Problem1: BMPmain.c, BMPfns.c, BMPfns.h, Makefile The file 'BMPmain.c' contains a main() function which is already written for you and attached with this homework. When appropriate functions are provided, main() will create a .bmp image file. Your job is to write 'BMPfns.c' which contains the functions which main() uses to create .bmp image files. You must also write the header file 'BMPfns.h' to #include in BMPmain.c and which contains prototypes of the functions defined in BMPfns.c .
Problem2: BMPcheckerboard.c, BMPfns.c, BMPfns.h, Makefile Write a new main() in BMPcheckerboard.c which will draw a checkerboard of size 296 x 296 pixels using two attractive colors of your own choosing. You should be able to bring BMPfns.c and BMPfns.h from Problem1 over to Problem2 as-is. BMPmain.c:
//BMPmain.c 150S17 HW1 Problem1: main() of a program which builds a .bmp image // see Lancaster's "Exploring the .BMP File Format" for an accessible description of the bmp file format.
#define NROWS 252 //width in pixels of the image to be built
#define NCOLS 252 //height --"--
#include <stdio.h>
#include <stdlib.h>
#include "BMPfns.h"
int main(void) {
FILE *fp;
int row,col;
if( (fp= fopen("myBMP.bmp","wb")) == NULL ) {printf("Couldn't open 'myBMP.bmp'\n"); exit(0); }
//-- building a bmp header for a NROWS x NCOLS 24-bit/pixel image using Lancaster's header info
//BMP marker
fputc((int)'B',fp); fputc((int)'M',fp);
//write total length of file in bytes= (size of header + 3*number of pixels) + (number of rows * size of padding) write4LE(54 + NROWS*(3*NCOLS+padding(NCOLS)),fp);
//reserved mystery value
write4LE(0,fp);
//offset to pixel data
write4LE(54,fp);
//size of data header
write4LE(40,fp);
//width of bitmap in pixels
write4LE(NCOLS,fp);
//height of bitmap in pixels
write4LE(NROWS,fp);
//number of color planes
write2LE(1,fp);
//number of bits per pixel
write2LE(24,fp);
//compression mode
write4LE(0,fp);
//size of stored pixel data in bytes
write4LE(NROWS*(3*NCOLS),fp); //required
//width resolution in pixels/meter
write4LE(0,fp); //doesn't seem to matter
//height resolution in pixels/meter
write4LE(0,fp); //""
//height resolution in pixels/meter
write4LE(0,fp); //""
//height resolution in pixels/meter
write4LE(0,fp); //""
//--here with header built; ready to fill data //color plan is to increment red at each row increment, blue at each column increment, and keep green at 0; image starts at bottom left
for(row=0; row < NROWS; row++) {
for(col=0; col < NCOLS; col++) {
writePIXEL(row, 0, col, fp); //writePIXEL(int red, int grn, int blu, FILE *fp)
}
writePAD(padding(NCOLS),fp);
}
//here with (we hope) the bmp file built
fclose(fp);
return 0;
}
ans of problem1:
//BMPfns.h
#ifndef BITMAP__
#define BITMAP__
#define BIT (8*sizeof(byte))
#define BITMAP_NOTFOUND -1
typedef enum{false=0, true} bool;
typedef unsigned char byte;
bool bitmapGet (byte *, int);
void bitmapSet (byte *, int);
void bitmapReset (byte *, int);
int bitmapSearch(byte *, bool, int, int);
#endif
//BMPfns.c
#include "BMPfns.h"
static bool get (byte, byte);
static void set (byte *, byte);
static void reset(byte *, byte);
bool bitmapGet(byte *bitmap, int pos) {
return get(bitmap[pos/BIT], pos%BIT);
}
void bitmapSet(byte *bitmap, int pos) {
set(&bitmap[pos/BIT], pos%BIT);
}
void bitmapReset(byte *bitmap, int pos) {
reset(&bitmap[pos/BIT], pos%BIT);
}
int bitmapSearch(byte *bitmap, bool n, int size, int start)
{
int i;
for(i = start+1, size *= BIT; i < size; i++)
if(bitmapGet(bitmap,i) == n)
return i;
return BITMAP_NOTFOUND;
}
static bool get(byte a, byte pos) {
return (a >> pos) & 1;
}
static void set(byte *a, byte pos) {
*a |= 1 << pos;
}
static void reset(byte *a, byte pos) {
*a &= ~(1 << pos);
}
Problem1: BMPmain.c, BMPfns.c, BMPfns.h, Makefile The file 'BMPmain.c' contains a main() function which is already written...
AssignmentBitmap files map three 8-bit (1-byte) color channels per pixel. A pixel is a light-emitting "dot" on your screen. Whenever you buy a new monitor, you will see the pixel configuration by its width and height, such as 1920 x 1080 (1080p) or 3840x2160 (4K). This tells us that we have 1080 rows (height), and each row has 1920 (width) pixels.The bitmap file format is fairly straight forward where we tell the file what our width and height are. When...
the following python code edits BMP image file to negative but I need help with modifying this code so it turns it the same BMP image file into a black and white instead of a negative. heres python code I have so far [pasted below] ## # This program processes a digital image by creating a negative of a BMP image. # from io import SEEK_CUR from sys import exit def main() : filename = input("Please enter the file name:...
In c++ The iron-puzzle.ppm image is a puzzle; it contains an image of something famous, however the image has been distorted. The famous object is in the red values, however the red values have all been divided by 10, so they are too small by a factor of 10. The blue and green values are all just meaningless random values ("noise") added to obscure the real image. If you were to create a grayscale image out of just the red...
It is a C++ program by using inheritance and vectors My professor said that all the files should be separate. like File.cpp, File.h, Text.cpp,Text.h,Main.cpp I already have these files File.cpp #include "File.h" // Constructor of File that takes File name and type as arguments File::File(string type, string name) { this->type = type; this->name = name; } //returns the type. string File::getType() { return type; } //returns the name of file. string File::getName() { return name; } File.h #ifndef __FILE_H__ #define...
Project_10_base_files.zipMakefile (2).txtProject_10_main 1.JPGProject_10_main 2.JPGProject_10_main 3.JPGProject_10 h.JPGProject_10 cpp.JPGAny C++ technique covered in Chapters 1 through 12is allowedexcept for global variablesYou are not allowed to use any global variables.If necessary, global constants may be used.Project 10DescriptionFor this project a Date class(specifiedin the file Project_10.h) will be constructed and all function definitions will be written in the file Project_10.cpp. A makefileis provided to compile this project. The file Project_10_main.cppcontainsthe main functionthat is used to run the program.On Canvas, download the files Project_10.h, Project_10_main.cpp...
-------c++-------- The Passport class takes a social security number and the location of a photo file. The Passport class has a Photo class member, which in a full-blown implementation would store the passport photo that belongs in that particular passport. This Photo class holds its location or file name and the pixel data of the image. In this lab the pixel data is only used to show how memory maybe used when a program uses large objects. We will not...
I only need the "functions" NOT the header file nor the main implementation file JUST the implementations for the functions Please help, if its difficult to do the complete program I would appreciate if you could do as much functions as you can especially for the derived class. I am a beginer so I am only using classes and pointers while implementing everything using simple c++ commands thank you in advanced Design and implement two C++ classes to provide matrix...
Need help starting from question 9. I have tried multiple codes but the program says it is incorrect. Case Problem 1 Data Files needed for this Case Problem: mi pricing_txt.html, mi_tables_txt.css, 2 CSS files, 3 PNG files, 1 TXT file, 1 TTF file, 1 WOFF file 0 Marlin Internet Luis Amador manages the website for Marlin Internet, an Internet service provider located in Crystal River, Florida. You have recently been hired to assist in the redesign of the company's website....
Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...
help implementing canvas.cpp but with only #include "canvas.h", class header file doesnt have height ----------------------------------------------------------------------------------------------------------------------- canvas.h #ifndef CANVAS_H #define CANVAS_H #include <string> using namespace std; // In this homework, you'll manipulate ASCII art images // consisting of a rectangular grid of chararacter pixels. class Canvas { public: // Allocates a canvas of the given width and height 5 that // consists entirely of ' ' (space) chars. Canvas(int width); // Allocates a canvas with width 5 and height 5 that...