Unbreak raw encoding

pull/13/head
Andri Yngvason 2020-01-19 21:31:55 +00:00
parent aa917decf3
commit 4e919c69ce
1 changed files with 21 additions and 12 deletions

View File

@ -27,11 +27,20 @@ int raw_encode_box(struct vec* dst, const struct rfb_pixel_format* dst_fmt,
uint32_t* b = fb->addr; uint32_t* b = fb->addr;
int bytes_per_pixel = dst_fmt->depth / 8; int bpp = dst_fmt->bits_per_pixel / 8;
for (int y = y_start; y < y_start + height; ++y) rc = vec_reserve(dst, width * height * bpp + dst->len);
pixel32_to_cpixel(dst->data, dst_fmt, b + y * stride, src_fmt, if (rc < 0)
bytes_per_pixel, width); return -1;
uint8_t* d = dst->data;
for (int y = y_start; y < y_start + height; ++y) {
pixel32_to_cpixel(d + dst->len, dst_fmt,
b + x_start + y * stride, src_fmt,
bpp, width);
dst->len += width * bpp;
}
return 0; return 0;
} }
@ -55,7 +64,7 @@ int raw_encode_frame(struct vec* dst, const struct rfb_pixel_format* dst_fmt,
.n_rects = htons(n_rects), .n_rects = htons(n_rects),
}; };
rc = vec_reserve(dst, src->width * src->height * 4 + 256); rc = vec_reserve(dst, src->width * src->height * 4);
if (rc < 0) if (rc < 0)
return -1; return -1;