return EINA_FALSE;
MAGIC_CHECK_END();
- if (obj->delete_me)
+ if (obj->delete_me && src)
{
- CRIT("Setting deleted object %p as image source %p", src, obj);
- abort();
+ WRN("Setting deleted object %p as image source %p", src, obj);
return EINA_FALSE;
}
- if (src->delete_me)
- {
- CRIT("Setting object %p to deleted image source %p", src, obj);
- abort();
- return EINA_FALSE;
- }
- if (!src->layer)
- {
- CRIT("No evas surface associated with source object (%p)", obj);
- abort();
- return EINA_FALSE;
- }
- if ((obj->layer && src->layer) &&
- (obj->layer->evas != src->layer->evas))
- {
- CRIT("Setting object %p from Evas (%p) from another Evas (%p)", src, src->layer->evas, obj->layer->evas);
- abort();
- return EINA_FALSE;
- }
- if (src == obj)
+ if (src)
{
- CRIT("Setting object %p as a source for itself", obj);
- abort();
- return EINA_FALSE;
+ if (src->delete_me)
+ {
+ WRN("Setting object %p to deleted image source %p", src, obj);
+ return EINA_FALSE;
+ }
+ if (!src->layer)
+ {
+ CRIT("No evas surface associated with source object (%p)", obj);
+ return EINA_FALSE;
+ }
+ if ((obj->layer && src->layer) &&
+ (obj->layer->evas != src->layer->evas))
+ {
+ CRIT("Setting object %p from Evas (%p) from another Evas (%p)", src, src->layer->evas, obj->layer->evas);
+ return EINA_FALSE;
+ }
+ if (src == obj)
+ {
+ CRIT("Setting object %p as a source for itself", obj);
+ return EINA_FALSE;
+ }
}
if (o->cur.source == src) return EINA_TRUE;
if (o->cur.file || o->cur.key)
evas_object_image_file_set(obj, NULL, NULL);
- if (src)
- {
- _proxy_set(obj, src);
- }
+ if (src) _proxy_set(obj, src);
+ else _proxy_unset(obj);
return EINA_TRUE;
}
static void _JPEGFatalErrorHandler(j_common_ptr cinfo);
static void _JPEGErrorHandler(j_common_ptr cinfo);
static void _JPEGErrorHandler2(j_common_ptr cinfo, int msg_level);
+static int _get_orientation_app0(char *app0_head, size_t remain_length);
+static int _get_orientation_app1(char *app1_head, size_t remain_length);
+static int _get_orientation(void *map, size_t length);
static Eina_Bool evas_image_load_file_head_jpeg_internal(Image_Entry *ie,
void *map,
return 0;
}
-/*! Magic number for EXIF header & App1*/
+/*! Magic number for EXIF header, App0, App1*/
static const unsigned char ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00};
+static const unsigned char JfifHeader[] = {0x4A, 0x46, 0x49, 0x46, 0x00};
+static const unsigned char JfxxHeader[] = {0x4A, 0x46, 0x58, 0x58, 0x00};
+static const unsigned char App0[] = {0xff, 0xe0};
static const unsigned char App1[] = {0xff, 0xe1};
typedef enum {
EXIF_BYTE_ALIGN_II,
} ExifByteAlign;
static int
-_get_orientation(void *map, size_t length)
+_get_orientation_app0(char *app0_head, size_t remain_length)
+{
+ unsigned int length = 0;
+ unsigned int w = 0, h = 0;
+ unsigned int format = 0;
+ unsigned int data_size = 0;
+ char *p;
+
+ /* p is appn's start pointer excluding app0 marker */
+ p = app0_head + 2;
+
+
+ length = ((*p << 8) + *(p + 1));
+
+ /* JFIF segment format */
+ if (!memcmp(p + 2, JfifHeader, sizeof (JfifHeader)))
+ {
+ format = 3;
+ w = *(p + 14);
+ h = *(p + 15);
+ }
+ else if (!memcmp(p + 2, JfxxHeader, sizeof (JfxxHeader)))
+ {
+ if (*(p + 7) == 0x11)
+ format = 1;
+ else
+ format = 3;
+ w = *(p + 8);
+ h = *(p + 9);
+ }
+
+ data_size = format * w * h;
+ p += length + data_size;
+
+ if (!memcmp(p, App1, sizeof (App1)))
+ return _get_orientation_app1(p, remain_length - (2 + length + data_size));
+ else
+ return 0;
+}
+
+static int
+_get_orientation_app1(char *app1_head, size_t remain_length)
{
char *buf;
char orientation[2];
unsigned int i, j;
int direction;
- /* open file and get 22 byte frome file */
- if (!map) return 0;
- /* 1. read 22byte */
- if (length < 22) return 0;
- buf = (char *)map;
-
- /* 2. check 2,3 bypte with APP1(0xFFE1) */
- if (memcmp(buf + 2, App1, sizeof (App1))) return 0;
+ /* start of app1 frame */
+ buf = app1_head;
- /* 3. check 6~11bype with Exif Header (0x45786966 0000) */
- if (memcmp(buf + 6, ExifHeader, sizeof (ExifHeader))) return 0;
+ /* 1. check 4~9bype with Exif Header (0x45786966 0000) */
+ if (memcmp(buf + 4, ExifHeader, sizeof (ExifHeader))) return 0;
- /* 4. get 12&13 byte get info of "II(0x4949)" or "MM(0x4d4d)" */
- /* 5. get [20]&[21] get directory entry # */
- if (!strncmp(buf + 12, "MM", 2))
+ /* 2. get 10&11 byte get info of "II(0x4949)" or "MM(0x4d4d)" */
+ /* 3. get [18]&[19] get directory entry # */
+ if (!strncmp(buf + 10, "MM", 2))
{
byte_align = EXIF_BYTE_ALIGN_MM;
- num_directory = ((*(buf + 20) << 8) + *(buf + 21));
+ num_directory = ((*(buf + 18) << 8) + *(buf + 19));
orientation[0] = 0x01;
orientation[1] = 0x12;
}
- else if (!strncmp(buf + 12, "II", 2))
+ else if (!strncmp(buf + 10, "II", 2))
{
byte_align = EXIF_BYTE_ALIGN_II;
- num_directory = ((*(buf + 21) << 8) + *(buf + 20));
+ num_directory = ((*(buf + 19) << 8) + *(buf + 18));
orientation[0] = 0x12;
orientation[1] = 0x01;
}
else return 0;
- buf = map + 22;
+ buf = app1_head + 20;
- if (length < (12 * num_directory + 22)) return 0;
+ if (remain_length < (12 * num_directory + 20)) return 0;
j = 0;
{
/*get orientation tag */
if (byte_align == EXIF_BYTE_ALIGN_MM)
- direction = *(buf+ j + 11);
+ direction = *(buf+ j + 9);
else direction = *(buf+ j + 8);
switch (direction)
{
return 0;
}
+static int
+_get_orientation(void *map, size_t length)
+{
+ char *buf;
+
+ /* open file and get 22 byte frome file */
+ if (!map) return 0;
+ /* 1. read 22byte */
+ if (length < 22) return 0;
+ buf = (char *)map;
+
+ /* 2. check 2,3 bypte with APP0(0xFFE0) or APP1(0xFFE1) */
+ if (!memcmp(buf + 2, App0, sizeof (App0)))
+ return _get_orientation_app0(buf + 2, length - 2);
+ if (!memcmp(buf + 2, App1, sizeof (App1)))
+ return _get_orientation_app1(buf + 2, length - 2);
+ return 0;
+}
+
static Eina_Bool
evas_image_load_file_head_jpeg_internal(Image_Entry *ie,
void *map, size_t length,