diff options
-rw-r--r-- | src/tbm_surface_internal.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index 659b19e..a9da5a1 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -1767,7 +1767,7 @@ _tbm_surface_internal_dump_file_raw(const char *file, void *data1, int size1, } static void -_tbm_surface_internal_dump_file_png(const char *file, const void *data, int width, int height, int format) +_tbm_surface_internal_dump_file_png(const char *file, const void *data, int width, int height, int stride, int format) { unsigned int *blocks = (unsigned int *)data; FILE *fp; @@ -1848,7 +1848,7 @@ _tbm_surface_internal_dump_file_png(const char *file, const void *data, int widt row_pointers[y] = (png_bytep)row; for (x = 0; x < width; ++x) { - unsigned int curBlock = blocks[y * width + x]; + unsigned int curBlock = blocks[(y * (stride >> 2)) + x]; if (pixel_size == 3) { // XRGB8888 row[x * pixel_size] = (curBlock & 0xFF); @@ -2019,12 +2019,16 @@ tbm_surface_internal_dump_end(void) case TBM_FORMAT_ARGB8888: _tbm_surface_internal_dump_file_png(file, bo_handle.ptr, buf_info->info.planes[0].stride >> 2, - buf_info->info.height, TBM_FORMAT_ARGB8888); + buf_info->info.height, + buf_info->info.planes[0].stride, + TBM_FORMAT_ARGB8888); break; case TBM_FORMAT_XRGB8888: _tbm_surface_internal_dump_file_png(file, bo_handle.ptr, buf_info->info.planes[0].stride >> 2, - buf_info->info.height, TBM_FORMAT_XRGB8888); + buf_info->info.height, + buf_info->info.planes[0].stride, + TBM_FORMAT_XRGB8888); break; case TBM_FORMAT_YVU420: case TBM_FORMAT_YUV420: @@ -2059,7 +2063,8 @@ tbm_surface_internal_dump_end(void) } else if (buf_info->dirty_shm) _tbm_surface_internal_dump_file_png(file, bo_handle.ptr, buf_info->shm_stride >> 2, - buf_info->shm_h, 0); + buf_info->shm_h, + buf_info->shm_stride, 0); tbm_bo_unmap(buf_info->bo); tbm_bo_unref(buf_info->bo); @@ -2495,13 +2500,17 @@ tbm_surface_internal_capture_buffer(tbm_surface_h surface, const char *path, con switch (info.format) { case TBM_FORMAT_ARGB8888: _tbm_surface_internal_dump_file_png(file, info.planes[0].ptr, - info.planes[0].stride >> 2, - info.height, TBM_FORMAT_ARGB8888); + info.width, + info.height, + info.planes[0].stride, + TBM_FORMAT_ARGB8888); break; case TBM_FORMAT_XRGB8888: _tbm_surface_internal_dump_file_png(file, info.planes[0].ptr, - info.planes[0].stride >> 2, - info.height, TBM_FORMAT_XRGB8888); + info.width, + info.height, + info.planes[0].stride, + TBM_FORMAT_XRGB8888); break; case TBM_FORMAT_YVU420: case TBM_FORMAT_YUV420: @@ -2564,7 +2573,7 @@ tbm_surface_internal_capture_shm_buffer(void *ptr, int w, int h, int stride, return 0; } - _tbm_surface_internal_dump_file_png(file, ptr, w, h, 0); + _tbm_surface_internal_dump_file_png(file, ptr, w, h, stride, 0); TBM_TRACE_SURFACE_INTERNAL("Capture %s \n", file); |