#include "kds_s2000w_image_converter.h"
#include "kds_s2000w_debug.h"
+#define SPACE 0x0a
+
+int _sane_kds_s2000w_net_find_first_data_byte(imagedata* image)
+{
+ debug_printf(ALL, "sane_kds_s2000w_net_find_first_data_byte");
+
+ char* data = image->data;
+ int header_spaces = 3;
+
+ if (strncmp(data, "P4", 2) == 0)
+ header_spaces = 2;
+
+ int space_count = 0;
+ int byte_count = 0;
+ for (byte_count = 0; byte_count < image->size; byte_count++) {
+ if (data[byte_count] == SPACE)
+ space_count++;
+
+ if (space_count >= header_spaces)
+ break;
+ }
+
+ byte_count++;
+ return byte_count;
+}
+
handler* init_handler()
{
debug_printf(ALL, "init handler");
{
debug_printf(ALL, "get_current_metadata");
+ h->read_info->read_size = 0;
+
params->format = 1;
params->last_frame = 1;
params->bytes_per_line = 0;
else
params->bytes_per_line = channels * params->pixels_per_line * params->depth / 8;
+ h->read_info->read_size = _sane_kds_s2000w_net_find_first_data_byte(h->image);
+
metadata = NULL;
free(mdata);
mdata = NULL;
#include "kds_s2000w_handler.h"
#include "kds_s2000w_debug.h"
-#define SPACE 0x0a
-
-int _sane_kds_s2000w_net_find_first_data_byte(imagedata* image)
-{
- debug_printf(ALL, "sane_kds_s2000w_net_find_first_data_byte");
-
- char* data = image->data;
- int header_spaces = 3;
-
- if (strncmp(data, "P4", 2) == 0)
- header_spaces = 2;
-
- int space_count = 0;
- int byte_count = 0;
- for (byte_count = 0; byte_count < image->size; byte_count++) {
- if (data[byte_count] == SPACE)
- space_count++;
-
- if (space_count >= header_spaces)
- break;
- }
-
- byte_count++;
- return byte_count;
-}
-
SANE_Status _sane_kds_s2000w_net_init(SANE_Int* version_code, SANE_Auth_Callback authorize)
{
debug_printf(ALL, "sane_kds_s2000w_net_init");
kds_s2000w_handler_get_current_metadata(h, (metadata*) params);
- h->read_info->read_size = 0;
- if (h->image->data != NULL)
- h->read_info->read_size = _sane_kds_s2000w_net_find_first_data_byte(h->image);
-
return SANE_STATUS_GOOD;
}