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 right = pinfo->client_offset;
|
||||||
int left = right + cols;
|
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");
|
// printf("loop\n");
|
||||||
int rowoffset = (rows-h)/2;
|
int rowoffset = (rows-h)/2;
|
||||||
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++) {
|
||||||
|
if (x<0)
|
||||||
|
continue;
|
||||||
//mvaddch(y + rowoffset, x, ('0' + x-(left-frame)+y));
|
//mvaddch(y + rowoffset, x, ('0' + x-(left-frame)+y));
|
||||||
int p = x-(left-frame);
|
int p = x-(left-frame);
|
||||||
mvaddch(y + rowoffset, x, p>=w?' ':img[y*w+p]);
|
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) {
|
if (f) {
|
||||||
while (fgets(linebuf, LINELEN, f)) {
|
while (fgets(linebuf, LINELEN, f)) {
|
||||||
int len = strlen(linebuf);
|
int len = strlen(linebuf);
|
||||||
*cols = MAX(len, *cols);
|
*cols = len>*cols?len:*cols;
|
||||||
(*rows)++;
|
(*rows)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
cols--;
|
(*cols)--;
|
||||||
ret = (char *)malloc(*cols * *rows);
|
ret = (char *)malloc(*cols * *rows + 1);
|
||||||
memset(ret, ' ', *cols * *rows);
|
memset(ret, ' ', *cols * *rows);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
for (int r=0; r<*rows; r++) {
|
for (int r=0; r<*rows; r++) {
|
||||||
fgets(&ret[r * *cols], *cols, f);
|
fgets(&ret[r * *cols], LINELEN, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
free(linebuf);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user