selim 2024-05-02 15:10:49 +02:00
parent 28d3d29d7d
commit b121302fcb
4 changed files with 8 additions and 4 deletions

Binary file not shown.

View File

@ -5,11 +5,11 @@ int main()
{ {
FILE *inputFile, *outputFile; FILE *inputFile, *outputFile;
char inputFileName[100], outputFileName[11]; char inputFileName[260], outputFileName[11];
char format[3]; char format[3];
unsigned int width, height, maxValue; unsigned int width, height, maxValue;
unsigned int rgbRed, rgbGreen, rgbBlue; unsigned int rgbRed, rgbGreen, rgbBlue;
float gray[10000]; float *gray;
printf("Input file name: "); printf("Input file name: ");
scanf("%s", inputFileName); scanf("%s", inputFileName);
@ -40,6 +40,9 @@ int main()
// Einlesen der Maße und des Farbbereiches von Input Datei // Einlesen der Maße und des Farbbereiches von Input Datei
fscanf(inputFile, "%d %d\n%d\n", &width, &height, &maxValue); fscanf(inputFile, "%d %d\n%d\n", &width, &height, &maxValue);
// Dynamische Speicherreservierung für gray
gray = malloc(width * height * sizeof(float));
// Ausrechnen der Graustufen für jeweilige RGB Werte mit Formel // Ausrechnen der Graustufen für jeweilige RGB Werte mit Formel
for (int i = 0; i < width * height; i++) for (int i = 0; i < width * height; i++)
{ {
@ -62,9 +65,10 @@ int main()
printf("Output file generated: output.ppm"); printf("Output file generated: output.ppm");
// Freigabe der FILE Pointer // Freigabe der FILE Pointer und des float Pointer
fclose(inputFile); fclose(inputFile);
fclose(outputFile); fclose(outputFile);
free(gray);
return 0; return 0;
} }

Binary file not shown.

View File

@ -28,7 +28,7 @@ union ReadWav
int main() int main()
{ {
char inputFileName[100]; char inputFileName[260];
printf("Input file name: "); printf("Input file name: ");
scanf("%s", inputFileName); scanf("%s", inputFileName);