#include <netpbm/pnm.h>
#include <jpeglib.h>
#include "kds_s2000w_image_converter.h"
+#include "kds_s2000w_debug.h"
#define SPACE 0x0a
#define SPACE_WIDTH_HEIGHT 0x20
int _kds_s2000w_image_converter_is_pnm(blobdata* image)
{
+ kds_s2000w_debug_printf(ALL, "_kds_s2000w_image_converter_is_pnm");
+
if (image->size < 2)
return 0;
int _kds_s2000w_image_converter_is_jpeg(blobdata* image)
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_jpeg");
+
if (image->size < 2)
return 0;
int _kds_s2000w_image_converter_find_char(blobdata* image, int start, const char cfind)
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_find_char");
+
char* image_data = (char*) image->data;
for (int i = start; i < image->size; i++) {
int _kds_s2000w_image_converter_get_number_from_substring(char* data, int start, int end)
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_get_number_from_substring");
+
int number = 0;
char* number_buffer = malloc(sizeof(char) * MAXBUFFER);
void _kds_s2000w_image_converter_pnm_metadata(blobdata* image, image_metadata* mdata)
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_pnm_metadata");
+
char* image_data = (char*) image->data;
mdata->depth = 8;
void _kds_s2000w_image_converter_jpeg_metadata(blobdata* image, image_metadata* mdata)
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_jpeg_metadata");
+
FILE* jpeg_stream = fmemopen(image->data, image->size, "r");
struct jpeg_decompress_struct cinfo;
FILE* jpeg_stream,
FILE* pnm_stream)
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_color_jpg_to_pnm");
+
size_t decompress_size = RGB * cinfo->output_width * cinfo->output_height;
unsigned char* decompress_data = malloc(sizeof(unsigned char) * decompress_size);
FILE* jpeg_stream,
FILE* pnm_stream)
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_gray_jpg_to_pnm");
+
size_t decompress_size = GRAY * cinfo->output_width * cinfo->output_height;
unsigned char* decompress_data = malloc(sizeof(unsigned char) * decompress_size);
void kds_s2000w_image_converter_metadata_from_scanner_image(blobdata* image, image_metadata* mdata)
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_metadata_from_scanner_image");
+
if (image->size < 2)
return;
void kds_s2000w_image_converter_jpg_to_pnm(blobdata* in, blobdata* out, int depth)
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_jpg_to_pnm");
+
if (!_kds_s2000w_image_converter_is_jpeg(in))
return;
void kds_s2000w_image_converter_tiff_to_pnm(blobdata* in, blobdata* out)
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_tiff_to_pnm");
+
if (_kds_s2000w_image_converter_is_jpeg(in))
return;