working #1
This commit is contained in:
parent
d0d12aa0aa
commit
f9889e443a
|
@ -89,12 +89,18 @@ void prntscreen(const struct message *msg, const struct prog_info *pinfo) {
|
|||
int right = pinfo->client_offset;
|
||||
int left = right + cols;
|
||||
|
||||
// for (int y=0; y<h; y++)
|
||||
// for (int x=0; x<w; x++)
|
||||
// mvaddch(y,x,img[y*w+x]);
|
||||
|
||||
|
||||
// printf("loop\n");
|
||||
int rowoffset = (rows-h)/2;
|
||||
int coloffset = left-frame;
|
||||
for (int y=0; y<h; y++) { // y<msg->height; y++) {
|
||||
for (int x=left-frame; x<cols; x++) {
|
||||
|
||||
if (x<0)
|
||||
continue;
|
||||
//mvaddch(y + rowoffset, x, ('0' + x-(left-frame)+y));
|
||||
int p = x-(left-frame);
|
||||
mvaddch(y + rowoffset, x, p>=w?' ':img[y*w+p]);
|
||||
|
|
18
src/image.c
18
src/image.c
|
@ -20,22 +20,32 @@ char *readImage(const char* filename, int *cols, int *rows) {
|
|||
if (f) {
|
||||
while (fgets(linebuf, LINELEN, f)) {
|
||||
int len = strlen(linebuf);
|
||||
*cols = MAX(len, *cols);
|
||||
*cols = len>*cols?len:*cols;
|
||||
(*rows)++;
|
||||
}
|
||||
|
||||
cols--;
|
||||
ret = (char *)malloc(*cols * *rows);
|
||||
(*cols)--;
|
||||
ret = (char *)malloc(*cols * *rows + 1);
|
||||
memset(ret, ' ', *cols * *rows);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
for (int r=0; r<*rows; r++) {
|
||||
fgets(&ret[r * *cols], *cols, f);
|
||||
fgets(&ret[r * *cols], LINELEN, f);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
free(linebuf);
|
||||
|
||||
printf("image size: %d x %d\n", *cols, *rows);
|
||||
|
||||
for (int y=0; y < *rows; y++) {
|
||||
for (int x=0; x < *cols; x++) {
|
||||
//mvaddch(y,x,img[y * *cols +x]);
|
||||
printf("%c", ret[y * *cols +x]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user