Added parameter to take screenshot with screendump as PNG

Currently screendump only supports PPM format, which is un-compressed. Added
a "format" parameter to QMP and HMP screendump command to support PNG image
capture using libpng.

QMP example usage:
{ "execute": "screendump", "arguments": { "filename": "/tmp/image",
"format":"png" } }

HMP example usage:
screendump /tmp/image -f png

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/718

Signed-off-by: Kshitij Suri <kshitij.suri@nutanix.com>

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20220408071336.99839-3-kshitij.suri@nutanix.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Kshitij Suri 2022-04-08 07:13:35 +00:00 committed by Gerd Hoffmann
parent 95f8510ef4
commit 9a0a119a38
4 changed files with 136 additions and 12 deletions

View file

@ -157,12 +157,27 @@
##
{ 'command': 'expire_password', 'boxed': true, 'data': 'ExpirePasswordOptions' }
##
# @ImageFormat:
#
# Supported image format types.
#
# @png: PNG format
#
# @ppm: PPM format
#
# Since: 7.1
#
##
{ 'enum': 'ImageFormat',
'data': ['ppm', 'png'] }
##
# @screendump:
#
# Write a PPM of the VGA screen to a file.
# Capture the contents of a screen and write it to a file.
#
# @filename: the path of a new PPM file to store the image
# @filename: the path of a new file to store the image
#
# @device: ID of the display device that should be dumped. If this parameter
# is missing, the primary display will be used. (Since 2.12)
@ -171,6 +186,8 @@
# parameter is missing, head #0 will be used. Also note that the head
# can only be specified in conjunction with the device ID. (Since 2.12)
#
# @format: image format for screendump. (default: ppm) (Since 7.1)
#
# Returns: Nothing on success
#
# Since: 0.14
@ -183,7 +200,8 @@
#
##
{ 'command': 'screendump',
'data': {'filename': 'str', '*device': 'str', '*head': 'int'},
'data': {'filename': 'str', '*device': 'str', '*head': 'int',
'*format': 'ImageFormat'},
'coroutine': true }
##