Skip to content

Commit bee8d37

Browse files
committed
Use the correct stride when writing png screenshot
1 parent 9d69e52 commit bee8d37

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

base/cvd/cuttlefish/host/frontend/webrtc/screenshot_handler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ Result<void> PngScreenshot(std::shared_ptr<VideoFrameBuffer> frame,
5959
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
6060
});
6161

62+
png_init_io(png_ptr, outfile);
63+
6264
// Set header info
6365
png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB,
6466
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
6567
PNG_FILTER_TYPE_BASE);
6668

67-
png_init_io(png_ptr, outfile);
68-
6969
png_write_info(png_ptr, info_ptr);
7070

7171
for (int y = 0; y < height; ++y) {
72-
png_write_row(png_ptr, rgb_frame.data() + y * height);
72+
png_write_row(png_ptr, rgb_frame.data() + y * width * 3);
7373
}
7474

7575
// Finalize

0 commit comments

Comments
 (0)