summaryrefslogtreecommitdiff
path: root/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'cli.c')
-rw-r--r--cli.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/cli.c b/cli.c
index b0d3a1b..79225c1 100644
--- a/cli.c
+++ b/cli.c
@@ -22,7 +22,6 @@
*/
#define _GNU_SOURCE
#include <stdio.h>
-#include <png.h>
#include "device.h"
#include "utils.h"
@@ -30,13 +29,13 @@
void
cli_read_images(libusb_context *usb, struct device *device, int count,
- const char *out)
+ bool raw, const char *out)
{
device_start(device);
for (int i = 0; i < count;) {
struct image *image = device_read(device);
if (image) {
- if (image->format != IMAGE_FORMAT_XBGR32) {
+ if (!raw && image->format != IMAGE_FORMAT_XBGR32) {
struct image *cimage = image_new(image->width, image->height,
image->width * 4, IMAGE_FORMAT_XBGR32);
image_convert(cimage, image);
@@ -47,16 +46,7 @@ cli_read_images(libusb_context *usb, struct device *device, int count,
if (asprintf(&name, out, i) < 0)
utils_fatal("can not prepare file name");
utils_info("write %s", name);
- png_image pimage;
- memset(&pimage, 0, sizeof(pimage));
- pimage.version = PNG_IMAGE_VERSION;
- pimage.width = image->width;
- pimage.height = image->height;
- pimage.format = PNG_FORMAT_BGRA;
- int r = png_image_write_to_file(&pimage, name, 0,
- image->pixels, image->stride, NULL);
- if (r == 0)
- utils_fatal("can not write image: %s", pimage.message);
+ image_save(image, name);
free(name);
image_unref(image);
i++;
@@ -94,7 +84,7 @@ cli_run(struct options *options)
if (width == -1)
utils_fatal("no matching resolution");
device_set_resolution(device, width, height, 0);
- cli_read_images(usb, device, options->count, options->out);
+ cli_read_images(usb, device, options->count, options->raw, options->out);
device_close(device);
libusb_exit(usb);
return EXIT_SUCCESS;