Witam!
Mam do napisania programik który jak w temacie przepisuje bitmape z jednego pliku, tworzy nowy plik bmp i w nim zapisuje zawartosc odczytanej bitmapy. Program ma slużyc jako baza do programu nakladajacego rozne filtry na obrazy. Program napisalem ale podczas proby uruchomienia z nieznanych mi przyczyn program nie moze uzyskac dostepu do pliku ktory utworzyl i w ktorym ma zapisac odczytana bitmape. Ponizej zamieszczan kod:
#include <windows.h>
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#include <fstream>
using namespace std;
BITMAPFILEHEADER bm_h;
BITMAPV5HEADER bm_v5;
RGBQUAD bm_rgb;
int main()
{
ifstream fh ("C:\\Documents and Settings\\Admin\\Pulpit\\program\\aston.bmp", ifstream::in);
ofstream fhout("C:\\Documents and Settings\\Admin\\Pulpit\\program\\aston_out.bmp", ios::binary);
//fhout.open ("C:\\Documents and Settings\\Admin\\Pulpit\\program\\aston_out.bmp");
fh.read((char *)(&bm_h),sizeof(bm_h));
fh.read((char *)(&bm_v5),sizeof(bm_v5));
fh.read((char *)(&bm_rgb),sizeof(bm_rgb));
fh.close();
cout<<"typ:"<<bm_h.bfType<<endl<<"rozmiar:"<<bm_h.bfSize<<endl;
cout<<"szer.:"<<bm_v5.bV5Width<<endl<<"wys.:"<<bm_v5.bV5Height<<endl;
cout<<"kolory:"<<bm_v5.bV5BitCount<<endl<<"kompresja:"<<bm_v5.bV5Compression<<endl;
cout<<"blue:"<<(string *)(bm_rgb.rgbBlue)<<endl<<"green:"<<(string *)(bm_rgb.rgbGreen)<<endl<<"red:"<<(string *)(bm_rgb.rgbRed)<<endl;
fh.seekg(bm_h.bfOffBits, ios::beg);
char **bitmap = new char *[bm_v5.bV5Width];
for (int x =0 ; x<bm_v5.bV5Width; x++){
bitmap[x] = new char [bm_v5.bV5Height];
}
for (int h=0 ; h<bm_v5.bV5Height ; h++)
{
for (int w = 0 ; w<bm_v5.bV5Width ; w++)
{
fh.read((char *)(&bitmap[w][h]), 1 );
}
}
//wyswietlenie tablicy na ekranie dla testu zawartosci
/*
for (int h=0 ; h<bm_v5.bV5Height ; h++)
{
for (int w = 0 ; w<bm_v5.bV5Width ; w++)
{
cout<<bitmap[w][h];
}
}
///////////////////////////////////
*/
fhout.write((char *)(bm_h.bfType), sizeof(bm_h.bfType));
fhout.write((char *)(bm_h.bfSize), sizeof(bm_h.bfSize));
fhout.write((char *)(bm_h.bfReserved1), sizeof(bm_h.bfReserved1));
fhout.write((char *)(bm_h.bfReserved2), sizeof(bm_h.bfReserved2));
fhout.write((char *)(bm_h.bfOffBits), sizeof(bm_h.bfOffBits));
fhout.write((char *)(bm_v5.bV5Size), sizeof(bm_v5.bV5Size));
fhout.write((char *)(bm_v5.bV5Width), sizeof(bm_v5.bV5Width));
fhout.write((char *)(bm_v5.bV5Height), sizeof(bm_v5.bV5Height));
fhout.write((char *)(bm_v5.bV5Planes), sizeof(bm_v5.bV5Planes));
fhout.write((char *)(bm_v5.bV5BitCount), sizeof(bm_v5.bV5BitCount));
fhout.write((char *)(bm_v5.bV5Compression), sizeof(bm_v5.bV5Compression));
fhout.write((char *)(bm_v5.bV5SizeImage), sizeof(bm_v5.bV5SizeImage));
fhout.write((char *)(bm_v5.bV5XPelsPerMeter), sizeof(bm_v5.bV5XPelsPerMeter));
fhout.write((char *)(bm_v5.bV5YPelsPerMeter), sizeof(bm_v5.bV5YPelsPerMeter));
fhout.write((char *)(bm_v5.bV5ClrUsed), sizeof(bm_v5.bV5ClrUsed));
fhout.write((char *)(bm_v5.bV5ClrImportant), sizeof(bm_v5.bV5ClrImportant));
fhout.write((char *)(bm_v5.bV5RedMask), sizeof(bm_v5.bV5RedMask));
fhout.write((char *)(bm_v5.bV5GreenMask), sizeof(bm_v5.bV5GreenMask));
fhout.write((char *)(bm_v5.bV5BlueMask), sizeof(bm_v5.bV5BlueMask));
fhout.write((char *)(bm_v5.bV5AlphaMask), sizeof(bm_v5.bV5AlphaMask));
fhout.write((char *)(bm_v5.bV5CSType), sizeof(bm_v5.bV5CSType));
//fhout.write((CIEXYZTRIPLE )(bm_v5.bV5Endpoints), sizeof(bm_v5.bV5Endpoints));
fhout.write((char *)(bm_v5.bV5GammaRed), sizeof(bm_v5.bV5GammaRed));
fhout.write((char *)(bm_v5.bV5GammaGreen), sizeof(bm_v5.bV5GammaGreen));
fhout.write((char *)(bm_v5.bV5GammaBlue), sizeof(bm_v5.bV5GammaBlue));
fhout.write((char *)(bm_v5.bV5Intent), sizeof(bm_v5.bV5Intent));
fhout.write((char *)(bm_v5.bV5ProfileData), sizeof(bm_v5.bV5ProfileData));
fhout.write((char *)(bm_v5.bV5ProfileSize), sizeof(bm_v5.bV5ProfileSize));
fhout.write((char *)(bm_v5.bV5Reserved), sizeof(bm_v5.bV5Reserved));
fhout.write((char *)(bm_rgb.rgbBlue), sizeof(bm_rgb.rgbBlue));
fhout.write((char *)(bm_rgb.rgbGreen), sizeof(bm_rgb.rgbGreen));
fhout.write((char *)(bm_rgb.rgbRed), sizeof(bm_rgb.rgbRed));
fhout.write((char *)(bm_rgb.rgbReserved), sizeof(bm_rgb.rgbReserved));
for (int h=0 ; h<bm_v5.bV5Height ; h++)
{
for (int w = 0 ; w<bm_v5.bV5Width ; w++)
{
fhout.write((char *)(bitmap[w][h]), 1);
}
}
for (int x=0 ; x<bm_v5.bV5Width ; x++)
{
delete [] bitmap[x];
delete [] bitmap;
}
fh.close();
fhout.close();
system("PAUSE");
return 0;
}