Hello.
I have been trying to fingure this out all day, and with the help of Google and this good site, I think I have a program that will copy the original file, into a new file. My plan is then to negate that file.
But before that, I have an issue, maybe a few! I do not know what sizes to make the data array. I do not know what image will be loaded it, so I don't know what to put here. How should I handle this?
Also, I am not sure about the structure of the code I need to negate the copied image, which I will save back into copy when it is done.
Any advice would be very welcome.
Code:
#include <iostream>
#include <stdio.h>
#include "windows.h"
using namespace std;
int main()
{
FILE *ptrBmpFile, *ptFile;
int number;
unsigned char data [][][];
BITMAPFILEHEADER bMapFileHeader;
BITMAPINFOHEADER bMapInfoHeader;
ptrBmpFile = fopen("Enter file name.bmp", "rb");
fseek(ptrBmpFile, 0, SEEK_SET); //Go to the start of the file
//copies BITMAPFILEHEADER and BITMAPINFOHEADER
num = fread(&bMapFileHeader, sizeof(BITMAPFILEHEADER), 1, ptrBmpFile);
num = fread(&bMapInfoHeader, sizeof(BITMAPINFOHEADER), 1, ptrBmpFile);
ptBmpFile = fopen("Enter file name for copy of image.bmp", "w")
//creates empty file for writing
fseek(ptBmpFile, 0, SEEK_SET);
num = fwrite(&bMapFileHeader, sizeof(BITMAPFILEHEADER), 1, ptBmpFile);
num = fwrite(&bMapInfoHeader, sizeof(BITMAPINFOHEADER), 1, ptBmpFile);
//Get the beginning of the data in the bitmap
fseek(ptr, 0, SEEK_SET);
//Read in the bitmap fil
fread(data, bMapInfoHeader.biSizeImage, 1, ptrBmpFile);
fclose(ptrBmpFile);
//Copy image
fseek(ptrBmpFile, 0, SEEK_SET);
fwrite(data, bMapInfoHeader.biSizeImage, 1, ptBmpFile);
fclose(ptBmpFile);
}
Thanks.
Seán