Sepia speedups and fixes. Sepia is tons better now.

SVN revision: 30075
This commit is contained in:
titan 2007-05-25 20:55:53 +00:00 committed by titan
parent 2515a4b4ba
commit 267def29ac
2 changed files with 85 additions and 19 deletions

View File

@ -16,6 +16,8 @@ static void image_blur(Ewl_Widget *w, void *event, void *data);
static void image_sharpen(Ewl_Widget *w, void *event, void *data);
static void image_grayscale(Ewl_Widget *w, void *event, void *data);
static void image_sepia(Ewl_Widget *w, void *event, void *data);
//static void close_channel(Ewl_Widget *w, void *event, void *data);
//static void channel_mixer(Ewl_Widget *w, void *event, void *data);
/*Add the edit view*/
Ewl_Widget *add_edit_view(Ewl_Widget *c)
@ -89,37 +91,37 @@ static void add_standard_edit_tools(Ewl_Widget *c)
Ewl_Widget *button;
button = add_button(c, "Zoom In", PACKAGE_DATA_DIR "/images/search.png", zoom_in, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
button = add_button(c, "Zoom Out", PACKAGE_DATA_DIR "/images/search.png", zoom_out, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
//button = add_button(c, "Zoom 1:1", PACKAGE_DATA_DIR "/images/search.png", zoom_full, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
button = add_button(c, "Rotate Left", PACKAGE_DATA_DIR "/images/undo.png", rotate_image_left, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
button = add_button(c, "Rotate Right", PACKAGE_DATA_DIR "/images/redo.png", rotate_image_right, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
button = add_button(c, "Flip Horizontally", PACKAGE_DATA_DIR "/images/go-next.png", flip_image_horizontal, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
button = add_button(c, "Flip Vertically", PACKAGE_DATA_DIR "/images/go-down.png", flip_image_vertical, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
@ -132,25 +134,29 @@ static void add_advanced_edit_tools(Ewl_Widget *c)
Ewl_Widget *button;
button = add_button(c, "Blur Image", NULL, image_blur, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
button = add_button(c, "Sharpen Image", NULL, image_sharpen, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
button = add_button(c, "Black and White", NULL, image_grayscale, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
button = add_button(c, "Sepia", NULL, image_sepia, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
ewl_button_image_size_set(EWL_BUTTON(button), 20, 20);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
/* button = add_button(c, "Channel Editor", NULL, channel_mixer, NULL);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);*/
return;
}
@ -234,7 +240,7 @@ static void flip_image_horizontal(Ewl_Widget *w, void *event, void *data)
image->oh = nh;
ewl_object_preferred_inner_size_set(EWL_OBJECT(em->eimage), nw, nh);
ewl_widget_configure(em->eimage->parent);
return;
}
@ -353,3 +359,57 @@ static void image_sepia(Ewl_Widget *w, void *event, void *data)
return;
}
/*Close the Channel Mixer*/
/*static void close_channel(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *win;
win = data;
ewl_widget_destroy(win);
}*/
/*Add a Channel Mixer*/
/*static void channel_mixer(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *window, *vbox, *ol, *image, *hist;
window = add_window("Channel Editor", 200, 400, NULL, NULL);
ewl_callback_append(window, EWL_CALLBACK_DELETE_WINDOW, close_channel, window);
vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 5);
ol = ewl_overlay_new();
ewl_object_alignment_set(EWL_OBJECT(ol), EWL_FLAG_ALIGN_CENTER);
ewl_object_fill_policy_set(EWL_OBJECT(ol), EWL_FLAG_FILL_SHRINK);
ewl_container_child_append(EWL_CONTAINER(vbox), ol);
ewl_widget_show(ol);
image = add_image(ol, ewl_image_file_path_get(EWL_IMAGE(em->eimage)),
0, NULL, NULL);
ewl_image_size_set(EWL_IMAGE(image), 175, 175);
ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_CENTER);
hist = ewl_histogram_new();
ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_R);
ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(image));
ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(ol), hist);
ewl_widget_show(hist);
hist = ewl_histogram_new();
ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_G);
ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(image));
ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(ol), hist);
ewl_widget_show(hist);
hist = ewl_histogram_new();
ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_B);
ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(image));
ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(ol), hist);
ewl_widget_show(hist);
}*/

View File

@ -370,10 +370,9 @@ unsigned int *grayscale_image(Ewl_Widget *image)
unsigned int *sepia_image(Ewl_Widget *image)
{
unsigned int *im_data, *im_data_new;
int i, r, g, b, a, ew, eh;
float h, s, v;
int i, r, rr, g, gg, b, bb, a, ew, eh;
im_data = evas_object_image_data_get(EWL_IMAGE(image)->image, FALSE);
im_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);
@ -384,11 +383,18 @@ unsigned int *sepia_image(Ewl_Widget *image)
g = (int)((im_data[i] >> 8) & 0xff);
r = (int)((im_data[i] >> 16) & 0xff);
a = (int)((im_data[i] >> 24) & 0xff);
rr = (int)(((r + g + b)/3)+40);
if (rr < 0) rr = 0;
if (rr > 255) rr = 255;
gg = (int)(((r + g + b)/3)+2);
if (gg < 0) gg = 0;
if (gg > 255) gg = 255;
bb = (int)(((r + g + b)/3)+2);
if (bb < 0) bb = 0;
if (bb > 255) bb = 255;
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;
im_data_new[i] = (a << 24) | (rr << 16) | (gg << 8) | bb;
}
return im_data_new;
}