json_object* metadataResp = NULL;
json_object* metadata = NULL;
json_object* mdata_value = NULL;
- int channels = 1;
+ h->current_metadata->channels = 1;
metadataResp = json_tokener_parse(resp->data);
metadata = json_object_object_get(metadataResp, "Metadata");
h->current_metadata->format = 0;
if (h->current_metadata->format == 1)
- channels = 3;
+ h->current_metadata->channels = 3;
if (pnm_image.size > 0) {
free(pnm_image.data);
debug_printf_int(DEBUG, "size of pnm image", pnm_image.size);
if (h->current_metadata->depth == 1)
- h->current_metadata->bytes_per_line = channels * floor((h->current_metadata->pixels_per_line + 7) / 8);
+ h->current_metadata->bytes_per_line = h->current_metadata->channels * floor((h->current_metadata->pixels_per_line + 7) / 8);
else
- h->current_metadata->bytes_per_line = channels * h->current_metadata->pixels_per_line * h->current_metadata->depth / 8;
+ h->current_metadata->bytes_per_line = h->current_metadata->channels * h->current_metadata->pixels_per_line * h->current_metadata->depth / 8;
h->current_metadata->valid = 1;
h->current_metadata->is_last = 0;
h->current_metadata->pixels_per_line = 0;
h->current_metadata->lines = 0;
h->current_metadata->depth = 8;
+ h->current_metadata->channels = 3;
h->current_metadata->valid = 0;
h->current_metadata->scanned_all_complete = 0;
h->current_metadata->image = NULL;
enum {
RELOAD_OPTIONS = 2,
- REALOD_PARAMS = 4
+ RELOAD_PARAMS = 4
};
typedef struct {
int pixels_per_line;
int lines;
int depth;
+ int channels;
int valid;
int scanned_all_complete;
void* image;
void free_handler(handler* h);
void kds_s2000w_handler_open(const char* devicename, void** handle);
void kds_s2000w_handler_close(handler* h);
-void kds_s2000w_handler_get_option(handler* handle, int option, void* value);
+void kds_s2000w_handler_get_option(handler* handle, int option, void* value, int* info);
void kds_s2000w_handler_set_option(handler* handle, int option, void* value, int* info);
void kds_s2000w_handler_set_option_auto(int option);
void kds_s2000w_handler_start_scan(handler* h);
}
}
-void kds_s2000w_handler_get_option(handler* h, int option, void* value)
+void kds_s2000w_handler_get_option(handler* h, int option, void* value, int* info)
{
config = json_object_object_get(resp_config, "Configuration");
json_object* value_object = NULL;
value_object = json_object_object_get(config, "ColorMode");
_write_string_value(value_object, value);
- if (strcmp(value, "Color") == 0)
+ if (strcmp(value, "Color") == 0) {
h->current_metadata->format = 1;
- else
+ h->current_metadata->channels = 3;
+ } else {
h->current_metadata->format = 0;
+ h->current_metadata->channels = 1;
+ }
break;
case 5:
#ifndef KDS_S2000W_HANDLER_OPTS_H
#define KDS_S2000W_HANDLER_OPTS_H
void init_gamma_table();
-void kds_s2000w_handler_get_option(handler* h, int option, void* value);
+void kds_s2000w_handler_get_option(handler* h, int option, void* value, int* info);
void kds_s2000w_handler_set_option(handler* h, int option, void* value, int* info);
void kds_s2000w_handler_set_option_auto(int option);
#endif
\ No newline at end of file
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <math.h>
#include <sane/sane.h>
#include "kds_s2000w_option_descriptors.h"
#include "kds_s2000w_handler.h"
debug_printf(ALL, "sane_kds_s2000w_net_control_option");
handler* h = (handler*) handle;
if (action == SANE_ACTION_GET_VALUE)
- kds_s2000w_handler_get_option(h, option, value);
+ kds_s2000w_handler_get_option(h, option, value, info);
if (action == SANE_ACTION_SET_VALUE)
kds_s2000w_handler_set_option(h, option, value, info);
h->current_metadata->valid = 1;
h->current_metadata->format = 1;
h->current_metadata->is_last = 0;
- h->current_metadata->bytes_per_line = 42;
h->current_metadata->pixels_per_line = 1080;
h->current_metadata->lines = 100;
h->current_metadata->depth = 8;
ck_assert_int_eq(params.format, 1);
ck_assert_int_eq(params.last_frame, 0);
- ck_assert_int_eq(params.bytes_per_line, 42);
+ ck_assert_int_eq(params.bytes_per_line, 0);
ck_assert_int_eq(params.pixels_per_line, 1080);
ck_assert_int_eq(params.lines, 100);
ck_assert_int_eq(params.depth, 8);