Enlightenment CVS committal
Author : atmosphere
Project : e17
Module : apps/entice
Dir : e17/apps/entice/src/bin
Modified Files:
entice.c image.c image.h prefs.c prefs.h
Log Message:
This should fix save routines that got broken the other day
Also address creepy's issue with filesize shrinking
You can now configure the quality Imlib2 saves with via a config opt.
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/entice.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- entice.c 10 Dec 2003 06:14:29 -0000 1.24
+++ entice.c 13 Dec 2003 06:36:47 -0000 1.25
@@ -216,6 +216,8 @@
new_current = entice_image_new(tmp);
entice_image_file_set(new_current, e_thumb_file_get(o));
entice_image_format_set(new_current, e_thumb_format_get(o));
+ entice_image_save_quality_set(new_current,
+ entice_config_image_quality_get());
new_scroller =
e_thumb_new(evas_object_evas_get(o), e_thumb_file_get(o));
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/image.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -3 -r1.35 -r1.36
--- image.c 26 Nov 2003 20:15:16 -0000 1.35
+++ image.c 13 Dec 2003 06:36:47 -0000 1.36
@@ -185,16 +185,13 @@
int
entice_image_save(Evas_Object * o)
{
- int iw, ih;
- Evas_Coord w, h;
+ int iw, ih, result = 0;
Entice_Image *im = NULL;
Imlib_Image imlib_im = NULL;
if ((im = evas_object_smart_data_get(o)))
{
evas_object_image_size_get(im->obj, &iw, &ih);
- evas_object_geometry_get(o, NULL, NULL, &w, &h);
-
if ((imlib_im =
imlib_create_image_using_copied_data(iw, ih,
evas_object_image_data_get
@@ -203,16 +200,29 @@
imlib_context_set_image(imlib_im);
if (im->format && im->filename)
{
+ char *tmp = NULL;
+ Imlib_Load_Error err;
+
imlib_image_set_has_alpha((char)
evas_object_image_alpha_get(im->obj));
- imlib_image_set_format(im->format);
- imlib_save_image(im->filename);
+ imlib_image_attach_data_value("quality", NULL, im->quality, NULL);
+ if ((tmp = strrchr(im->filename, '.')))
+ imlib_image_set_format(tmp + 1);
+ imlib_save_image_with_error_return(im->filename, &err);
+ switch (err)
+ {
+ case 0:
+ result = 1;
+ break;
+ default:
+ fprintf(stderr, "Unable to save file(%d)", (int) err);
+ break;
+ }
}
imlib_free_image();
- return (1);
}
}
- return (0);
+ return (result);
}
void
@@ -389,14 +399,15 @@
if ((im = evas_object_smart_data_get(o)))
{
double wfactor, hfactor;
+
wfactor = (double) (im->iw) / (double) (im->w);
hfactor = (double) (im->ih) / (double) (im->h);
- /*
+#if 0
if (im->iw > im->ih)
im->zoom = ((double) (im->iw) / (double) im->w);
else
im->zoom = ((double) (im->ih) / (double) im->h);
- */
+#endif
im->zoom = (wfactor > hfactor ? wfactor : hfactor);
im->fit = 1;
entice_image_resize(o, im->w, im->h);
@@ -678,8 +689,7 @@
ww = (int) ((double) im->iw / im->zoom);
hh = (int) ((double) im->ih / im->zoom);
-
- /*
+#if 0
if (ww > w)
{
if (im->scroll.x > ((ww - w) / 2))
@@ -708,7 +718,7 @@
else if (im->scroll.y < -((h - hh + 1) / 2))
im->scroll.y = -((h - hh + 1) / 2);
}
- */
+#endif
evas_object_resize(im->obj, ww, hh);
evas_object_image_fill_set(im->obj, 0, 0, ww, hh);
evas_object_move(im->obj, im->scroll.x + im->x + ((im->w - ww) / 2),
@@ -816,6 +826,18 @@
if ((im = evas_object_smart_data_get(o)))
{
im->state = state;
+ }
+}
+
+void
+entice_image_save_quality_set(Evas_Object * o, int quality)
+{
+ Entice_Image *im = NULL;
+
+ if ((im = evas_object_smart_data_get(o)))
+ {
+ if ((quality >= 70) && (quality <= 100))
+ im->quality = quality;
}
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/image.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- image.h 5 Nov 2003 07:33:56 -0000 1.18
+++ image.h 13 Dec 2003 06:36:47 -0000 1.19
@@ -34,6 +34,7 @@
struct _Entice_Image
{
int fit;
+ int quality; /* int value for saving quality */
double zoom; /* the current zoom percentage */
struct
{
@@ -87,4 +88,6 @@
Evas_Coord * h);
void entice_image_x_scroll_offset_add(Evas_Object * o, Evas_Coord offset);
void entice_image_y_scroll_offset_add(Evas_Object * o, Evas_Coord offset);
+void entice_image_save_quality_set(Evas_Object * o, int quality);
+
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/prefs.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- prefs.c 30 Nov 2003 20:13:37 -0000 1.11
+++ prefs.c 13 Dec 2003 06:36:47 -0000 1.12
@@ -18,6 +18,21 @@
static void entice_config_generate_original_db(char *filename);
/**
+ * entice_config_image_quality_get - Get the image quality
+ * Returns - value should always be >= 70 and <= 100
+ */
+int
+entice_config_image_quality_get(void)
+{
+ int result = 80;
+
+ if ((econfig) && (econfig->image_quality >= 70)
+ && (econfig->image_quality <= 100))
+ result = econfig->image_quality;
+ return (result);
+}
+
+/**
* entice_config_font_cache_get - Get the font cache size in megabytes
* Returns - value should always be > 0
*/
@@ -147,6 +162,7 @@
result->theme = strdup(buf);
result->w = 320;
result->h = 240;
+ result->image_quality = 80;
}
return (result);
}
@@ -193,6 +209,9 @@
}
if (!e_db_int_get(db, "/entice/engine", &econfig->engine))
econfig->engine = SOFTWARE_X11;
+ if (!e_db_int_get
+ (db, "/entice/image_quality", &econfig->image_quality))
+ econfig->image_quality = 80;
if (e_db_int_get(db, "/entice/keys/up/count", &count))
{
@@ -295,6 +314,7 @@
e_db_int_set(db, "/entice/keys/up/count", count);
e_db_int_set(db, "/entice/cache/font", 1);
e_db_int_set(db, "/entice/cache/image", 8);
+ e_db_int_set(db, "/entice/image_quality", 80);
e_db_close(db);
e_db_flush();
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/prefs.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- prefs.h 30 Nov 2003 20:13:37 -0000 1.4
+++ prefs.h 13 Dec 2003 06:36:47 -0000 1.5
@@ -16,14 +16,17 @@
char *theme;
char *db;
int engine;
+ int image_quality;
+
struct
{
int image, font;
} cache;
int x, y, w, h;
- struct {
- Evas_List *list;
- Evas_Hash *hash;
+ struct
+ {
+ Evas_List *list;
+ Evas_Hash *hash;
} themes;
};
typedef struct _Entice_Config Entice_Config;
@@ -37,5 +40,6 @@
int entice_config_image_cache_get(void);
void entice_config_geometry_get(int *x, int *y, int *w, int *h);
void entice_config_geometry_set(int x, int y, int w, int h);
+int entice_config_image_quality_get(void);
#endif
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs