static void color_rotate_row (const guchar *src_row, guchar *dest_row, gint row, gint row_width, gint bytes) { gint col, bytenum; gdouble H, S, V; guchar rgb[3]; for (col = 0; col < row_width; col++) { gboolean skip = FALSE; rgb[0] = src_row[col * bytes + 0]; rgb[1] = src_row[col * bytes + 1]; rgb[2] = src_row[col * bytes + 2]; gimp_rgb_to_hsv4 (rgb, &H, &S, &V); if (rcm_is_gray (S)) { if (Current.Gray_to_from == GRAY_FROM) { if (rcm_angle_inside_slice (Current.Gray->hue, Current.From->angle) <= 1) { H = Current.Gray->hue / TP; S = Current.Gray->satur; } else { skip = TRUE; } } else { skip = TRUE; gimp_hsv_to_rgb4 (rgb, Current.Gray->hue / TP, Current.Gray->satur, V); } } if (! skip) { H = rcm_linear (rcm_left_end (Current.From->angle), rcm_right_end (Current.From->angle), rcm_left_end (Current.To->angle), rcm_right_end (Current.To->angle), H * TP); H = angle_mod_2PI (H) / TP; gimp_hsv_to_rgb4 (rgb, H, S, V); } dest_row[col * bytes + 0] = rgb[0]; dest_row[col * bytes + 1] = rgb[1]; dest_row[col * bytes + 2] = rgb[2]; if (bytes > 3) { for (bytenum = 3; bytenum < bytes; bytenum++) dest_row[col * bytes + bytenum] = src_row[col * bytes + bytenum]; } } }
/* render before/after preview */ void rcm_render_preview (GtkWidget *preview) { ReducedImage *reduced; gint version; gint RW, RH, bytes, i, j; guchar *a; guchar *rgb_array; gdouble *hsv_array; gfloat degree; g_return_if_fail (preview != NULL); version = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (preview), "mode")); reduced = Current_c.reduced; RW = reduced->width; RH = reduced->height; bytes = Current_c.drawable->bpp; hsv_array = reduced->hsv; rgb_array = reduced->rgb; a = g_new (guchar, 4 * RW * RH); if (version == CURRENT) { gdouble H, S, V; guchar rgb[3]; for (i = 0; i < RH; i++) { for (j = 0; j < RW; j++) { gboolean unchanged = FALSE; gboolean skip = FALSE; H = hsv_array[i*RW*bytes + j*bytes + 0]; S = hsv_array[i*RW*bytes + j*bytes + 1]; V = hsv_array[i*RW*bytes + j*bytes + 2]; if (rcm_is_gray(S) && (reduced->mask[i*RW+j] != 0)) { switch (Current_c.Gray_to_from) { case GRAY_FROM: if (rcm_angle_inside_slice (Current_c.Gray->hue, Current_c.From->angle) <= 1) { H = Current_c.Gray->hue/TP; S = Current_c.Gray->satur; } else skip = TRUE; break; case GRAY_TO: unchanged = FALSE; skip = TRUE; gimp_hsv_to_rgb4 (rgb, Current_c.Gray->hue/TP, Current_c.Gray->satur, V); break; default: break; } } if (!skip) { unchanged = FALSE; H = rcm_linear (rcm_left_end (Current_c.From->angle), rcm_right_end (Current_c.From->angle), rcm_left_end (Current_c.To->angle), rcm_right_end (Current_c.To->angle), H * TP); H = angle_mod_2PI(H) / TP; gimp_hsv_to_rgb4 (rgb, H,S,V); } if (unchanged) degree = 0; else degree = reduced->mask[i*RW+j] / 255.0; a[(i*RW+j)*4+0] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 0] + degree * rgb[0]; a[(i*RW+j)*4+1] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 1] + degree * rgb[1]; a[(i*RW+j)*4+2] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 2] + degree * rgb[2]; /* apply transparency */ if (bytes == 4) a[(i*RW+j)*4+3] = rgb_array[i*RW*bytes+j*bytes+3]; else a[(i*RW+j)*4+3] = 255; } } } else /* ORIGINAL */ { for (i = 0; i < RH; i++) { for (j = 0; j < RW; j++) { a[(i*RW+j)*4+0] = rgb_array[i*RW*bytes + j*bytes + 0]; a[(i*RW+j)*4+1] = rgb_array[i*RW*bytes + j*bytes + 1]; a[(i*RW+j)*4+2] = rgb_array[i*RW*bytes + j*bytes + 2]; if (bytes == 4) a[(i*RW+j)*4+3] = rgb_array[i*RW*bytes+j*bytes+3]; else a[(i*RW+j)*4+3] = 255; } } } gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview), 0, 0, RW, RH, GIMP_RGBA_IMAGE, a, RW * 4); g_free (a); }