Enlightenment CVS committal
Author : titan
Project : e17
Module : apps/ephoto
Dir : e17/apps/ephoto/src/bin
Modified Files:
ephoto.h ephoto_imaging.c ephoto_main.c
Log Message:
Sepia works pretty well now, I do believe. Added a contrast formula based on
imlib2, and soon to add a brightness one.
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -3 -r1.23 -r1.24
--- ephoto.h 23 May 2007 22:02:56 -0000 1.23
+++ ephoto.h 24 May 2007 19:27:07 -0000 1.24
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
#include <time.h>
#include <unistd.h>
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_imaging.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- ephoto_imaging.c 23 May 2007 22:02:56 -0000 1.13
+++ ephoto_imaging.c 24 May 2007 19:27:07 -0000 1.14
@@ -1,7 +1,20 @@
#include "ephoto.h"
-static void rgb_to_hsv(int r, int g, int b, float *h, float *s, float *v);
-static void hsv_to_rgb(float h, float s, float v, int *r, int *g, int *b);
+#define R_CMOD(r) \
+ red[(int)(r)]
+#define G_CMOD(g) \
+ green[(int)(g)]
+#define B_CMOD(b) \
+ blue[(int)(b)] \
+/*#define A_CMOD(a) \
+ alpha[(int)(a)]*/
+
+#define A_VAL(p) ((unsigned char *)(p))[3]
+#define R_VAL(p) ((unsigned char *)(p))[2]
+#define G_VAL(p) ((unsigned char *)(p))[1]
+#define B_VAL(p) ((unsigned char *)(p))[0]
+
+static unsigned int *set_contrast(unsigned int *data, int ew, int eh, float v);
static void close_dialog(Ewl_Widget *w, void *event, void *data);
static void close_progress(Ewl_Widget *w, void *event, void *data);
@@ -10,108 +23,51 @@
static Ewl_Widget *save_win, *qseek;
-static void rgb_to_hsv(int r, int g, int b, float *h, float *s, float *v)
+static unsigned int *set_contrast(unsigned int *data, int ew, int eh, float v)
{
- int delta, min, max;
-
- max = (r + g + abs(r - g)) / 2;
- max = (max + b + abs(max - b)) / 2;
- min = (r + g - abs(r - g)) / 2;
- min = (min + b - abs(min - b)) / 2;
-
- delta = max - min;
- *v = (float)(100 * max) / 255.0;
-
- if (max != 0) *s = (float)(100 * delta) / (float)max;
-
- else
- {
- *s = 0.0;
- *h = 0.0;
- *v = 0.0;
- }
-
- if (r == max) *h = (float)(100 * (g - b)) / (float)(6.0 * delta);
-
- else
- {
- if (g == max) *h = (float)(100 * (2 * delta + b - r)) /
(float)(6.0 * delta);
- else *h = (float)(100 * (4 * delta + r - g)) / (float)(6.0 *
delta);
- }
- if (*h < 0.0) *h += 100.0;
- if (*h > 100.0) *h -= 100.0;
+ int i, val;
+ unsigned int *p;
+ unsigned char red[256], green[256], blue[256], alpha[256];
- return;
-}
-
-static void hsv_to_rgb(float h, float s, float v, int *r, int *g, int *b)
-{
- float hh, f, p, q, t;
- int i;
+ for (i = 0; i < 256; i++)
+ {
+ red[i] = (unsigned char)i;
+ green[i] = (unsigned char)i;
+ blue[i] = (unsigned char)i;
+ alpha[i] = (unsigned char)i;
+ }
+ for (i = 0; i < 256; i++)
+ {
+ val = (int)(((double)red[i] - 127) * v) + 127;
+ if (val < 0) val = 0;
+ if (val > 255) val = 255;
+ red[i] = (unsigned char)val;
+
+ val = (int)(((double)green[i] - 127) * v) + 127;
+ if (val < 0) val = 0;
+ if (val > 255) val = 255;
+ green[i] = (unsigned char)val;
+
+ val = (int)(((double)blue[i] - 127) * v) + 127;
+ if (val < 0) val = 0;
+ if (val > 255) val = 255;
+ blue[i] = (unsigned char)val;
+
+ val = (int)(((double)alpha[i] - 127) * v) + 127;
+ if (val < 0) val = 0;
+ if (val > 255) val = 255;
+ alpha[i] = (unsigned char)val;
+ }
+ for (i = 0; i < (ew * eh); i++)
+ {
+ p = &data[i];
- if (s == 0.0)
- {
- *r = (int)(((v * 255.0) / 100.0) + 0.5);
- *g = (int)(((v * 255.0) / 100.0) + 0.5);
- *b = (int)(((v * 255.0) / 100.0) + 0.5);
-
- return;
+ R_VAL(p) = R_CMOD(R_VAL(p));
+ G_VAL(p) = G_CMOD(G_VAL(p));
+ B_VAL(p) = B_CMOD(B_VAL(p));
+ // A_VAL(p) = A_CMOD(A_VAL(p));
}
-
- hh = (h * 6.0) / 100.0;
- i = floor(hh);
- f = hh - (float)i;
-
- p = v * (1.0 - s / 100.0) / 100.0;
- q = v * (1.0 - (s * f) / 100.0) / 100.0;
- t = v * (1.0 - s * (1.0 - f) / 100.0) / 100.0;
-
- switch (i)
- {
- case 0:
- {
- *r = (int)((v * 255.0 / 100.0) + 0.5);
- *g = (int)((t * 255.0) + 0.5);
- *b = (int)((p * 255.0) + 0.5);
- break;
- }
- case 1:
- {
- *r = (int)((q * 255.0) + 0.5);
- *g = (int)((v * 255.0 / 100.0) + 0.5);
- *b = (int)((p * 255.0) + 0.5);
- break;
- }
- case 2:
- {
- *r = (int)((p * 255.0) + 0.5);
- *g = (int)((v * 255.0 / 100.0) + 0.5);
- *b = (int)((t * 255.0) + 0.5);
- break;
- }
- case 3:
- {
- *r = (int)((p * 255.0) + 0.5);
- *g = (int)((q * 255.0) + 0.5);
- *b = (int)((v * 255.0 / 100.0) + 0.5);
- break;
- }
- case 4:
- {
- *r = (int)((t * 255.0) + 0.5);
- *g = (int)((p * 255.0) + 0.5);
- *b = (int)((v * 255.0 / 100.0) + 0.5);
- break;
- }
- case 5:
- {
- *r = (int)((v * 255.0 / 100.0) + 0.5);
- *g = (int)((p * 255.0) + 0.5);
- *b = (int)((q * 255.0) + 0.5);
- break;
- }
- }
- return;
+ return data;
}
unsigned int *flip_horizontal(Ewl_Widget *image)
@@ -413,27 +369,29 @@
unsigned int *sepia_image(Ewl_Widget *image)
{
- unsigned int *im_data, *im_data_new;
+ unsigned int *data, *im_data, *im_data_new;
int i, r, g, b, a, ew, eh;
float h, s, v;
- im_data = evas_object_image_data_get(EWL_IMAGE(image)->image, FALSE);
+ data = evas_object_image_data_get(EWL_IMAGE(image)->image, FALSE);
evas_object_image_size_get(EWL_IMAGE(image)->image, &ew, &eh);
im_data_new = malloc(sizeof(unsigned int) * ew * eh);
+ im_data = set_contrast(data, ew, eh, 2);
+
for (i = 0; i < (ew * eh); i++)
{
b = (int)((im_data[i]) & 0xff);
g = (int)((im_data[i] >> 8) & 0xff);
r = (int)((im_data[i] >> 16) & 0xff);
a = (int)((im_data[i] >> 24) & 0xff);
-
- rgb_to_hsv(r, g, b, &h, &s, &v);
- hsv_to_rgb(25, s, v, &r, &g, &b);
- im_data_new[i] = (a << 24) | (r << 16) | (g << 8) | b;
- }
+ evas_color_rgb_to_hsv(r, g, b, &h, &s, &v);
+ evas_color_hsv_to_rgb(35, s, v, &r, &g, &b);
+
+ im_data_new[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
return im_data_new;
}
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_main.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -3 -r1.35 -r1.36
--- ephoto_main.c 19 May 2007 16:59:09 -0000 1.35
+++ ephoto_main.c 24 May 2007 19:27:07 -0000 1.36
@@ -1,6 +1,9 @@
#include "ephoto.h"
+
+
/*Ewl Callbacks*/
+static void about_dialog(Ewl_Widget *w, void *event, void *data);
static void add_album(Ewl_Widget *w, void *event, void *data);
static void cancel(Ewl_Widget *w, void *event, void *data);
static void destroy(Ewl_Widget *w, void *event, void *data);
@@ -87,7 +90,7 @@
return;
}
-/*Cancel the Album Dialog*/
+/*Cancel the Dialog*/
static void cancel(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *win;
@@ -152,6 +155,37 @@
ewl_button_image_size_set(EWL_BUTTON(button), 25, 25);
}
+/*Add an About Dialog*/
+static void about_dialog(Ewl_Widget *w, void *event, void *data)
+{
+ Ewl_Widget *window, *button, *vbox, *text;
+
+ window = add_window("About Ephoto", 200, 100, NULL, NULL);
+ ewl_callback_append(window, EWL_CALLBACK_DELETE_WINDOW, cancel,
window);
+
+ vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 3);
+ ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL);
+
+ text = add_text(vbox, "Ephoto is an advanced image viewer that allows\n"
+ "you to view images in several methods. They\n"
+ "include an icon view, a list view, and a single\n"
+ "image view. You can also view exif data, view\n"
+ "images in a fullscreen mode, and view images in a\n"
+ "slideshow. The edit view offers simple and advanced\n"
+ "editing options including rotations, flips, blurs,\n"
+ "sharpens, conversion to black and white, and\n"
+ "conversions to sepia.");
+
+ ewl_text_wrap_set(EWL_TEXT(text), EWL_TEXT_WRAP_WORD);
+
+ button = add_button(vbox, "Close",
+ PACKAGE_DATA_DIR "/images/dialog-close.png",
+ cancel,
window);
+ ewl_button_image_size_set(EWL_BUTTON(button), 25, 25);
+
+ return;
+}
+
/*Create the Main Ephoto Window*/
void create_main_gui(void)
{
@@ -182,6 +216,11 @@
mi = add_menu_item(menu, "Add Album",
PACKAGE_DATA_DIR "/images/add.png",
add_album, NULL);
+
+ menu = add_menu(mb, "Help");
+ mi = add_menu_item(menu, "About",
+ PACKAGE_DATA_DIR "/images/stock_help.png",
+ about_dialog, NULL);
hbox = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 2);
ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL);
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs