file parsing
I don't think this is finished yet but it's late and not on my pc so I have to upload it now...
This commit is contained in:
parent
63332c6221
commit
ab380b4671
20
fisualizer.c
20
fisualizer.c
@ -1,15 +1,22 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
|
#include "stb_image_write.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
size_t file_sz;
|
size_t file_sz;
|
||||||
char* file_cnt;
|
unsigned char *file_cnt, *canvas;
|
||||||
|
char *filename_output;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
argv++;
|
||||||
while(argc--){
|
while(argc--){
|
||||||
|
|
||||||
const char* filename = *argv++;
|
const char* filename = *argv++;
|
||||||
|
filename_output = malloc(sizeof(char) * strlen(filename) + 8);
|
||||||
|
strcpy(filename_output, filename);
|
||||||
fd = fopen(filename, "r");
|
fd = fopen(filename, "r");
|
||||||
if(fd == NULL){
|
if(fd == NULL){
|
||||||
fprintf(stderr, "couldn't open this file: %s\n", filename);
|
fprintf(stderr, "couldn't open this file: %s\n", filename);
|
||||||
@ -24,9 +31,18 @@ int main(int argc, char *argv[])
|
|||||||
file_cnt = malloc(sizeof(char)*file_sz);
|
file_cnt = malloc(sizeof(char)*file_sz);
|
||||||
fread(file_cnt, sizeof(char), file_sz, fd);
|
fread(file_cnt, sizeof(char), file_sz, fd);
|
||||||
|
|
||||||
printf("%s\n", file_cnt);
|
canvas = calloc(256*256, sizeof(char));
|
||||||
|
|
||||||
|
for (size_t i = 0; i < file_sz - 1; ++i) {
|
||||||
|
unsigned char at_pos = file_cnt[i], next_pos = file_cnt[i+1];
|
||||||
|
canvas[at_pos + next_pos * 256] = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
stbi_write_png(strcat(filename_output, ".out.png"), 256, 256, 1, canvas, 256);
|
||||||
|
|
||||||
|
free(canvas);
|
||||||
free(file_cnt);
|
free(file_cnt);
|
||||||
|
free(filename_output);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
1724
stb_image_write.h
Normal file
1724
stb_image_write.h
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user