[Rawstudio-commit] r1932 - trunk/src

Anders Brander anders at brander.dk
Thu Jul 24 16:42:52 CEST 2008


Author: abrander
Date: 2008-07-24 16:42:51 +0200 (Thu, 24 Jul 2008)
New Revision: 1932

Modified:
   trunk/src/rawstudio.c
   trunk/src/rawstudio.h
   trunk/src/rs-batch.c
   trunk/src/rs-color-transform.c
   trunk/src/rs-color-transform.h
   trunk/src/rs-curve.c
   trunk/src/rs-histogram.c
   trunk/src/rs-histogram.h
   trunk/src/rs-job.c
   trunk/src/rs-job.h
   trunk/src/rs-preview-widget.c
   trunk/src/tiff-meta.c
Log:
Ported RS_COLOR_TRANSFORM to RSColorTransform (GObject'ified).

Modified: trunk/src/rawstudio.c
===================================================================
--- trunk/src/rawstudio.c	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rawstudio.c	2008-07-24 14:42:51 UTC (rev 1932)
@@ -48,6 +48,7 @@
 #include "rs-histogram.h"
 #include "rs-curve.h"
 #include "rs-photo.h"
+#include "rs-math.h"
 
 static void photo_settings_changed(RS_PHOTO *photo, gint mask, RS_BLOB *rs);
 static void photo_spatial_changed(RS_PHOTO *photo, RS_BLOB *rs);
@@ -537,7 +538,7 @@
 	RS_IMAGE16 *image16;
 	gint quality = 100;
 	gboolean uncompressed_tiff = FALSE;
-	RS_COLOR_TRANSFORM *rct;
+	RSColorTransform *rct;
 	void *transform = NULL;
 
 	g_assert(RS_IS_PHOTO(photo));
@@ -569,7 +570,7 @@
 	{
 		case FILETYPE_JPEG:
 			pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, rsi->w, rsi->h);
-			rct->transform(rct, rsi->w, rsi->h, rsi->pixels,
+			rs_color_transform_transform(rct, rsi->w, rsi->h, rsi->pixels,
 				rsi->rowstride, gdk_pixbuf_get_pixels(pixbuf), gdk_pixbuf_get_rowstride(pixbuf));
 
 			rs_conf_get_integer(CONF_EXPORT_JPEG_QUALITY, &quality);
@@ -583,7 +584,7 @@
 			break;
 		case FILETYPE_PNG:
 			pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, rsi->w, rsi->h);
-			rct->transform(rct, rsi->w, rsi->h, rsi->pixels, rsi->rowstride,
+			rs_color_transform_transform(rct, rsi->w, rsi->h, rsi->pixels, rsi->rowstride,
 				gdk_pixbuf_get_pixels(pixbuf), gdk_pixbuf_get_rowstride(pixbuf));
 			gdk_pixbuf_save(pixbuf, filename, "png", NULL, NULL);
 			g_object_unref(pixbuf);
@@ -591,7 +592,7 @@
 		case FILETYPE_TIFF8:
 			pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, rsi->w, rsi->h);
 			rs_conf_get_boolean(CONF_EXPORT_TIFF_UNCOMPRESSED, &uncompressed_tiff);
-			rct->transform(rct, rsi->w, rsi->h, rsi->pixels,
+			rs_color_transform_transform(rct, rsi->w, rsi->h, rsi->pixels,
 				rsi->rowstride, gdk_pixbuf_get_pixels(pixbuf), gdk_pixbuf_get_rowstride(pixbuf));
 			rs_tiff8_save(pixbuf, filename, rs_cms_get_profile_filename(cms, PROFILE_EXPORT), uncompressed_tiff);
 			g_object_unref(pixbuf);
@@ -600,7 +601,7 @@
 			rs_conf_get_boolean(CONF_EXPORT_TIFF_UNCOMPRESSED, &uncompressed_tiff);
 			image16 = rs_image16_new(rsi->w, rsi->h, 3, 3);
 			rs_color_transform_set_output_format(rct, 16);
-			rct->transform(rct, rsi->w, rsi->h,
+			rs_color_transform_transform(rct, rsi->w, rsi->h,
 				rsi->pixels, rsi->rowstride,
 				image16->pixels, image16->rowstride*2);
 			rs_tiff16_save(image16, filename, rs_cms_get_profile_filename(cms, PROFILE_EXPORT), uncompressed_tiff);
@@ -609,7 +610,7 @@
 	}
 
 	rs_image16_free(rsi);
-	rs_color_transform_free(rct);
+	g_object_unref(rct);
 
 	photo->exported = TRUE;
 	rs_cache_save(photo);
@@ -793,12 +794,12 @@
 		gdouble blackpoint;
 		gdouble whitepoint;
 		guint total = 0;
-		RS_COLOR_TRANSFORM *rct;
+		RSColorTransform *rct;
 
 		rct = rs_color_transform_new();
 		rs_color_transform_set_from_settings(rct, rs->photo->settings[rs->current_setting], MASK_ALL ^ MASK_CURVE);
 		rs_color_transform_make_histogram(rct, rs->histogram_dataset, hist);
-		rs_color_transform_free(rct);
+		g_object_unref(rct);
 
 		// calculate black point
 		while(i < 256) {

Modified: trunk/src/rawstudio.h
===================================================================
--- trunk/src/rawstudio.h	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rawstudio.h	2008-07-24 14:42:51 UTC (rev 1932)
@@ -129,7 +129,7 @@
 typedef struct _RS_QUEUE RS_QUEUE;
 
 /* Defined in rs-color-transform.c */
-typedef struct _RS_COLOR_TRANSFORM RS_COLOR_TRANSFORM;
+typedef struct _RSColorTransform RSColorTransform;
 
 typedef struct {double coeff[3][3]; } RS_MATRIX3;
 typedef struct {int coeff[3][3]; } RS_MATRIX3Int;
@@ -231,7 +231,7 @@
 	gint current_setting;
 	RS_IMAGE16 *histogram_dataset;
 	GtkWidget *histogram;
-	RS_COLOR_TRANSFORM *histogram_transform;
+	RSColorTransform *histogram_transform;
 	RS_QUEUE *queue;
 	RS_CMS *cms;
 	RSStore *store;

Modified: trunk/src/rs-batch.c
===================================================================
--- trunk/src/rs-batch.c	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rs-batch.c	2008-07-24 14:42:51 UTC (rev 1932)
@@ -389,7 +389,7 @@
 	GtkWidget *cancel;
 	gboolean abort_render = FALSE;
 	gboolean fullscreen = FALSE;
-	RS_COLOR_TRANSFORM *rct = rs_color_transform_new();
+	RSColorTransform *rct = rs_color_transform_new();
 	GTimeVal start_time;
 	GTimeVal now_time = {0,0};
 	gint time, eta;
@@ -521,7 +521,7 @@
 
 				/* Render preview image */
 				rs_color_transform_set_from_settings(rct, photo->settings[setting_id], MASK_ALL);
-				rct->transform(rct, image->w, image->h, image->pixels,
+				rs_color_transform_transform(rct, image->w, image->h, image->pixels,
 					image->rowstride, gdk_pixbuf_get_pixels(pixbuf),
 					gdk_pixbuf_get_rowstride(pixbuf));
 				gtk_image_set_from_pixbuf((GtkImage *) preview, pixbuf);
@@ -546,7 +546,7 @@
 
 		g_get_current_time(&now_time);
 	}
-	rs_color_transform_free(rct);
+	g_object_unref(rct);
 	gtk_widget_destroy(window);
 
 	/* Restore fullscreen state if needed */

Modified: trunk/src/rs-color-transform.c
===================================================================
--- trunk/src/rs-color-transform.c	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rs-color-transform.c	2008-07-24 14:42:51 UTC (rev 1932)
@@ -22,8 +22,8 @@
 #include "rs-color-transform.h"
 #include "rs-spline.h"
 
-static void make_tables(RS_COLOR_TRANSFORM *rct);
-static gboolean select_render(RS_COLOR_TRANSFORM *rct);
+static void make_tables(RSColorTransform *rct);
+static gboolean select_render(RSColorTransform *rct);
 
 #define LUM_PRECISION 15
 #define LUM_FIXED(a) ((guint)((a)*(1<<LUM_PRECISION)))
@@ -32,7 +32,6 @@
 #define BLUMF LUM_FIXED(0.072169f)
 #define HALFF LUM_FIXED(0.5f)
 
-
 /* Function pointers - initialized by arch binders */
 COLOR_TRANSFORM(*transform_nocms8);
 COLOR_TRANSFORM(*transform_cms8);
@@ -41,7 +40,9 @@
 COLOR_TRANSFORM(transform_null);
 COLOR_TRANSFORM(transform_nocms_float);
 
-struct _RS_COLOR_TRANSFORM_PRIVATE {
+struct _RSColorTransform {
+	GObject parent;
+	COLOR_TRANSFORM(*transform_func);
 	gdouble gamma;
 	gdouble contrast;
 	gfloat pre_mul[4] align(16);
@@ -49,63 +50,78 @@
 	guint pixelsize;
 	RS_MATRIX4 color_matrix;
 	RS_MATRIX4 adobe_matrix;
-	guchar table8[65536];
-	gushort table16[65536];
+	guchar *table8;
+	gushort *table16;
 	rs_spline_t *spline;
 	gint nknots;
 	gfloat *knots;
-	gfloat curve_samples[65536];
-	void *transform;
+	gfloat *curve_samples;
+	void *cms_transform;
 };
 
-/**
- * Creates a new color transform
- * @return A new RS_COLOR_TRANSFORM
- */
-RS_COLOR_TRANSFORM *
-rs_color_transform_new()
+G_DEFINE_TYPE (RSColorTransform, rs_color_transform, G_TYPE_OBJECT);
+
+static void
+rs_color_transform_finalize(GObject *object)
 {
-	gint i;
-	RS_COLOR_TRANSFORM *rct;
+	RSColorTransform *rct = RS_COLOR_TRANSFORM(object);
 
-	rct = g_new0(RS_COLOR_TRANSFORM, 1);
-	rct->transform = transform_null;
+	g_free(rct->curve_samples);
+	g_free(rct->table8);
+	g_free(rct->table16);
 
-	rct->priv = g_new0(RS_COLOR_TRANSFORM_PRIVATE, 1);
+	if (G_OBJECT_CLASS (rs_color_transform_parent_class)->finalize)
+		G_OBJECT_CLASS (rs_color_transform_parent_class)->finalize (object);
+}
 
+static void
+rs_color_transform_class_init(RSColorTransformClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = rs_color_transform_finalize;
+}
+
+static void
+rs_color_transform_init(RSColorTransform *rct)
+{
+	gint i;
+	rct->transform_func = transform_null;
 	/* Initialize with sane values */
-	rct->priv->gamma = GAMMA;
-	rct->priv->contrast = 1.0;
+	rct->gamma = GAMMA;
+	rct->contrast = 1.0;
 	for (i=0;i<4;i++)
-		rct->priv->pre_mul[i] = 1.0;
-	rct->priv->bits_per_color = 8;
-	matrix4_identity(&rct->priv->color_matrix);
-	matrix4_identity(&rct->priv->adobe_matrix);
-	rct->priv->transform = NULL;
-	rct->priv->spline = NULL;
-	rct->priv->nknots = 0;
-	rct->priv->knots = NULL;
+		rct->pre_mul[i] = 1.0;
+	rct->bits_per_color = 8;
+	matrix4_identity(&rct->color_matrix);
+	matrix4_identity(&rct->adobe_matrix);
+	rct->spline = NULL;
+	rct->nknots = 0;
+	rct->knots = NULL;
+	rct->curve_samples = g_new(gfloat, 65536);
 	for(i=0;i<65536;i++)
-		rct->priv->curve_samples[i] = ((gdouble)i)/65536.0;
+		rct->curve_samples[i] = ((gfloat)i)/65536.0;
+	rct->cms_transform = NULL;
 
+	rct->table8 = g_new(guchar, 65536);
+	rct->table16 = g_new(gushort, 65536);
 	/* Prepare tables */
 	make_tables(rct);
 
 	/* Select renderer */
 	select_render(rct);
+}
 
-	return rct;
+RSColorTransform *
+rs_color_transform_new()
+{
+	return g_object_new (RS_TYPE_COLOR_TRANSFORM, NULL);
 }
 
-void
-rs_color_transform_free(RS_COLOR_TRANSFORM *rct)
+/* Just a simple wrapper */
+COLOR_TRANSFORM(rs_color_transform_transform)
 {
-	g_assert(rct != NULL);
-
-	g_free(rct->priv);
-	g_free(rct);
-
-	return;
+	rct->transform_func(rct, width, height, in, in_rowstride, out, out_rowstride);
 }
 
 /**
@@ -114,13 +130,13 @@
  * @param gamma The desired gamma
  */
 gboolean
-rs_color_transform_set_gamma(RS_COLOR_TRANSFORM *rct, gdouble gamma)
+rs_color_transform_set_gamma(RSColorTransform *rct, gdouble gamma)
 {
 	g_assert(rct != NULL);
 
 	if (gamma>0.0)
 	{
-		rct->priv->gamma = gamma;
+		rct->gamma = gamma;
 		make_tables(rct);
 		return TRUE;
 	}
@@ -135,13 +151,13 @@
  * @param contrast The desired contrast, range 0-3
  */
 gboolean
-rs_color_transform_set_contrast(RS_COLOR_TRANSFORM *rct, gdouble contrast)
+rs_color_transform_set_contrast(RSColorTransform *rct, gdouble contrast)
 {
 	g_assert(rct != NULL);
 
 	if (contrast>0.0)
 	{
-		rct->priv->contrast = contrast;
+		rct->contrast = contrast;
 		make_tables(rct);
 		return TRUE;
 	}
@@ -155,16 +171,16 @@
  * @param premul A gfloat *, {1.0, 1.0, 1.0} will result in no change
  */
 gboolean
-rs_color_transform_set_premul(RS_COLOR_TRANSFORM *rct, gfloat *premul)
+rs_color_transform_set_premul(RSColorTransform *rct, gfloat *premul)
 {
 	g_assert(rct != NULL);
 	g_assert(premul != NULL);
 
 	if ((premul[R]>0.0) && (premul[G]>0.0) && (premul[B]>0.0) && (premul[G2]>0.0))
 	{
-		rct->priv->pre_mul[R] = premul[R];
-		rct->priv->pre_mul[G] = premul[G];
-		rct->priv->pre_mul[B] = premul[B];
+		rct->pre_mul[R] = premul[R];
+		rct->pre_mul[G] = premul[G];
+		rct->pre_mul[B] = premul[B];
 		return TRUE;
 	}
 	else
@@ -177,17 +193,17 @@
  * @param matrix A pointer to a color matrix
  */
 gboolean
-rs_color_transform_set_matrix(RS_COLOR_TRANSFORM *rct, RS_MATRIX4 *matrix)
+rs_color_transform_set_matrix(RSColorTransform *rct, RS_MATRIX4 *matrix)
 {
 	g_assert(rct != NULL);
 	g_assert(matrix != NULL);
 
-	rct->priv->color_matrix = *matrix;
+	rct->color_matrix = *matrix;
 	return TRUE;
 }
 
 void
-rs_color_transform_set_from_settings(RS_COLOR_TRANSFORM *rct, RS_SETTINGS_DOUBLE *settings, guint mask)
+rs_color_transform_set_from_settings(RSColorTransform *rct, RS_SETTINGS_DOUBLE *settings, guint mask)
 {
 	gboolean update_tables = FALSE;
 
@@ -196,30 +212,30 @@
 	if (mask & (MASK_EXPOSURE|MASK_SATURATION|MASK_HUE))
 	{
 		/* FIXME: this is broken, we should cache the results */
-		if (rct->priv->transform)
-			matrix4_identity(&rct->priv->color_matrix);
+		if (rct->cms_transform)
+			matrix4_identity(&rct->color_matrix);
 		else
-			rct->priv->color_matrix = rct->priv->adobe_matrix;
+			rct->color_matrix = rct->adobe_matrix;
 
-		matrix4_color_exposure(&rct->priv->color_matrix, settings->exposure);
-		matrix4_color_saturate(&rct->priv->color_matrix, settings->saturation);
-		matrix4_color_hue(&rct->priv->color_matrix, settings->hue);
+		matrix4_color_exposure(&rct->color_matrix, settings->exposure);
+		matrix4_color_saturate(&rct->color_matrix, settings->saturation);
+		matrix4_color_hue(&rct->color_matrix, settings->hue);
 	}
 
 	if (mask & MASK_WB)
 	{
-		rct->priv->pre_mul[R] = (1.0+settings->warmth)*(2.0-settings->tint);
-		rct->priv->pre_mul[G] = 1.0;
-		rct->priv->pre_mul[B] = (1.0-settings->warmth)*(2.0-settings->tint);
-		rct->priv->pre_mul[G2] = 1.0;
+		rct->pre_mul[R] = (1.0+settings->warmth)*(2.0-settings->tint);
+		rct->pre_mul[G] = 1.0;
+		rct->pre_mul[B] = (1.0-settings->warmth)*(2.0-settings->tint);
+		rct->pre_mul[G2] = 1.0;
 	}
 
 	if (mask & MASK_CONTRAST)
 	{
-		if (rct->priv->contrast != settings->contrast)
+		if (rct->contrast != settings->contrast)
 		{
 			update_tables = TRUE;
-			rct->priv->contrast = settings->contrast;
+			rct->contrast = settings->contrast;
 		}
 	}
 
@@ -227,33 +243,33 @@
 	{
 		if (settings->curve_nknots < 2)
 		{
-			if (rct->priv->knots)
+			if (rct->knots)
 			{
-				g_free(rct->priv->knots);
-				rct->priv->knots = NULL;
-				rct->priv->nknots = 0;
+				g_free(rct->knots);
+				rct->knots = NULL;
+				rct->nknots = 0;
 				update_tables = TRUE;
 			}
 		}
-		if ((settings->curve_nknots > 1) && (rct->priv->nknots != settings->curve_nknots))
+		if ((settings->curve_nknots > 1) && (rct->nknots != settings->curve_nknots))
 		{
-			rct->priv->nknots = settings->curve_nknots;
-			if (rct->priv->knots)
+			rct->nknots = settings->curve_nknots;
+			if (rct->knots)
 			{
-				g_free(rct->priv->knots);
-				rct->priv->knots = NULL;
+				g_free(rct->knots);
+				rct->knots = NULL;
 			}
-			rct->priv->knots = g_new0(gfloat, rct->priv->nknots*2);
+			rct->knots = g_new0(gfloat, rct->nknots*2);
 		}
-		if ((settings->curve_nknots > 1) && (rct->priv->nknots == settings->curve_nknots))
+		if ((settings->curve_nknots > 1) && (rct->nknots == settings->curve_nknots))
 		{
-			if (memcmp(rct->priv->knots, settings->curve_knots, rct->priv->nknots*sizeof(gfloat)*2) != 0)
+			if (memcmp(rct->knots, settings->curve_knots, rct->nknots*sizeof(gfloat)*2) != 0)
 			{
-				memcpy(rct->priv->knots, settings->curve_knots, rct->priv->nknots*sizeof(gfloat)*2);
-				if (rct->priv->spline)
-					rs_spline_destroy(rct->priv->spline);
-				rct->priv->spline = rs_spline_new(rct->priv->knots, rct->priv->nknots, NATURAL);
-				rs_spline_sample(rct->priv->spline, rct->priv->curve_samples, 65536);
+				memcpy(rct->knots, settings->curve_knots, rct->nknots*sizeof(gfloat)*2);
+				if (rct->spline)
+					rs_spline_destroy(rct->spline);
+				rct->spline = rs_spline_new(rct->knots, rct->nknots, NATURAL);
+				rs_spline_sample(rct->spline, rct->curve_samples, 65536);
 				update_tables = TRUE;
 			}
 		}
@@ -270,17 +286,17 @@
  * @return TRUE on success
  */
 gboolean
-rs_color_transform_set_output_format(RS_COLOR_TRANSFORM *rct, guint bits_per_color)
+rs_color_transform_set_output_format(RSColorTransform *rct, guint bits_per_color)
 {
 	gboolean changes = FALSE;
 	gboolean ret = FALSE;
 
 	g_assert(rct != NULL);
 
-	if (rct->priv->bits_per_color != bits_per_color)
+	if (rct->bits_per_color != bits_per_color)
 	{
 		changes = TRUE;
-		rct->priv->bits_per_color = bits_per_color;
+		rct->bits_per_color = bits_per_color;
 	}
 
 	if (changes)
@@ -292,59 +308,59 @@
 }
 
 void
-rs_color_transform_set_cms_transform(RS_COLOR_TRANSFORM *rct, void *transform)
+rs_color_transform_set_cms_transform(RSColorTransform *rct, void *transform)
 {
 	g_assert(rct != NULL);
 
-	rct->priv->transform = transform;
+	rct->cms_transform = transform;
 	select_render(rct);
 }
 
 void
-rs_color_transform_set_adobe_matrix(RS_COLOR_TRANSFORM *rct, RS_MATRIX4 *matrix)
+rs_color_transform_set_adobe_matrix(RSColorTransform *rct, RS_MATRIX4 *matrix)
 {
 	g_assert(rct != NULL);
 	g_assert(matrix != NULL);
 
-	rct->priv->adobe_matrix = *matrix;
+	rct->adobe_matrix = *matrix;
 }
 
 static void
-make_tables(RS_COLOR_TRANSFORM *rct)
+make_tables(RSColorTransform *rct)
 {
 	static const gdouble rec65535 = (1.0f / 65536.0f);
 	register gint n;
 	gdouble nd;
 	register gint res;
-	const gdouble contrast = rct->priv->contrast + 0.01f; /* magic */
+	const gdouble contrast = rct->contrast + 0.01f; /* magic */
 	const gdouble postadd = 0.5f - (contrast/2.0f);
-	const gdouble gammavalue = (1.0f/rct->priv->gamma);
+	const gdouble gammavalue = (1.0f/rct->gamma);
 
 	for(n=0;n<65536;n++)
 	{
 		nd = ((gdouble) n) * rec65535;
 		nd = pow(nd, gammavalue);
 
-		if (likely(rct->priv->curve_samples))
-			nd = (gdouble) rct->priv->curve_samples[((gint) (nd*65535.0f))];
+		if (likely(rct->curve_samples))
+			nd = (gdouble) rct->curve_samples[((gint) (nd*65535.0f))];
 
 		nd = nd*contrast+postadd;
 
 		/* 8 bit output */
-		if ((rct->priv->bits_per_color == 8) && (rct->priv->transform == NULL))
+		if ((rct->bits_per_color == 8) && (rct->cms_transform == NULL))
 		{
 			res = (gint) (nd*255.0f);
 			_CLAMP255(res);
-			rct->priv->table8[n] = res;
+			rct->table8[n] = res;
 		}
 
 		/* 16 bit output */
-		else if ((rct->priv->bits_per_color == 16) || (rct->priv->transform != NULL))
+		else if ((rct->bits_per_color == 16) || (rct->cms_transform != NULL))
 		{
-			nd = pow(nd, rct->priv->gamma);
+			nd = pow(nd, rct->gamma);
 			res = (gint) (nd*65535.0f);
 			_CLAMP65535(res);
-			rct->priv->table16[n] = res;
+			rct->table16[n] = res;
 		}
 	}
 
@@ -352,27 +368,27 @@
 }
 
 static gboolean
-select_render(RS_COLOR_TRANSFORM *rct)
+select_render(RSColorTransform *rct)
 {
 	gboolean ret = FALSE;
 	g_assert(rct != NULL);
 
 	/* Start with null renderer, replace if possible */
-	rct->transform = transform_null;
+	rct->transform_func = transform_null;
 
-	if ((rct->priv->bits_per_color == 8) && (rct->priv->transform != NULL))
+	if ((rct->bits_per_color == 8) && (rct->cms_transform != NULL))
 	{
-		rct->transform = transform_cms8;
+		rct->transform_func = transform_cms8;
 		ret = TRUE;
 	}
-	else if ((rct->priv->bits_per_color == 8) && (rct->priv->transform == NULL))
+	else if ((rct->bits_per_color == 8) && (rct->cms_transform == NULL))
 	{
-		rct->transform = transform_nocms8;
+		rct->transform_func = transform_nocms8;
 		ret = TRUE;
 	}
-	else if ((rct->priv->bits_per_color == 8) || (rct->priv->bits_per_color == 16))
+	else if ((rct->bits_per_color == 8) || (rct->bits_per_color == 16))
 	{
-		rct->transform = transform_nocms_float;
+		rct->transform_func = transform_nocms_float;
 		ret = TRUE;
 	}
 	/* Make sure the appropriate tables are ready for the new renderer */
@@ -406,9 +422,9 @@
 		for(x=0 ; x<width ; x++)
 		{
 			/* pre multipliers */
-			r1 = in[srcoffset+R] * rct->priv->pre_mul[R];
-			g1 = in[srcoffset+G] * rct->priv->pre_mul[G];
-			b1 = in[srcoffset+B] * rct->priv->pre_mul[B];
+			r1 = in[srcoffset+R] * rct->pre_mul[R];
+			g1 = in[srcoffset+G] * rct->pre_mul[G];
+			b1 = in[srcoffset+B] * rct->pre_mul[B];
 
 			/* clamp top */
 			if (r1>65535.0) r1 = 65535.0;
@@ -416,15 +432,15 @@
 			if (b1>65535.0) b1 = 65535.0;
 
 			/* apply color matrix */
-			r2 = (gint) (r1*rct->priv->color_matrix.coeff[0][0]
-				+ g1*rct->priv->color_matrix.coeff[0][1]
-				+ b1*rct->priv->color_matrix.coeff[0][2]);
-			g2 = (gint) (r1*rct->priv->color_matrix.coeff[1][0]
-				+ g1*rct->priv->color_matrix.coeff[1][1]
-				+ b1*rct->priv->color_matrix.coeff[1][2]);
-			b2 = (gint) (r1*rct->priv->color_matrix.coeff[2][0]
-				+ g1*rct->priv->color_matrix.coeff[2][1]
-				+ b1*rct->priv->color_matrix.coeff[2][2]);
+			r2 = (gint) (r1*rct->color_matrix.coeff[0][0]
+				+ g1*rct->color_matrix.coeff[0][1]
+				+ b1*rct->color_matrix.coeff[0][2]);
+			g2 = (gint) (r1*rct->color_matrix.coeff[1][0]
+				+ g1*rct->color_matrix.coeff[1][1]
+				+ b1*rct->color_matrix.coeff[1][2]);
+			b2 = (gint) (r1*rct->color_matrix.coeff[2][0]
+				+ g1*rct->color_matrix.coeff[2][1]
+				+ b1*rct->color_matrix.coeff[2][2]);
 
 			/* we need integers for lookup */
 			r = r2;
@@ -435,17 +451,17 @@
 			_CLAMP65535_TRIPLET(r,g,b);
 
 			/* look up all colors in gammatable */
-			if (unlikely(rct->priv->bits_per_color == 16))
+			if (unlikely(rct->bits_per_color == 16))
 			{
-				*d16++ = rct->priv->table16[r];
-				*d16++ = rct->priv->table16[g];
-				*d16++ = rct->priv->table16[b];
+				*d16++ = rct->table16[r];
+				*d16++ = rct->table16[g];
+				*d16++ = rct->table16[b];
 			}
 			else
 			{
-				*d8++ = rct->priv->table8[r];
-				*d8++ = rct->priv->table8[g];
-				*d8++ = rct->priv->table8[b];
+				*d8++ = rct->table8[r];
+				*d8++ = rct->table8[g];
+				*d8++ = rct->table8[b];
 			}
 
 			/* input is always aligned to 64 bits */
@@ -469,19 +485,19 @@
 	if ((rct==NULL) || (width<1) || (height<1) || (in == NULL) || (in_rowstride<8) || (out == NULL) || (out_rowstride<1))
 		return;
 
-	mat[0] = rct->priv->color_matrix.coeff[0][0];
-	mat[1] = rct->priv->color_matrix.coeff[1][0];
-	mat[2] = rct->priv->color_matrix.coeff[2][0];
+	mat[0] = rct->color_matrix.coeff[0][0];
+	mat[1] = rct->color_matrix.coeff[1][0];
+	mat[2] = rct->color_matrix.coeff[2][0];
 	mat[3] = 0.f;
 
-	mat[4] = rct->priv->color_matrix.coeff[0][1];
-	mat[5] = rct->priv->color_matrix.coeff[1][1];
-	mat[6] = rct->priv->color_matrix.coeff[2][1];
+	mat[4] = rct->color_matrix.coeff[0][1];
+	mat[5] = rct->color_matrix.coeff[1][1];
+	mat[6] = rct->color_matrix.coeff[2][1];
 	mat[7] = 0.f;
 
-	mat[8]  = rct->priv->color_matrix.coeff[0][2];
-	mat[9]  = rct->priv->color_matrix.coeff[1][2];
-	mat[10] = rct->priv->color_matrix.coeff[2][2];
+	mat[8]  = rct->color_matrix.coeff[0][2];
+	mat[9]  = rct->color_matrix.coeff[1][2];
+	mat[10] = rct->color_matrix.coeff[2][2];
 	mat[11] = 0.f;
 
 	asm volatile (
@@ -492,7 +508,7 @@
 		"movaps (%1), %%xmm6\n\t" /* top */
 		"pxor %%mm7, %%mm7\n\t" /* 0x0 */
 		:
-		: "r" (&mat[0]), "r" (&top[0]), "r" (rct->priv->pre_mul)
+		: "r" (&mat[0]), "r" (&top[0]), "r" (rct->pre_mul)
 		: "memory"
 	);
 	while(height--)
@@ -547,9 +563,9 @@
 				: "r" (s)
 				: "memory"
 			);
-			d[destoffset++] = rct->priv->table8[r];
-			d[destoffset++] = rct->priv->table8[g];
-			d[destoffset++] = rct->priv->table8[b];
+			d[destoffset++] = rct->table8[r];
+			d[destoffset++] = rct->table8[g];
+			d[destoffset++] = rct->table8[b];
 			s += 4;
 		}
 	}
@@ -567,19 +583,19 @@
 	if ((rct==NULL) || (width<1) || (height<1) || (in == NULL) || (in_rowstride<8) || (out == NULL) || (out_rowstride<1))
 		return;
 
-	mat[0] = rct->priv->color_matrix.coeff[0][0];
-	mat[1] = rct->priv->color_matrix.coeff[0][1];
-	mat[2] = rct->priv->color_matrix.coeff[0][2];
+	mat[0] = rct->color_matrix.coeff[0][0];
+	mat[1] = rct->color_matrix.coeff[0][1];
+	mat[2] = rct->color_matrix.coeff[0][2];
 	mat[3] = 0.f;
 
-	mat[4] = rct->priv->color_matrix.coeff[1][0];
-	mat[5] = rct->priv->color_matrix.coeff[1][1];
-	mat[6] = rct->priv->color_matrix.coeff[1][2];
+	mat[4] = rct->color_matrix.coeff[1][0];
+	mat[5] = rct->color_matrix.coeff[1][1];
+	mat[6] = rct->color_matrix.coeff[1][2];
 	mat[7] = 0.f;
 
-	mat[8]  = rct->priv->color_matrix.coeff[2][0];
-	mat[9]  = rct->priv->color_matrix.coeff[2][1];
-	mat[10] = rct->priv->color_matrix.coeff[2][2];
+	mat[8]  = rct->color_matrix.coeff[2][0];
+	mat[9]  = rct->color_matrix.coeff[2][1];
+	mat[10] = rct->color_matrix.coeff[2][2];
 	mat[11] = 0.f;
 
 	asm volatile (
@@ -589,7 +605,7 @@
 		"movq 8(%0), %%mm3\n\t" /* pre_mul B | pre_mul G2 */
 		"movq (%1), %%mm6\n\t" /* 65535.0 | 65535.0 */
 		:
-		: "r" (rct->priv->pre_mul), "r" (&top[0])
+		: "r" (rct->pre_mul), "r" (&top[0])
 	);
 	while(height--)
 	{
@@ -654,9 +670,9 @@
 				: "+r" (s), "+r" (r), "+r" (g), "+r" (b)
 				: "r" (&mat[0])
 			);
-			d[destoffset++] = rct->priv->table8[r];
-			d[destoffset++] = rct->priv->table8[g];
-			d[destoffset++] = rct->priv->table8[b];
+			d[destoffset++] = rct->table8[r];
+			d[destoffset++] = rct->table8[g];
+			d[destoffset++] = rct->table8[b];
 		}
 	}
 	asm volatile ("femms\n\t");
@@ -675,19 +691,19 @@
 	if ((rct==NULL) || (width<1) || (height<1) || (in == NULL) || (in_rowstride<8) || (out == NULL) || (out_rowstride<1))
 		return;
 
-	mat[0] = rct->priv->color_matrix.coeff[0][0];
-	mat[1] = rct->priv->color_matrix.coeff[1][0];
-	mat[2] = rct->priv->color_matrix.coeff[2][0];
+	mat[0] = rct->color_matrix.coeff[0][0];
+	mat[1] = rct->color_matrix.coeff[1][0];
+	mat[2] = rct->color_matrix.coeff[2][0];
 	mat[3] = 0.f;
 
-	mat[4] = rct->priv->color_matrix.coeff[0][1];
-	mat[5] = rct->priv->color_matrix.coeff[1][1];
-	mat[6] = rct->priv->color_matrix.coeff[2][1];
+	mat[4] = rct->color_matrix.coeff[0][1];
+	mat[5] = rct->color_matrix.coeff[1][1];
+	mat[6] = rct->color_matrix.coeff[2][1];
 	mat[7] = 0.f;
 
-	mat[8]  = rct->priv->color_matrix.coeff[0][2];
-	mat[9]  = rct->priv->color_matrix.coeff[1][2];
-	mat[10] = rct->priv->color_matrix.coeff[2][2];
+	mat[8]  = rct->color_matrix.coeff[0][2];
+	mat[9]  = rct->color_matrix.coeff[1][2];
+	mat[10] = rct->color_matrix.coeff[2][2];
 	mat[11] = 0.f;
 
 	asm volatile (
@@ -698,7 +714,7 @@
 		"movaps (%1), %%xmm6\n\t" /* top */
 		"pxor %%mm7, %%mm7\n\t" /* 0x0 */
 		:
-		: "r" (&mat[0]), "r" (&top[0]), "r" (rct->priv->pre_mul)
+		: "r" (&mat[0]), "r" (&top[0]), "r" (rct->pre_mul)
 		: "memory"
 	);
 	while(height--)
@@ -750,12 +766,12 @@
 				: "r" (s)
 				: "memory"
 			);
-			buffer[destoffset++] = rct->priv->table16[r];
-			buffer[destoffset++] = rct->priv->table16[g];
-			buffer[destoffset++] = rct->priv->table16[b];
+			buffer[destoffset++] = rct->table16[r];
+			buffer[destoffset++] = rct->table16[g];
+			buffer[destoffset++] = rct->table16[b];
 			s += 4;
 		}
-		cmsDoTransform((cmsHPROFILE) rct->priv->transform, buffer, out+height * out_rowstride, width);
+		cmsDoTransform((cmsHPROFILE) rct->cms_transform, buffer, out+height * out_rowstride, width);
 	}
 	asm volatile("emms\n\t");
 	g_free(buffer);
@@ -773,19 +789,19 @@
 	if ((rct==NULL) || (width<1) || (height<1) || (in == NULL) || (in_rowstride<8) || (out == NULL) || (out_rowstride<1))
 		return;
 
-	mat[0] = rct->priv->color_matrix.coeff[0][0];
-	mat[1] = rct->priv->color_matrix.coeff[0][1];
-	mat[2] = rct->priv->color_matrix.coeff[0][2];
+	mat[0] = rct->color_matrix.coeff[0][0];
+	mat[1] = rct->color_matrix.coeff[0][1];
+	mat[2] = rct->color_matrix.coeff[0][2];
 	mat[3] = 0.f;
 
-	mat[4] = rct->priv->color_matrix.coeff[1][0];
-	mat[5] = rct->priv->color_matrix.coeff[1][1];
-	mat[6] = rct->priv->color_matrix.coeff[1][2];
+	mat[4] = rct->color_matrix.coeff[1][0];
+	mat[5] = rct->color_matrix.coeff[1][1];
+	mat[6] = rct->color_matrix.coeff[1][2];
 	mat[7] = 0.f;
 
-	mat[8]  = rct->priv->color_matrix.coeff[2][0];
-	mat[9]  = rct->priv->color_matrix.coeff[2][1];
-	mat[10] = rct->priv->color_matrix.coeff[2][2];
+	mat[8]  = rct->color_matrix.coeff[2][0];
+	mat[9]  = rct->color_matrix.coeff[2][1];
+	mat[10] = rct->color_matrix.coeff[2][2];
 	mat[11] = 0.f;
 
 	asm volatile (
@@ -795,7 +811,7 @@
 		"movq 8(%0), %%mm3\n\t" /* pre_mul B | pre_mul G2 */
 		"movq (%1), %%mm6\n\t" /* 65535.0 | 65535.0 */
 		:
-		: "r" (rct->priv->pre_mul), "r" (&top[0])
+		: "r" (rct->pre_mul), "r" (&top[0])
 	);
 	while(height--)
 	{
@@ -859,11 +875,11 @@
 				: "+r" (s), "+r" (r), "+r" (g), "+r" (b)
 				: "r" (&mat[0])
 			);
-			buffer[destoffset++] = rct->priv->table16[r];
-			buffer[destoffset++] = rct->priv->table16[g];
-			buffer[destoffset++] = rct->priv->table16[b];
+			buffer[destoffset++] = rct->table16[r];
+			buffer[destoffset++] = rct->table16[g];
+			buffer[destoffset++] = rct->table16[b];
 		}
-		cmsDoTransform((cmsHPROFILE) rct->priv->transform, buffer, out+height * out_rowstride, width);
+		cmsDoTransform((cmsHPROFILE) rct->cms_transform, buffer, out+height * out_rowstride, width);
 	}
 	asm volatile ("femms\n\t");
 	g_free(buffer);
@@ -884,9 +900,9 @@
 	if ((rct==NULL) || (width<1) || (height<1) || (in == NULL) || (in_rowstride<8) || (out == NULL) || (out_rowstride<1))
 		return;
 
-	matrix4_to_matrix4int(&rct->priv->color_matrix, &mati);
+	matrix4_to_matrix4int(&rct->color_matrix, &mati);
 	for(x=0;x<4;x++)
-		pre_muli[x] = (gint) (rct->priv->pre_mul[x]*128.0);
+		pre_muli[x] = (gint) (rct->pre_mul[x]*128.0);
 	for(y=0 ; y<height ; y++)
 	{
 		destoffset = 0;
@@ -907,12 +923,12 @@
 				+ gg*mati.coeff[2][1]
 				+ bb*mati.coeff[2][2])>>MATRIX_RESOLUTION;
 			_CLAMP65535_TRIPLET(r,g,b);
-			buffer[destoffset++] = rct->priv->table16[r];
-			buffer[destoffset++] = rct->priv->table16[g];
-			buffer[destoffset++] = rct->priv->table16[b];
+			buffer[destoffset++] = rct->table16[r];
+			buffer[destoffset++] = rct->table16[g];
+			buffer[destoffset++] = rct->table16[b];
 			srcoffset+=4;
 		}
-		cmsDoTransform((cmsHPROFILE) rct->priv->transform, buffer, out+y * out_rowstride, width);
+		cmsDoTransform((cmsHPROFILE) rct->cms_transform, buffer, out+y * out_rowstride, width);
 	}
 	g_free(buffer);
 	return;
@@ -930,9 +946,9 @@
 	if ((rct==NULL) || (width<1) || (height<1) || (in == NULL) || (in_rowstride<8) || (out == NULL) || (out_rowstride<1))
 		return;
 
-	matrix4_to_matrix4int(&rct->priv->color_matrix, &mati);
+	matrix4_to_matrix4int(&rct->color_matrix, &mati);
 	for(x=0;x<4;x++)
-		pre_muli[x] = (gint) (rct->priv->pre_mul[x]*128.0);
+		pre_muli[x] = (gint) (rct->pre_mul[x]*128.0);
 	for(y=0 ; y<height ; y++)
 	{
 		guchar *d = out + y * out_rowstride;
@@ -954,9 +970,9 @@
 				+ gg*mati.coeff[2][1]
 				+ bb*mati.coeff[2][2])>>MATRIX_RESOLUTION;
 			_CLAMP65535_TRIPLET(r,g,b);
-			d[destoffset++] = rct->priv->table8[r];
-			d[destoffset++] = rct->priv->table8[g];
-			d[destoffset++] = rct->priv->table8[b];
+			d[destoffset++] = rct->table8[r];
+			d[destoffset++] = rct->table8[g];
+			d[destoffset++] = rct->table8[b];
 			srcoffset+=4;
 		}
 	}
@@ -964,7 +980,7 @@
 }
 
 void
-rs_color_transform_make_histogram(RS_COLOR_TRANSFORM *rct, RS_IMAGE16 *input, guint histogram[4][256])
+rs_color_transform_make_histogram(RSColorTransform *rct, RS_IMAGE16 *input, guint histogram[4][256])
 {
 	gint y,x;
 	gint srcoffset;
@@ -982,7 +998,7 @@
 	if (unlikely(histogram==NULL)) return;
 
 	/* Allocate buffers for CMS if needed */
-	if (rct->priv->transform != NULL)
+	if (rct->cms_transform != NULL)
 	{
 		buffer16 = g_new(gushort, input->w*3);
 		buffer8 = g_new(guchar, input->w*3);
@@ -991,10 +1007,10 @@
 	/* Reset table */
 	memset(histogram, 0x00, sizeof(guint)*4*256);
 
-	matrix4_to_matrix4int(&rct->priv->color_matrix, &mati);
+	matrix4_to_matrix4int(&rct->color_matrix, &mati);
 
 	for(x=0;x<4;x++)
-		pre_muli[x] = (gint) (rct->priv->pre_mul[x]*128.0);
+		pre_muli[x] = (gint) (rct->pre_mul[x]*128.0);
 	in	= input->pixels;
 	for(y=0 ; y<input->h ; y++)
 	{
@@ -1016,7 +1032,7 @@
 				+ bb*mati.coeff[2][2])>>MATRIX_RESOLUTION;
 			_CLAMP65535_TRIPLET(r,g,b);
 
-			if (rct->priv->transform != NULL)
+			if (rct->cms_transform != NULL)
 			{
 				buffer16[x*3+R] = r;
 				buffer16[x*3+G] = g;
@@ -1024,22 +1040,22 @@
 			}
 			else
 			{
-				histogram[0][rct->priv->table8[r]]++;
-				histogram[1][rct->priv->table8[g]]++;
-				histogram[2][rct->priv->table8[b]]++;
+				histogram[0][rct->table8[r]]++;
+				histogram[1][rct->table8[g]]++;
+				histogram[2][rct->table8[b]]++;
 				luma = (RLUMF*(guint)r
 					+ GLUMF*(guint)g
 					+ BLUMF*(guint)b
 					+ HALFF)>>LUM_PRECISION;
-				luma = rct->priv->table8[luma];
+				luma = rct->table8[luma];
 				_CLAMP255(luma);
 				histogram[3][luma]++;
 			}
 			srcoffset+=input->pixelsize;
 		}
-		if (rct->priv->transform != NULL)
+		if (rct->cms_transform != NULL)
 		{
-			cmsDoTransform((cmsHPROFILE) rct->priv->transform, buffer16, buffer8, input->w);
+			cmsDoTransform((cmsHPROFILE) rct->cms_transform, buffer16, buffer8, input->w);
 			for(x=0 ; x<input->w ; x++)
 			{
 				histogram[R][buffer8[x*3+R]]++;

Modified: trunk/src/rs-color-transform.h
===================================================================
--- trunk/src/rs-color-transform.h	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rs-color-transform.h	2008-07-24 14:42:51 UTC (rev 1932)
@@ -20,38 +20,46 @@
 #ifndef RS_COLOR_TRANSFORM_H
 #define RS_COLOR_TRANSFORM_H
 
+#include <glib-object.h>
 #include "rawstudio.h"
 #include "rs-math.h"
 
+#define RS_TYPE_COLOR_TRANSFORM rs_color_transform_get_type()
+#define RS_COLOR_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_COLOR_TRANSFORM, RSColorTransform))
+#define RS_COLOR_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_COLOR_TRANSFORM, RSColorTransformClass))
+#define RS_IS_COLOR_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_COLOR_TRANSFORM))
+#define RS_IS_COLOR_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RS_TYPE_COLOR_TRANSFORM))
+#define RS_COLOR_TRANSFORM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_COLOR_TRANSFORM, RSColorTransformClass))
+
+/* RSColorTransform typedef'ed in rawstudio.h */
+
+typedef struct _RSColorTransformClass {
+  GObjectClass parent_class;
+} RSColorTransformClass;
+
+GType rs_color_transform_get_type (void);
+
 #define COLOR_TRANSFORM(transform) void (transform) \
-(RS_COLOR_TRANSFORM *rct, \
+(RSColorTransform *rct, \
 		gint width, gint height, \
 		gushort *in, gint in_rowstride, \
 		void *out, gint out_rowstride)
 
-/* Public */
-typedef struct _RS_COLOR_TRANSFORM_PRIVATE RS_COLOR_TRANSFORM_PRIVATE;
-
-struct _RS_COLOR_TRANSFORM {
-	RS_COLOR_TRANSFORM_PRIVATE *priv;
-	COLOR_TRANSFORM(*transform);
-};
-
-extern RS_COLOR_TRANSFORM *rs_color_transform_new();
-extern void rs_color_transform_free(RS_COLOR_TRANSFORM *rct);
-extern gboolean rs_color_transform_set_gamma(RS_COLOR_TRANSFORM *rct, gdouble gamma);
-extern gboolean rs_color_transform_set_contrast(RS_COLOR_TRANSFORM *rct, gdouble contrast);
-extern gboolean rs_color_transform_set_premul(RS_COLOR_TRANSFORM *rct, gfloat *premul);
-extern gboolean rs_color_transform_set_matrix(RS_COLOR_TRANSFORM *rct, RS_MATRIX4 *matrix);
-void rs_color_transform_set_from_settings(RS_COLOR_TRANSFORM *rct, RS_SETTINGS_DOUBLE *settings, guint mask);
-extern gboolean rs_color_transform_set_curve(RS_COLOR_TRANSFORM *rct, gfloat *curve);
-extern void rs_color_transform_set_all(RS_COLOR_TRANSFORM *rct, gdouble gamma,
+extern RSColorTransform *rs_color_transform_new();
+extern COLOR_TRANSFORM(rs_color_transform_transform);
+extern gboolean rs_color_transform_set_gamma(RSColorTransform *rct, gdouble gamma);
+extern gboolean rs_color_transform_set_contrast(RSColorTransform *rct, gdouble contrast);
+extern gboolean rs_color_transform_set_premul(RSColorTransform *rct, gfloat *premul);
+extern gboolean rs_color_transform_set_matrix(RSColorTransform *rct, RS_MATRIX4 *matrix);
+void rs_color_transform_set_from_settings(RSColorTransform *rct, RS_SETTINGS_DOUBLE *settings, guint mask);
+extern gboolean rs_color_transform_set_curve(RSColorTransform *rct, gfloat *curve);
+extern void rs_color_transform_set_all(RSColorTransform *rct, gdouble gamma,
 	gdouble contrast, gfloat *premul, RS_MATRIX4 *matrix, gfloat *curve);
-extern void rs_color_transform_set_from_photo(RS_COLOR_TRANSFORM *rct, RS_PHOTO *photo, gint snapshot);
-extern gboolean rs_color_transform_set_output_format(RS_COLOR_TRANSFORM *rct, guint bits_per_color);
-extern void rs_color_transform_set_cms_transform(RS_COLOR_TRANSFORM *rct, void *transform);
-extern void rs_color_transform_set_adobe_matrix(RS_COLOR_TRANSFORM *rct, RS_MATRIX4 *matrix);
-extern void rs_color_transform_make_histogram(RS_COLOR_TRANSFORM *rct, RS_IMAGE16 *input, guint histogram[3][256]);
+extern void rs_color_transform_set_from_photo(RSColorTransform *rct, RS_PHOTO *photo, gint snapshot);
+extern gboolean rs_color_transform_set_output_format(RSColorTransform *rct, guint bits_per_color);
+extern void rs_color_transform_set_cms_transform(RSColorTransform *rct, void *transform);
+extern void rs_color_transform_set_adobe_matrix(RSColorTransform *rct, RS_MATRIX4 *matrix);
+extern void rs_color_transform_make_histogram(RSColorTransform *rct, RS_IMAGE16 *input, guint histogram[3][256]);
 
 extern COLOR_TRANSFORM(*transform_nocms8);
 extern COLOR_TRANSFORM(*transform_cms8);

Modified: trunk/src/rs-curve.c
===================================================================
--- trunk/src/rs-curve.c	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rs-curve.c	2008-07-24 14:42:51 UTC (rev 1932)
@@ -43,7 +43,7 @@
 	/* For drawing the histogram */
 	guint histogram_data[4][256];
 	guchar *bg_buffer;
-	RS_COLOR_TRANSFORM *rct;
+	RSColorTransform *rct;
 	RS_SETTINGS_DOUBLE *settings;
 };
 

Modified: trunk/src/rs-histogram.c
===================================================================
--- trunk/src/rs-histogram.c	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rs-histogram.c	2008-07-24 14:42:51 UTC (rev 1932)
@@ -20,6 +20,7 @@
 #include <gtk/gtk.h>
 #include "rs-histogram.h"
 #include "rs-color-transform.h"
+#include "rs-math.h"
 
 struct _RSHistogramWidget
 {
@@ -28,7 +29,7 @@
 	gint height;
 	GdkPixmap *blitter;
 	RS_IMAGE16 *image;
-	RS_COLOR_TRANSFORM *rct;
+	RSColorTransform *rct;
 	guint input_samples[4][256];
 	guint *output_samples[4];
 };
@@ -136,10 +137,10 @@
 /**
  * Set color transform to be used when rendering histogram
  * @param histogram A RSHistogramWidget
- * @param rct A RS_COLOR_TRANSFORM
+ * @param rct A RSColorTransform
  */
 void
-rs_histogram_set_color_transform(RSHistogramWidget *histogram, RS_COLOR_TRANSFORM *rct)
+rs_histogram_set_color_transform(RSHistogramWidget *histogram, RSColorTransform *rct)
 {
 	g_return_if_fail (RS_IS_HISTOGRAM_WIDGET(histogram));
 	g_return_if_fail (rct);

Modified: trunk/src/rs-histogram.h
===================================================================
--- trunk/src/rs-histogram.h	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rs-histogram.h	2008-07-24 14:42:51 UTC (rev 1932)
@@ -24,9 +24,9 @@
 /**
  * Set color transform to be used when rendering histogram
  * @param histogram A RSHistogramWidget
- * @param rct A RS_COLOR_TRANSFORM
+ * @param rct A RSColorTransform
  */
-extern void rs_histogram_set_color_transform(RSHistogramWidget *histogram, RS_COLOR_TRANSFORM *rct);
+extern void rs_histogram_set_color_transform(RSHistogramWidget *histogram, RSColorTransform *rct);
 
 /**
  * Redraw a RSHistogramWidget

Modified: trunk/src/rs-job.c
===================================================================
--- trunk/src/rs-job.c	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rs-job.c	2008-07-24 14:42:51 UTC (rev 1932)
@@ -102,12 +102,12 @@
 				gint row;
 				RS_IMAGE16 *in = RS_IMAGE16(job->arg1);
 				GdkPixbuf *out = (GdkPixbuf *) job->arg2;
-				RS_COLOR_TRANSFORM *rct = (RS_COLOR_TRANSFORM *) job->arg3;
+				RSColorTransform *rct = RS_COLOR_TRANSFORM(job->arg3);
 
 				/* Render 2 row at a time for quick breakability */
 				for(row=0;row<(in->h-2);row+=2)
 				{
-					rct->transform(
+					rs_color_transform_transform(
 						rct,
 						in->w, 2,
 						GET_PIXEL(in, 0, row), in->rowstride,
@@ -116,7 +116,7 @@
 				}
 				if (row<(in->h-1))
 				{
-					rct->transform(
+					rs_color_transform_transform(
 						rct,
 						in->w, 1,
 						GET_PIXEL(in, 0, row), in->rowstride,
@@ -255,7 +255,7 @@
  * @param rct A color transform to use for the render
  */
 RS_JOB *
-rs_job_add_render(RS_IMAGE16 *in, GdkPixbuf *out, RS_COLOR_TRANSFORM *rct)
+rs_job_add_render(RS_IMAGE16 *in, GdkPixbuf *out, RSColorTransform *rct)
 {
 	RS_JOB *job = g_new0(RS_JOB, 1);
 

Modified: trunk/src/rs-job.h
===================================================================
--- trunk/src/rs-job.h	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rs-job.h	2008-07-24 14:42:51 UTC (rev 1932)
@@ -57,6 +57,6 @@
  * @param rct A color transform to use for the render
  */
 RS_JOB *
-rs_job_add_render(RS_IMAGE16 *in, GdkPixbuf *out, RS_COLOR_TRANSFORM *rct);
+rs_job_add_render(RS_IMAGE16 *in, GdkPixbuf *out, RSColorTransform *rct);
 
 #endif /* RS_JOB_H */

Modified: trunk/src/rs-preview-widget.c
===================================================================
--- trunk/src/rs-preview-widget.c	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/rs-preview-widget.c	2008-07-24 14:42:51 UTC (rev 1932)
@@ -137,7 +137,7 @@
 	RS_IMAGE16 *scaled[MAX_VIEWS];
 	RS_IMAGE16 *sharpened[MAX_VIEWS];
 	GdkPixbuf *buffer[MAX_VIEWS];
-	RS_COLOR_TRANSFORM *rct[MAX_VIEWS];
+	RSColorTransform *rct[MAX_VIEWS];
 	gint dirty[MAX_VIEWS]; /* Dirty flag, used for multiple things */
 };
 
@@ -1035,7 +1035,7 @@
 	if (gdk_rectangle_intersect(&image, dirty, &clip))
 	{
 		if ((clip.width>0) && (clip.height>0))
-			preview->rct[view]->transform(preview->rct[view],
+			rs_color_transform_transform(preview->rct[view],
 				clip.width, clip.height,
 				GET_PIXEL(source, clip.x, clip.y), source->rowstride,
 				GET_PIXBUF_PIXEL(preview->buffer[view], clip.x, clip.y), gdk_pixbuf_get_rowstride(preview->buffer[view]));
@@ -2131,7 +2131,7 @@
 	cbdata->y = real_y;
 
 	/* Render current pixel */
-	preview->rct[view]->transform(preview->rct[view],
+	rs_color_transform_transform(preview->rct[view],
 		1, 1,
 		cbdata->pixel, preview->scaled[view]->rowstride,
 		&cbdata->pixel8, 1);

Modified: trunk/src/tiff-meta.c
===================================================================
--- trunk/src/tiff-meta.c	2008-07-24 14:21:23 UTC (rev 1931)
+++ trunk/src/tiff-meta.c	2008-07-24 14:42:51 UTC (rev 1932)
@@ -1019,7 +1019,7 @@
 			gint c;
 			gfloat pre_mul[4];
 			RS_IMAGE16 *image;
-			RS_COLOR_TRANSFORM *rct = rs_color_transform_new();
+			RSColorTransform *rct = rs_color_transform_new();
 			image = rs_image16_transform(photo->input, NULL,
 				NULL, NULL, photo->crop, 128, 128, TRUE, -1.0,
 				photo->angle, photo->orientation, NULL);
@@ -1029,13 +1029,13 @@
 				pre_mul[c] = (gfloat) meta->cam_mul[c];
 
 			rs_color_transform_set_premul(rct, pre_mul);
-			rct->transform(rct, image->w, image->h, image->pixels,
+			rs_color_transform_transform(rct, image->w, image->h, image->pixels,
 					image->rowstride, gdk_pixbuf_get_pixels(pixbuf),
 					gdk_pixbuf_get_rowstride(pixbuf));
 
 			g_object_unref(photo);
 			g_object_unref(image);
-			rs_color_transform_free(rct);
+			g_object_unref(rct);
 		}
 	}
 




More information about the Rawstudio-commit mailing list