From: Bastian Dehn Date: Sun, 10 Mar 2024 14:42:27 +0000 (+0100) Subject: rename image to pnm image X-Git-Tag: v1.0.0^2~116 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=2b65ebdf6f9b4840339649fc140b2ddcd5be7c83;p=sane-kds-s2000w-net.git rename image to pnm image --- diff --git a/src/kds_s2000w_handler.c b/src/kds_s2000w_handler.c index d2379fd..866f335 100644 --- a/src/kds_s2000w_handler.c +++ b/src/kds_s2000w_handler.c @@ -42,7 +42,7 @@ void _get_current_metadata(handler* h) 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"); @@ -73,14 +73,14 @@ void _get_current_metadata(handler* h) 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); @@ -171,7 +171,7 @@ handler* init_handler() 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; @@ -193,8 +193,8 @@ handler* init_handler() 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; } @@ -208,10 +208,10 @@ void free_handler(handler* 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; } @@ -219,8 +219,8 @@ void free_handler(handler* h) 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; @@ -295,8 +295,8 @@ void kds_s2000w_handler_open(const char* devicename, void** handle) 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); diff --git a/src/kds_s2000w_handler.h b/src/kds_s2000w_handler.h index 55d6b8a..c334fbd 100644 --- a/src/kds_s2000w_handler.h +++ b/src/kds_s2000w_handler.h @@ -49,7 +49,7 @@ typedef struct { scanstatus* current_scan_status; metadata* current_metadata; readinfo* read_info; - imagedata* image; + imagedata* pnm_image; } handler; handler* init_handler(); diff --git a/src/kds_s2000w_net.c b/src/kds_s2000w_net.c index dff77be..28b4dec 100644 --- a/src/kds_s2000w_net.c +++ b/src/kds_s2000w_net.c @@ -213,7 +213,7 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data, } // 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; @@ -222,18 +222,18 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data, // 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; diff --git a/tests/kds_s2000w_net_read_tests.c b/tests/kds_s2000w_net_read_tests.c index a8a472d..bee8d41 100644 --- a/tests/kds_s2000w_net_read_tests.c +++ b/tests/kds_s2000w_net_read_tests.c @@ -58,11 +58,11 @@ START_TEST(sane_kds_s2000w_net_read_empty_image) { 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); @@ -83,13 +83,13 @@ START_TEST(sane_kds_s2000w_net_read_test) 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); @@ -118,13 +118,13 @@ START_TEST(sane_kds_s2000w_net_read_bytes_per_line_bigger_test) 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);