Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to load an 8-bit Grayscale image and output an overlay with Comments in c++

ID: 3744964 • Letter: H

Question

How to load an 8-bit Grayscale image and output an overlay with Comments in c++ using the BMP format and an array:

One image (out1) that contains the original image overlaid (IO) with the overlay image. While there are several useful ways of overlaying, the one that you need to implement is the following: if a pixel is black in the overlay image, the corresponding pixel in out1 is white. If a pixel is not black in the overlay image, the corresponding pixel in out1 equals the corresponding pixel in the original image. We will call this way of processing image overlay (IO).

Explanation / Answer


#include <windows.h> #include <iostream> #include <stdio.h> HANDLE hfile; DWORD written; BITMAPFILEHEADER bfh; BITMAPINFOHEADER bih; int main() hfile = CreateFile("image.bmp",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); ReadFile(hfile,&bfh,sizeof(bfh),&written,NULL); ReadFile(hfile,&bih,sizeof(bih),&written,NULL); int imagesize = bih.biWidth * bih.biHeight; image = (unsigned char*) malloc(imagesize); ReadFile(hfile,image,imagesize*sizeof(char),&written,NULL); CloseHandle(hfile);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote