First version out
It certainly is full of bug but the main goal is done so i'm kinda happy ^^
This commit is contained in:
		
							
								
								
									
										3
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								Makefile
									
									
									
									
									
								
							| @ -1,6 +1,7 @@ | |||||||
| .PHONY: clean, mrproper | .PHONY: clean, mrproper | ||||||
| CC = gcc | CC = gcc | ||||||
| CFLAGS = -g -Wall -Wextra -pedantic | CFLAGS = -g -Wall -Wextra -pedantic | ||||||
|  | LIBS = -lm | ||||||
|  |  | ||||||
| all: fisualizer | all: fisualizer | ||||||
|  |  | ||||||
| @ -8,7 +9,7 @@ all: fisualizer | |||||||
| 	$(CC) $(CFLAGS) -c -o $@ $< | 	$(CC) $(CFLAGS) -c -o $@ $< | ||||||
|  |  | ||||||
| fisualizer: fisualizer.o | fisualizer: fisualizer.o | ||||||
| 	$(CC) $(CFLAGS) -o $@ $+ | 	$(CC) $(CFLAGS) -o $@ $+ $(LIBS) | ||||||
|  |  | ||||||
| clean: | clean: | ||||||
| 	rm -f *.o core.* | 	rm -f *.o core.* | ||||||
|  | |||||||
							
								
								
									
										10
									
								
								fisualizer.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								fisualizer.c
									
									
									
									
									
								
							| @ -1,8 +1,10 @@ | |||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
|  | #include <string.h> | ||||||
|  | #include <math.h> | ||||||
|  |  | ||||||
| #define STB_IMAGE_WRITE_IMPLEMENTATION | #define STB_IMAGE_WRITE_IMPLEMENTATION | ||||||
| #include "stb_image_write.h" | #include "stb_image_write.h" | ||||||
| #include <string.h> |  | ||||||
|  |  | ||||||
| FILE *fd; | FILE *fd; | ||||||
| size_t file_sz; | size_t file_sz; | ||||||
| @ -12,7 +14,7 @@ char *filename_output; | |||||||
| int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||||
| { | { | ||||||
| 	argv++; | 	argv++; | ||||||
| 	while(argc--){ | 	while(--argc){ | ||||||
|  |  | ||||||
| 		const char* filename = *argv++; | 		const char* filename = *argv++; | ||||||
| 		filename_output = malloc(sizeof(char) * strlen(filename) + 8); | 		filename_output = malloc(sizeof(char) * strlen(filename) + 8); | ||||||
| @ -33,9 +35,11 @@ int main(int argc, char *argv[]) | |||||||
|  |  | ||||||
| 		canvas = calloc(256*256, sizeof(char)); | 		canvas = calloc(256*256, sizeof(char)); | ||||||
|  |  | ||||||
|  | 		double weight = (double)file_sz / 255;  | ||||||
|  |  | ||||||
| 		for (size_t i = 0; i < file_sz - 1; ++i) { | 		for (size_t i = 0; i < file_sz - 1; ++i) { | ||||||
| 			unsigned char at_pos = file_cnt[i], next_pos = file_cnt[i+1]; | 			unsigned char at_pos = file_cnt[i], next_pos = file_cnt[i+1]; | ||||||
| 			canvas[at_pos + next_pos * 256] = 255; | 			canvas[at_pos + next_pos * 256] += weight; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		stbi_write_png(strcat(filename_output, ".out.png"), 256, 256, 1, canvas, 256); | 		stbi_write_png(strcat(filename_output, ".out.png"), 256, 256, 1, canvas, 256); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user