need some help with my code, I tried in many ways to make simple filtering image with array 3x3, but cant make it. any ideas how shall I start it?
#include
#include
#include
#include
#include
using namespace std;
//BMP header
typedef struct tagBITMAPFILEHEADER {
unsigned short bfType;
unsigned int bfSize;
short bfReserved1;
short bfReserved2;
unsigned int bfOffBits;
} BITMAPFILEHEADER;
//BMP header
typedef struct tagBITMAPINFOHEADER {
unsigned int biSize;
int biWidth;
int biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
unsigned int biCompression;
unsigned int biSizeImage;
int biXpelsPerMeter;
int biYpelsPerMeter;
unsigned int biClrUses;
unsigned int biClrImportant;
} BITMAPINFOHEADER;
int odczytajBFH(ifstream &ifs, BITMAPFILEHEADER &bfh);
int odczytajBIH(ifstream &ifs, BITMAPINFOHEADER &bih, int kursor);
void zapiszBFH(ofstream &ofs, BITMAPFILEHEADER &bfh);
void zapiszBIH(ofstream &ofs, BITMAPINFOHEADER &bih);
unsigned char* odczytajDaneObrazu(ifstream &ifs, unsigned int rozmiar, int kursor);
void odczytajRGB(unsigned char *obraz, int **niebieski, int **zielony , int **czerwony, unsigned int rozmiar, int szerokosc, int wysokosc);
unsigned char * polaczRGB(int **niebieski, int **zielony, int **czerwony, unsigned int rozmiar, int szerokosc, int wysokosc);
void zwolnij_pamiec(unsigned char *obraz, int **niebieski, int **zielony , int **czerwony, int wysokosc);
void zapiszDaneObrazu(ofstream &ofs, unsigned char *obraz, unsigned int rozmiar);
int main()
{
BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bih;
string str = "bitmap.bmp";
const char * nazwa_pliku = str.c_str();
ifstream ifs(nazwa_pliku, ios::binary) ;
if( !ifs.is_open() )
{
cout << "\nBlad otwarcia pliku";
return 0;
}
ofstream ofs("out.bmp", ios::binary);
int kursor = odczytajBFH(ifs, bfh);
kursor = odczytajBIH(ifs, bih, kursor);
zapiszBFH(ofs, bfh);
zapiszBIH(ofs, bih);
unsigned int rozmiar = bfh.bfSize - bfh.bfOffBits;
int szerokosc = bih.biWidth;
int wysokosc = bih.biHeight;
u