first test now working, second test causes programm to fail
This commit is contained in:
parent
6189a5aa1e
commit
9d913f80f9
58
imageInput.c
58
imageInput.c
@ -26,15 +26,34 @@ GrayScaleImageSeries *readImages(const char *path)
|
||||
const unsigned int amountOfStatusInfoToRead = 1;
|
||||
char headerString[sizeof("__info2_image_file_format__\0")] = "";
|
||||
|
||||
/*
|
||||
char curChar = 0;
|
||||
int i = 0;
|
||||
*/
|
||||
|
||||
//speicher allocaten weil *series auf null zeigt !!!!!!!!
|
||||
|
||||
readSource = fopen(path, "rb");
|
||||
|
||||
if (readSource != NULL)
|
||||
{
|
||||
|
||||
series = calloc(sizeof(GrayScaleImageSeries), amountOfStatusInfoToRead);
|
||||
series->images = calloc(sizeof(GrayScaleImage), amountOfStatusInfoToRead);
|
||||
/*
|
||||
// print entire source char by char
|
||||
do
|
||||
{
|
||||
curChar = fgetc(readSource);
|
||||
printf("%x ", curChar);
|
||||
if (i >= 9)
|
||||
{
|
||||
printf("\n");
|
||||
i = 0;
|
||||
}
|
||||
i++;
|
||||
} while (curChar != EOF);
|
||||
// print entire source char by char
|
||||
*/
|
||||
series = calloc(sizeof(unsigned int) + 3* sizeof(headerString), amountOfStatusInfoToRead);
|
||||
series->images = calloc(2*sizeof(unsigned int) + sizeof(headerString), amountOfStatusInfoToRead);
|
||||
|
||||
numberOfBytesToRead = readStatusInfo(readSource, headerString, &(series->count), &(series->images->width), &(series->images->height), amountOfStatusInfoToRead);
|
||||
|
||||
@ -42,10 +61,11 @@ GrayScaleImageSeries *readImages(const char *path)
|
||||
series->labels = calloc((series->count), sizeof(&(series->labels)));
|
||||
|
||||
readImagedata(readSource, series->images->buffer, series->labels, series->count, numberOfBytesToRead);
|
||||
|
||||
}
|
||||
|
||||
fclose(readSource);
|
||||
|
||||
printf("hier\n");
|
||||
|
||||
return series;
|
||||
}
|
||||
@ -73,10 +93,11 @@ void clearSeries(GrayScaleImageSeries *series)
|
||||
// AND write NULL into every pointer
|
||||
// so they can't be accessed
|
||||
free(series->images->buffer);
|
||||
free(series->labels);
|
||||
series->images->buffer = NULL;
|
||||
series->images = NULL;
|
||||
free(series->labels);
|
||||
series->labels = NULL;
|
||||
free(series->images);
|
||||
series->images = NULL;
|
||||
free(series);
|
||||
series = NULL;
|
||||
|
||||
@ -87,25 +108,25 @@ void clearSeries(GrayScaleImageSeries *series)
|
||||
unsigned int readStatusInfo(FILE *source, char *const headerString, unsigned int *const imageCount, unsigned int *const imageWidth, unsigned int *const imageHeight, int const amountToRead)
|
||||
{
|
||||
unsigned int bytesToRead = 0;
|
||||
/*
|
||||
int numred = 0;
|
||||
int numred2 = 0;
|
||||
int numred3 = 0;
|
||||
int numred4 = 0;
|
||||
*/
|
||||
|
||||
//unsigned int imageCountBuffer = 0;
|
||||
|
||||
*imageCount = 0;
|
||||
*imageWidth = 0;
|
||||
*imageHeight = 0;
|
||||
|
||||
numred = fread(headerString, sizeof("__info2_image_file_format__\0"), 1, source);
|
||||
numred2 = fread(imageCount, sizeof(unsigned int), 1, source);
|
||||
numred3 = fread(imageWidth, sizeof(unsigned int), 1, source);
|
||||
numred4 = fread(imageHeight, sizeof(unsigned int), 1, source);
|
||||
|
||||
*imageCount = 2;
|
||||
fread(headerString, 27, 1, source);
|
||||
fread(imageCount, 2, 1, source);
|
||||
fread(imageWidth, 2, 1, source);
|
||||
fread(imageHeight, 2, 1, source);
|
||||
|
||||
bytesToRead = (*imageWidth) * (*imageHeight);
|
||||
|
||||
printf("hier\n");
|
||||
/*
|
||||
printf("imgCntBuffer: %u\n", imageCountBuffer);
|
||||
*imageCount = imageCountBuffer;
|
||||
|
||||
printf("numred: %d\n", numred);
|
||||
printf("stringsize: %lld\n", sizeof("__info2_image_file_format__"));
|
||||
printf("string: %send\n", headerString);
|
||||
@ -116,6 +137,7 @@ unsigned int readStatusInfo(FILE *source, char *const headerString, unsigned int
|
||||
printf("numred4: %d\n", numred4);
|
||||
printf("height %u\n", *imageHeight);
|
||||
printf("bytes to read = %u\n", bytesToRead);
|
||||
*/
|
||||
return bytesToRead;
|
||||
}
|
||||
|
||||
|
||||
@ -1 +0,0 @@
|
||||
some_tag
|
||||
Loading…
x
Reference in New Issue
Block a user