Enlightenment CVS committal Author : cedric Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/modules/loaders/eet Modified Files: evas_image_load_eet.c Log Message: * Make RGBA_IMAGE_HAS_ALPHA and RGBA_IMAGE_ALPHA_SPARSE part of Image_Entry flag structure. This fix a bug with 16 bpp software engine. * Change image loader module API to take any Image_Entry. Same goes for evas_common_image_premul and evas_common_image_set_alpha_sparse. * Use new eet API: eet_data_image_read_to_surface. =================================================================== RCS file: /cvs/e/e17/libs/evas/src/modules/loaders/eet/evas_image_load_eet.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- evas_image_load_eet.c 12 Apr 2008 00:32:29 -0000 1.10 +++ evas_image_load_eet.c 3 Jun 2008 09:09:38 -0000 1.11 @@ -8,8 +8,8 @@ #include "evas_private.h" -int evas_image_load_file_head_eet(RGBA_Image *im, const char *file, const char *key); -int evas_image_load_file_data_eet(RGBA_Image *im, const char *file, const char *key); +int evas_image_load_file_head_eet(Image_Entry *ie, const char *file, const char *key); +int evas_image_load_file_data_eet(Image_Entry *ie, const char *file, const char *key); Evas_Image_Load_Func evas_image_load_eet_func = { @@ -19,73 +19,63 @@ int -evas_image_load_file_head_eet(RGBA_Image *im, const char *file, const char *key) +evas_image_load_file_head_eet(Image_Entry *ie, const char *file, const char *key) { int alpha, compression, quality, lossy; unsigned int w, h; Eet_File *ef; int ok; + int res = 0; if ((!file) || (!key)) return 0; ef = eet_open((char *)file, EET_FILE_MODE_READ); if (!ef) return 0; - ok = eet_data_image_header_read(ef, (char *)key, + ok = eet_data_image_header_read(ef, key, &w, &h, &alpha, &compression, &quality, &lossy); - if (!ok) - { - eet_close(ef); - return 0; - } - if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192)) - { - eet_close(ef); - return 0; - } - if (alpha) im->flags |= RGBA_IMAGE_HAS_ALPHA; - im->cache_entry.w = w; - im->cache_entry.h = h; + if (!ok) goto on_error; + if (alpha) ie->flags.alpha = 1; + ie->w = w; + ie->h = h; + res = 1; + + on_error: eet_close(ef); - return 1; + return res; } int -evas_image_load_file_data_eet(RGBA_Image *im, const char *file, const char *key) +evas_image_load_file_data_eet(Image_Entry *ie, const char *file, const char *key) { unsigned int w, h; - int alpha, compression, quality, lossy; + int alpha, compression, quality, lossy, ok; Eet_File *ef; DATA32 *body, *p, *end; DATA32 nas = 0; + int res = 0; if ((!file) || (!key)) return 0; - if (im->image.data) return 1; - ef = eet_open((char *)file, EET_FILE_MODE_READ); + if (ie->flags.loaded) return 1; + ef = eet_open(file, EET_FILE_MODE_READ); if (!ef) return 0; - body = eet_data_image_read(ef, (char *)key, - &w, &h, &alpha, &compression, &quality, &lossy); - if (!body) - { - eet_close(ef); - return 0; - } - if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192)) - { - free(body); - eet_close(ef); - return 0; - } - if (alpha) im->flags |= RGBA_IMAGE_HAS_ALPHA; - im->cache_entry.w = w; - im->cache_entry.h = h; - im->image.data = body; - im->image.no_free = 0; + ok = eet_data_image_header_read(ef, key, + &w, &h, &alpha, &compression, &quality, &lossy); + if (!ok) goto on_error; + evas_cache_image_surface_alloc(ie, w, h); + ok = eet_data_image_read_to_surface(ef, key, 0, 0, + evas_cache_image_pixels(ie), w, h, w * 4, + &alpha, &compression, &quality, &lossy); + if (!ok) goto on_error; if (alpha) { + ie->flags.alpha = 1; + + body = evas_cache_image_pixels(ie); + end = body +(w * h); for (p = body; p < end; p++) { DATA32 r, g, b, a; - + a = A_VAL(p); r = R_VAL(p); g = G_VAL(p); @@ -96,13 +86,16 @@ if (b > a) b = a; *p = ARGB_JOIN(a, r, g, b); } - if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (im->cache_entry.w * im->cache_entry.h)) - im->flags |= RGBA_IMAGE_ALPHA_SPARSE; + if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h)) + ie->flags.alpha_sparse = 1; } -// result is already premultiplied now if u compile with edje +// result is already premultiplied now if u compile with edje // evas_common_image_premul(im); + res = 1; + + on_error: eet_close(ef); - return 1; + return res; } EAPI int ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs