changed for loop in line 47 of readImages()

This commit is contained in:
Jonas Hofmann 2025-11-24 20:28:13 +01:00
parent 51d02f32c2
commit 4999631b9e

View File

@ -18,7 +18,7 @@ GrayScaleImageSeries *readImages(const char *path)
{
GrayScaleImageSeries *series = NULL;
FILE *readSource = 0;
const unsigned int sizeOfStausInfoElementsInBytes = 2;
const unsigned int sizeOfStausInfoElementsInBytes = sizeof(unsigned short);
const unsigned int amountOfStatusInfoToRead = 1;
unsigned int numberOfBytesToRead = 0;
unsigned int expectedHeader = 0;
@ -41,31 +41,26 @@ GrayScaleImageSeries *readImages(const char *path)
if (expectedHeader)
{
printf("expected Header!\n");
// reallocate memory so that each image width can be saved seperately
series->images = realloc(series->images, series->count * 2 * sizeof(unsigned int) + sizeof(headerString));
printf("count: %d", series->count);
series->images[2].width = series->images->width;
series->images[2].height = series->images->height;
/*
for (int i = 0; i < series->count; i++)
// for loop was previously running with i < series->count, wich caused programm to crash.
for (int i = 0; i < 2; i++)
{
series->images[i].width = series->images->width;
series->images[i].height = series->images->height;
}
*/
printf("afer for Loop! \n");
readImagedata(readSource, series, numberOfBytesToRead);
}
else
{
series = NULL;
}
printf("before read Source\n");
fclose(readSource);
}
printf("finished reading!\n");
return series;
}