Ok, habe ich die Lösung selbst gefunden (Ich hatte einige Fehler in MALLOC und in der Lange der Tabelle gemacht).
Für die die interessiert sind :
(Vorsicht ! Gültig nur für 24 BMP, 1024*1024)
#include
#include
#include // to use malloc (memory allocation)
//#include // to work with BMP
#define PHOTOBW „C:\C+±Programme\Guilhem_Martin\test01.bmp“
// TEST SEEMS OK FOR ENTIRE WHITE FUNCTION OR ENTIRE BLACK FUNCTION
#define PHOTOBW2 „C:\C+±Programme\Guilhem_Martin\halfblack_halfwhite_totest_coordinatesystem_and_getlev.bmp“
#define PHOTOBW3 „C:\C+±Programme\Guilhem_Martin\halfblack_halfwhite_reverse.bmp“
#define PHOTOBW4 „C:\C+±Programme\Guilhem_Martin\wasser486bmp10241024_centered_worked_b2.bmp“
void main()
{
FILE *pFile; // Pointer to the image file to process (to extract the drop profile from)
// unsigned short int* table_to_fill; // half black half white
// unsigned short int* frame; // The frame is supposed to store only image data (and not header information)
unsigned char * frame_total; // The frame is supposed to store the whole image file
unsigned char * frame_intensity; // (R+G+B)/3
// unsigned short int * frame_pixel; // Compute the R+G+B for one pixel
int n_frame; //long n_frame;
//unsigned short int lSize; // Causes error by execution
long lSize; // Size of the file to analyse (including both image and header data)
int number_of_element_read;
int offset_image;
int n_frame2=0;
// Notice !
// lSize : length of the file in bytes (8bits) :
// For instance 32 bits for lSize is 4 bytes
// buffer defined as (unsigned) short int (16bits ou 2 bytes)
//************OPENING AND SETTING UP FILE POINTER************//
//** fopen returns a pointer to the file, Opening the file in binary mode
//** Variables to be passed in parameter for fread
//** lSize : same size as the one displayed in the property dialog in the explorer
if((pFile=fopen(PHOTOBW4,„rb“))==0) printf(„Open file failed\n“); // Read only Opening BMP file
fseek (pFile , 0 , SEEK_END); // obtain file size
lSize = ftell (pFile);
rewind (pFile); // Replace the pointer to the beginning of the file
// fseek (pFile,55,SEEK_SET); // Place the cursor to the beginning of BMP data (54 bytes are designed for the header)
fseek (pFile,10,SEEK_SET);
printf(„offset_image = %d \n“,offset_image=fgetc(pFile));
fseek (pFile,offset_image,SEEK_SET);
//mybmp=pFile;//mybmp//biBitCount
frame_total = (unsigned char*) malloc (3 * 1024 * 1024 * sizeof(unsigned char)); // allocate memory to contain the whole file.
frame_intensity = (unsigned char*) malloc (1024 * 1024 * sizeof(unsigned char));
if(frame_total == NULL)
{
printf(„Error by buffer allocation \n“);
exit (2);
}
number_of_element_read=fread (frame_total,1,3 * 1024 * 1024 * sizeof(unsigned char),pFile); // copy the file into the buffer. The whole file is loaded in the buffer.
// 3*1024*1024 = 3145728
printf(„FREAD VALUE IS : %d \n“,number_of_element_read);
printf(„FREAD/3 VALUE IS : %d \n“,number_of_element_read/3);
//printf("%d %d %d \n",frame_total[0],frame_total[1],frame_total[2]);
//printf("%d %d %d \n",frame_total[3069],frame_total[3070],frame_total[3071]);
// frame_total[3069]=(frame_total[3070]+frame_total[3071])/2-58; Ca ca marche
/*
for(n_frame=0;n_frame[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]