summaryrefslogtreecommitdiff
path: root/weston-ivi-shell
diff options
context:
space:
mode:
authorWataru Mizuno <wmizuno@adit-jv.com>2016-08-24 10:26:12 +0900
committerWataru Mizuno <wmizuno@jp.adit-jv.com>2016-09-01 17:09:38 +0900
commit98e2d0207ffb439c2c9e9bc7a67c5eed016b75dd (patch)
treed2c2e4394b01908d1af1eef3356d3d1184624e42 /weston-ivi-shell
parent183810b051a7a194bb260ff7db6c8a59ef44d18d (diff)
downloadwayland-ivi-extension-98e2d0207ffb439c2c9e9bc7a67c5eed016b75dd.tar.gz
ivi-controller: Correction ilm_takeScreenshot surface.
When surface width is not multiple of 4, calculate padding for 24bit bmp image. Signed-off-by: Wataru Mizuno <wmizuno@adit-jv.com>
Diffstat (limited to 'weston-ivi-shell')
-rw-r--r--weston-ivi-shell/src/ivi-controller.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/weston-ivi-shell/src/ivi-controller.c b/weston-ivi-shell/src/ivi-controller.c
index 19f8ae5..b226c95 100644
--- a/weston-ivi-shell/src/ivi-controller.c
+++ b/weston-ivi-shell/src/ivi-controller.c
@@ -500,6 +500,9 @@ controller_surface_screenshot(struct wl_client *client,
int32_t col = 0;
int32_t offset = 0;
int32_t image_offset = 0;
+ int32_t i = 0;
+ int32_t padding = 0;
+ int32_t sum_padding = 0;
result = lyt->surface_get_size(ivisurf->layout_surface, &width,
&height, &stride);
@@ -533,15 +536,24 @@ controller_surface_screenshot(struct wl_client *client,
return;
}
+ /* When width is not multiple of 4, calculate padding. */
+ if (width % 4 != 0)
+ padding = (4 - ((width * 3) % 4));
+
for (row = 0; row < height; ++row) {
for (col = 0; col < width; ++col) {
- offset = row * width + col;
- image_offset = (height - row - 1) * width + col;
+ offset = (height - row - 1) * width + col;
+ image_offset = (row * width + col) * 3 + sum_padding;
- image_buffer[image_offset * 3] = buffer[offset * 4 + 2];
- image_buffer[image_offset * 3 + 1] = buffer[offset * 4 + 1];
- image_buffer[image_offset * 3 + 2] = buffer[offset * 4];
+ image_buffer[image_offset] = buffer[offset * 4 + 2];
+ image_buffer[image_offset + 1] = buffer[offset * 4 + 1];
+ image_buffer[image_offset + 2] = buffer[offset * 4];
}
+ for (i = 1; i <= padding; ++i) {
+ image_buffer[image_offset + 2 + i] = 0;
+ sum_padding++;
+ }
+
}
free(buffer);