mdata_value = NULL;
mdata_value = json_object_object_get(metadata, "ImageSize");
- h->image->size = json_object_get_int(mdata_value);
+ h->pnm_image->size = json_object_get_int(mdata_value); // TODO
mdata_value = NULL;
mdata_value = json_object_object_get(metadata, "ImageWidth");
if (h->current_metadata->depth > 8) {
h->current_metadata->depth = 8;
- pnm_image = (blobdata*) h->image;
+ pnm_image = (blobdata*) h->pnm_image;
kds_s2000w_convert_jpg_to_pnm_with_depth(&image, pnm_image, h->current_metadata->depth);
} else {
- pnm_image = (blobdata*) h->image;
+ pnm_image = (blobdata*) h->pnm_image;
kds_s2000w_convert_jpg_to_pnm(&image, pnm_image);
}
- debug_printf_int(DEBUG, "size of pnm image", h->image->size);
+ debug_printf_int(DEBUG, "size of pnm image", h->pnm_image->size);
if (h->current_metadata->depth == 1)
h->current_metadata->bytes_per_line = h->current_metadata->channels * floor((h->current_metadata->pixels_per_line + 7) / 8);
h->current_scan_status = malloc(sizeof(scanstatus));
h->current_metadata = malloc(sizeof(metadata));
h->read_info = malloc(sizeof(readinfo));
- h->image = malloc(sizeof(imagedata));
+ h->pnm_image = malloc(sizeof(imagedata));
h->sessionid = 0;
h->state = NOTCONNECTED;
h->read_info->read_size = 0;
h->read_info->readed_bytes_per_line = 0;
h->read_info->readed_lines = 0;
- h->image->size = 0;
- h->image->data = NULL;
+ h->pnm_image->size = 0;
+ h->pnm_image->data = NULL;
return h;
}
h->current_metadata = NULL;
free(h->read_info);
h->read_info = NULL;
- free(h->image->data);
- h->image->data = NULL;
- free(h->image);
- h->image = NULL;
+ free(h->pnm_image->data);
+ h->pnm_image->data = NULL;
+ free(h->pnm_image);
+ h->pnm_image = NULL;
free(h);
h = NULL;
}
void reset_handler(handler* h)
{
debug_printf(ALL, "reset handler");
- free(h->image->data);
- h->image->data = NULL;
+ free(h->pnm_image->data);
+ h->pnm_image->data = NULL;
h->state = NOTCONNECTED;
h->current_scan_status->current_image_number = 1;
image.size = 0;
image.data = NULL;
- h->image->size = 0;
- h->image->data = NULL;
+ h->pnm_image->size = 0;
+ h->pnm_image->data = NULL;
resp = kds_s2000w_client_response_init();
int result = kds_s2000w_client_open_session(resp);
scanstatus* current_scan_status;
metadata* current_metadata;
readinfo* read_info;
- imagedata* image;
+ imagedata* pnm_image;
} handler;
handler* init_handler();
}
// last frame
- if (h->read_info->read_size >= h->image->size) {
+ if (h->read_info->read_size >= h->pnm_image->size) {
*length = 0;
h->current_metadata->is_last = 1;
// calc max length
int maxlen = max_length;
- if (h->image->size - h->read_info->read_size < max_length)
- maxlen = h->image->size - h->read_info->read_size;
+ if (h->pnm_image->size - h->read_info->read_size < max_length)
+ maxlen = h->pnm_image->size - h->read_info->read_size;
// read image
- if (h->image->data != NULL) {
- int skip_header_bytes = _sane_kds_s2000w_net_find_first_data_byte(h->image->data);
+ if (h->pnm_image->data != NULL) {
+ int skip_header_bytes = _sane_kds_s2000w_net_find_first_data_byte(h->pnm_image->data);
if (h->read_info->read_size <= 0)
h->read_info->read_size += skip_header_bytes;
}
*length = maxlen;
- memcpy(data, h->image->data + h->read_info->read_size, *length);
+ memcpy(data, h->pnm_image->data + h->read_info->read_size, *length);
h->read_info->read_size += *length;
return SANE_STATUS_GOOD;
{
int length = 0;
handler* h = init_handler();
- h->image->size = 1;
+ h->pnm_image->size = 1;
char* image = malloc(sizeof(char));
image[0] = 0;
- h->image->data = image;
- h->image->size = 0;
+ h->pnm_image->data = image;
+ h->pnm_image->size = 0;
char* dataptr = malloc(sizeof(char));
SANE_Status status = _sane_kds_s2000w_net_read(h, dataptr, 65536, &length);
h->read_info->cancel = 0;
h->read_info->read_size = 0;
h->current_metadata->format = 0;
- h->image->size = 65539;
+ h->pnm_image->size = 65539;
char* image = malloc(sizeof(char) * 65539);
for (int i = 0; i < 3; i++) {
image[i] = 0x0a;
}
image[3] = 0xff;
- h->image->data = image;
+ h->pnm_image->data = image;
SANE_Int maxlen = 65536;
char* dataptr = malloc(sizeof(char) * maxlen);
h->read_info->cancel = 0;
h->read_info->read_size = 0;
h->current_metadata->format = 0;
- h->image->size = 95003;
+ h->pnm_image->size = 95003;
char* image = malloc(sizeof(char) * 95003);
for (int i = 0; i < 3; i++) {
image[i] = 0x0a;
}
image[3] = 0xff;
- h->image->data = image;
+ h->pnm_image->data = image;
SANE_Int maxlen = 65536;
char* dataptr = malloc(sizeof(char) * maxlen);