buggy image output

This commit is contained in:
tkarrass 2013-11-03 13:13:48 +01:00
parent 9a0995dbd0
commit d0d12aa0aa
2 changed files with 15 additions and 12 deletions

View File

@ -66,6 +66,16 @@ void prntscreen(const struct message *msg, const struct prog_info *pinfo) {
static char *img = NULL; static char *img = NULL;
static int w; static int w;
static int h; static int h;
if (!img && msg->image) {
img = msg->image;
w = msg->width;
h = msg->height;
}
if (!img) {
printf("awaiting state ... %d\r", msg->timestamp);
return;
}
if (!init) { if (!init) {
// printf("init start\n"); // printf("init start\n");
initscr(); initscr();
@ -74,14 +84,6 @@ void prntscreen(const struct message *msg, const struct prog_info *pinfo) {
init = 1; init = 1;
// printf("init end\n"); // printf("init end\n");
} }
if (!img && msg->image) {
img = msg->image;
w = msg->width;
h = msg->height;
}
if (!img)
return;
int frame = msg->timestamp; int frame = msg->timestamp;
int right = pinfo->client_offset; int right = pinfo->client_offset;
@ -92,8 +94,10 @@ void prntscreen(const struct message *msg, const struct prog_info *pinfo) {
int coloffset = left-frame; int coloffset = left-frame;
for (int y=0; y<h; y++) { // y<msg->height; y++) { for (int y=0; y<h; y++) { // y<msg->height; y++) {
for (int x=left-frame; x<cols; x++) { for (int x=left-frame; x<cols; x++) {
mvaddch(y + rowoffset, x, ('0' + x-(left-frame)+y)); //mvaddch(y + rowoffset, x, ('0' + x-(left-frame)+y));
int p = x-(left-frame);
mvaddch(y + rowoffset, x, p>=w?' ':img[y*w+p]);
} }
} }

View File

@ -78,7 +78,6 @@ int run_server(const struct prog_info *pinfo, char *img, int w, int h) {
for (;;) { for (;;) {
//printf("sending...\n"); //printf("sending...\n");
int numbytes; int numbytes;
// TODO: Hier den Messageblock erstellen und serialisieren.
t++; t++;
t %= pinfo->width; t %= pinfo->width;
@ -99,7 +98,7 @@ int run_server(const struct prog_info *pinfo, char *img, int w, int h) {
if ((numbytes = sendto(sockfd, outbuf, buflen, 0, p->ai_addr, p->ai_addrlen)) == -1) { if ((numbytes = sendto(sockfd, outbuf, buflen, 0, p->ai_addr, p->ai_addrlen)) == -1) {
perror("error sending"); perror("error sending");
return -44; return -42;
} }
nanosleep(&tim, NULL); nanosleep(&tim, NULL);
} }