From 92a9d59337f5a3c303cb19c8b459904d3c9ce021 Mon Sep 17 00:00:00 2001 From: tkarrass Date: Sat, 2 Nov 2013 22:30:30 +0100 Subject: [PATCH] image reader --- Makefile | 2 +- image | 10 ++++++++++ src/display.c | 4 ++-- src/image.c | 31 +++++++++++++++++++++++++++++++ src/image.h | 12 ++++++++++++ 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 image create mode 100644 src/image.c create mode 100644 src/image.h diff --git a/Makefile b/Makefile index 5f67eb5..5cda73f 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ BIN=bin SRC=src LIBS=-lncurses TARGET=$(BIN)/netsl -OBJECTS=$(BIN)/main.o $(BIN)/msg.o $(BIN)/net.o $(BIN)/display.o +OBJECTS=$(BIN)/main.o $(BIN)/msg.o $(BIN)/net.o $(BIN)/display.o $(BIN)/image.o all: $(BIN) $(TARGET) diff --git a/image b/image new file mode 100644 index 0000000..68ce63c --- /dev/null +++ b/image @@ -0,0 +1,10 @@ + + _,-%/%| + _,-' \//%\ + _,-' \%/|% + / / ) __,-- /%\ + \__/_,-'%(% ; %)% + / %\%, %\ + / '--%' + / + diff --git a/src/display.c b/src/display.c index a120639..11982c4 100644 --- a/src/display.c +++ b/src/display.c @@ -77,9 +77,9 @@ void prntscreen(const struct message *msg, const struct prog_info *pinfo) { int left = right + cols; // printf("loop\n"); - for (int y=0; y<10; y++) { // yheight; y++) { + for (int y=0; y<50; y++) { // yheight; y++) { for (int x=left-frame; x*cols?len:*cols; + (*rows)++; + } + + cols--; + ret = (char *)malloc(*cols * *rows); + memset(ret, ' ', *cols * *rows); + fseek(f, 0, SEEK_SET); + for (int r=0; r<*rows; r++) { + fgets(&ret[r * *cols], *cols, f); + } + + fclose(f); + } + free(linebuf); + + return ret; +} diff --git a/src/image.h b/src/image.h new file mode 100644 index 0000000..4735e46 --- /dev/null +++ b/src/image.h @@ -0,0 +1,12 @@ +#ifndef __IMAGE +#define __IMAGE + +#include +#include +#include + +#define LINELEN 20000 + +char *readImage(const char* filename, int *cols, int *rows); + +#endif