#include "kds_s2000w_image_converter.h"
#include "kds_s2000w_debug.h"
+int _kds_s2000w_image_converter_is_tiff(blobdata* image)
+{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_tiff");
+
+ if (image->size < 4)
+ return 0;
+
+ char* image_data = (char*) image->data;
+
+ int result = image_data[0] == (char)0x49;
+ result = result && image_data[1] == (char)0x49;
+ result = result && image_data[2] == (char)0x2A;
+ return result && image_data[3] == (char)0x00;
+}
+
int _kds_s2000w_image_converter_is_pnm(blobdata* image)
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_pnm");
int _kds_s2000w_image_converter_is_jpeg(blobdata* image)
{
- kds_s2000w_debug_printf(ALL, "_kds_s2000w_image_converter_is_jpeg");
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_jpeg");
if (image->size < 2)
return 0;
- const char first_byte = 0xff;
- const char second_byte = 0xd8;
-
char* image_data = (char*) image->data;
- return image_data[0] == first_byte && image_data[1] == second_byte;
+
+ int result = image_data[0] == (char)0xff;
+ return result && image_data[1] == (char)0xd8;
}
+
void _kds_s2000w_image_converter_to_pnm_depth(blobdata* in,
blobdata* out,
int depth,
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_convert_tiff_to_pnm");
- if (_kds_s2000w_image_converter_is_jpeg(in))
+ if (!_kds_s2000w_image_converter_is_tiff(in))
return;
_kds_s2000w_image_converter_to_pnm_depth(in, out, -1, "tiff");
#define RGB 3
#define GRAY 1
+int _kds_s2000w_image_converter_is_tiff(blobdata* image)
+{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_tiff");
+
+ if (image->size < 4)
+ return 0;
+
+ char* image_data = (char*) image->data;
+
+ int result = image_data[0] == (char)0x49;
+ result = result && image_data[1] == (char)0x49;
+ result = result && image_data[2] == (char)0x2A;
+ return result && image_data[3] == (char)0x00;
+}
+
int _kds_s2000w_image_converter_is_pnm(blobdata* image)
{
- kds_s2000w_debug_printf(ALL, "_kds_s2000w_image_converter_is_pnm");
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_pnm");
if (image->size < 2)
return 0;
if (image->size < 2)
return 0;
- const char first_byte = 0xff;
- const char second_byte = 0xd8;
-
char* image_data = (char*) image->data;
- return image_data[0] == first_byte && image_data[1] == second_byte;
+
+ int result = image_data[0] == (char)0xff;
+ return result && image_data[1] == (char)0xd8;
}
int _kds_s2000w_image_converter_find_char(blobdata* image, int start, const char cfind)
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_tiff_to_pnm");
- if (_kds_s2000w_image_converter_is_jpeg(in))
+ if (!_kds_s2000w_image_converter_is_tiff(in))
return;
return;