Commit 988a91ae authored by Povilas Kanapickas's avatar Povilas Kanapickas

genesys: Write all offset calibration debug to a single file on gl843

parent 36bc1944
......@@ -3369,6 +3369,11 @@ gl843_offset_calibration (Genesys_Device * dev)
pass = 0;
// FIXME: we'll leak debug image if we encounter errors below
Genesys_Vector debug_image = sanei_gl_vector_create(1);
size_t debug_image_lines = 0;
Genesys_Vector debug_image_info = sanei_gl_vector_create(1);
/* loop until acceptable level */
while ((pass < 32)
&& ((top[0] - bottom[0] > 1)
......@@ -3394,10 +3399,13 @@ gl843_offset_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
{
char fn[30];
snprintf(fn, 30, "gl843_offset_%03d_%03d_%03d.pnm", dev->frontend.offset[0],
dev->frontend.offset[1], dev->frontend.offset[2]);
sanei_genesys_write_pnm_file(fn, second_line, bpp, channels, pixels, lines);
char title[100];
snprintf(title, 100, "lines: %d pixels_per_line: %d offsets[0..2]: %d %d %d\n",
lines, pixels,
dev->frontend.offset[0], dev->frontend.offset[1], dev->frontend.offset[2]);
sanei_gl_vector_append(&debug_image_info, title, strlen(title));
sanei_gl_vector_append(&debug_image, second_line, total_size);
debug_image_lines += lines;
}
for (i = 0; i < 3; i++)
......@@ -3421,6 +3429,18 @@ gl843_offset_calibration (Genesys_Device * dev)
}
}
}
if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_file("gl843_offset_all_desc.txt",
(uint8_t*)debug_image_info.data, debug_image_info.size);
sanei_genesys_write_pnm_file("gl843_offset_all.pnm",
(uint8_t*)debug_image.data, bpp, channels, pixels, debug_image_lines);
}
sanei_gl_vector_destroy(&debug_image);
sanei_gl_vector_destroy(&debug_image_info);
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0],
dev->frontend.offset[1], dev->frontend.offset[2]);
......
......@@ -83,6 +83,23 @@ sanei_genesys_init_cmd_set (Genesys_Device * dev)
/* General IO and debugging functions */
/* ------------------------------------------------------------------------ */
SANE_Status sanei_genesys_write_file(char *filename, uint8_t * data, size_t length)
{
FILE *out;
out = fopen (filename, "w");
if (!out) {
DBG(DBG_error, "%s: could nor open %s for writing: %s\n", __func__, filename,
strerror(errno));
return SANE_STATUS_INVAL;
}
fwrite(data, 1, length, out);
fclose(out);
DBG(DBG_proc, "%s: finished\n", __func__);
return SANE_STATUS_GOOD;
}
/* Write data to a pnm file (e.g. calibration). For debugging only */
/* data is RGB or grey, with little endian byte order */
SANE_Status
......
......@@ -1108,6 +1108,8 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, uint8_t * data,
int start_pixel, int dpi, int width,
int height);
extern SANE_Status sanei_genesys_write_file(char *filename, uint8_t* data, size_t length);
extern SANE_Status
sanei_genesys_write_pnm_file (const char *filename, uint8_t * data, int depth,
int channels, int pixels_per_line, int lines);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment