From f7aafbb59687c03c91b3fe0e07a3c50d200b2e58 Mon Sep 17 00:00:00 2001 From: LukVal54 Date: Mon, 17 Nov 2025 15:41:32 +0100 Subject: [PATCH] read Width, Height, Count implementiert. Ausgelesen wird in UNSIGNED SHORT!! --- imageInput.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/imageInput.c b/imageInput.c index a1b643a..ab24492 100644 --- a/imageInput.c +++ b/imageInput.c @@ -32,6 +32,31 @@ static FILE* openFileCheckHeader(const char *path) ///dass nun der header Teil gelesen wurde und somit die nächste Funktion ab dieser Stelle weiter liest. ///NULL, wenn falscher header. // TODO Vervollständigen Sie die Funktion readImages unter Benutzung Ihrer Hilfsfunktionen +static int readWidthHeightCount(FILE *fp, unsigned int *count, unsigned int *width, unsigned int *height) +{ + unsigned short count_s; + unsigned short width_s; + unsigned short height_s; + if(fread(&count_s, sizeof(unsigned short), 1, fp) != 1) + { + return -1; + } + if(fread(&width_s, sizeof(unsigned short), 1, fp) != 1) + { + return -1; + } + if(fread(&height_s, sizeof(unsigned short), 1, fp) != 1) + { + return -1; + } + *count = (unsigned int)count_s; + *width = (unsigned int)width_s; + *height = (unsigned int)height_s; + return 0; +} +/* +readWidthHeightCount: liest die drei shorts ein, welche Hoehe, Breite und Anzahl sind. (SHORT!!) +*/ GrayScaleImageSeries *readImages(const char *path) { GrayScaleImageSeries *series = NULL;