[Rawstudio-commit] r903 - trunk/src

Anders Brander anders at brander.dk
Fri Oct 20 20:04:26 CEST 2006


Author: abrander
Date: 2006-10-20 20:04:26 +0200 (Fri, 20 Oct 2006)
New Revision: 903

Modified:
   trunk/src/rs-image.c
Log:
Simplified rs_image16_crop().

Modified: trunk/src/rs-image.c
===================================================================
--- trunk/src/rs-image.c	2006-10-20 17:02:35 UTC (rev 902)
+++ trunk/src/rs-image.c	2006-10-20 18:04:26 UTC (rev 903)
@@ -512,13 +512,18 @@
 
 /* Crop image _INPLACE_ */
 void
-rs_image16_crop(RS_IMAGE16 **image, RS_RECT *rect)
+rs_image16_crop(RS_IMAGE16 **image, RS_RECT *rect_in)
 {
 	RS_IMAGE16 *in = *image;
 	RS_IMAGE16 *out = *image;
-	gint orientation = in->orientation;
+	RS_RECT im;
+	RS_RECT rect;
+	im.x1 = 0;
+	im.x2 = in->w-1;
+	im.y1 = 0;
+	im.y2 = in->h-1;
 
-	g_assert (IS_RECT_WITHIN_IMAGE(in, rect));
+	rs_rect_union(rect_in, &im, &rect);
 
 	if (!in->parent)
 	{
@@ -531,18 +536,10 @@
 		out->orientation = in->orientation;
 	}
 
-	if (orientation && 0x1) /* portrait */
-	{
-		out->w = rect->y2 - rect->y1;
-		out->h = rect->x2 - rect->x1;
-	}
-	else /* landscape */
-	{
-		out->w = rect->x2 - rect->x1;
-		out->h = rect->y2 - rect->y1;
-	}
+	out->w = rect.x2 - rect.x1;
+	out->h = rect.y2 - rect.y1;
 
-	out->pixels = in->pixels + rect->y1*in->rowstride + rect->x1*in->pixelsize;
+	out->pixels = in->pixels + rect.y1*in->rowstride + rect.x1*in->pixelsize;
 	*image = out;
 	return;
 }




More information about the Rawstudio-commit mailing list