image.c: use MAX
This commit is contained in:
parent
aec66da3b1
commit
556189ee3a
|
@ -46,7 +46,7 @@ statisch nichts print_current_image(konstant struktur message* msg, zahl start,
|
||||||
void prntscreen(const struct message *msg, const struct prog_info *pinfo);
|
void prntscreen(const struct message *msg, const struct prog_info *pinfo);
|
||||||
|
|
||||||
void callback(const struct message *msg, const struct prog_info *pinfo) {
|
void callback(const struct message *msg, const struct prog_info *pinfo) {
|
||||||
// printf("in callback, tst=%d\n", msg->timestamp);
|
//printf("in callback, tst=%d\n", msg->timestamp);
|
||||||
|
|
||||||
// calculate the actual offset to use
|
// calculate the actual offset to use
|
||||||
//int start = msg->timestamp % msg->width + pinfo->client_offset;
|
//int start = msg->timestamp % msg->width + pinfo->client_offset;
|
||||||
|
|
10
src/image.c
10
src/image.c
|
@ -1,5 +1,12 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/param.h> // MAX
|
||||||
|
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
|
||||||
|
#define LINELEN 20000
|
||||||
|
|
||||||
char *readImage(const char* filename, int *cols, int *rows) {
|
char *readImage(const char* filename, int *cols, int *rows) {
|
||||||
|
|
||||||
FILE *f = fopen(filename, "r");
|
FILE *f = fopen(filename, "r");
|
||||||
|
@ -11,7 +18,7 @@ char *readImage(const char* filename, int *cols, int *rows) {
|
||||||
if (!f) {
|
if (!f) {
|
||||||
while (fgets(linebuf, LINELEN, f)) {
|
while (fgets(linebuf, LINELEN, f)) {
|
||||||
int len = strlen(linebuf);
|
int len = strlen(linebuf);
|
||||||
*cols = len>*cols?len:*cols;
|
*cols = MAX(len, *cols);
|
||||||
(*rows)++;
|
(*rows)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,3 +36,4 @@ char *readImage(const char* filename, int *cols, int *rows) {
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
#ifndef __IMAGE
|
#ifndef __IMAGE
|
||||||
#define __IMAGE
|
#define __IMAGE
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define LINELEN 20000
|
|
||||||
|
|
||||||
char *readImage(const char* filename, int *cols, int *rows);
|
char *readImage(const char* filename, int *cols, int *rows);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user