Index: tga.c
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/common/tga.c,v
retrieving revision 1.23.2.2
retrieving revision 1.23.2.3
diff -u -r1.23.2.2 -r1.23.2.3
--- tga.c	2001/08/01 16:44:12	1.23.2.2
+++ tga.c	2002/01/24 07:42:10	1.23.2.3
@@ -1,7 +1,7 @@
 /* The GIMP -- an image manipulation program
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
- * $Id: tga.c,v 1.23.2.2 2001/08/01 16:44:12 nicklamb Exp $
+ * $Id: tga.c,v 1.23.2.3 2002/01/24 07:42:10 nicklamb Exp $
  * TrueVision Targa loading and saving file filter for the Gimp.
  * Targa code Copyright (C) 1997 Raphael FRANCOIS and Gordon Matzigkeit
  *
@@ -94,11 +94,13 @@
 typedef struct _TgaSaveVals
 {
   gint rle;
+  gint origin;
 } TgaSaveVals;
 
 static TgaSaveVals tsvals =
 {
-  1,    /* rle */
+  1,    /* rle = ON */
+  1, 	/* origin = bottom left */
 };
 
 typedef struct _TgaSaveInterface
@@ -231,7 +233,8 @@
     { GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" },
     { GIMP_PDB_STRING, "filename", "The name of the file to save the image in" },
     { GIMP_PDB_STRING, "raw_filename", "The name of the file to save the image in" },
-    { GIMP_PDB_INT32, "rle", "Use RLE compression" }
+    { GIMP_PDB_INT32, "rle", "Use RLE compression" },
+    { GIMP_PDB_INT32, "origin", "Image origin (0 = top-left, 1 = bottom-left)"}
 
   } ;
   static gint nsave_args = sizeof (save_args) / sizeof (save_args[0]);
@@ -352,7 +355,7 @@
 
 	case GIMP_RUN_NONINTERACTIVE:
 	  /*  Make sure all the arguments are there!  */
-	  if (nparams != 6)
+	  if (nparams != 7)
 	    {
 	      status = GIMP_PDB_CALLING_ERROR;
 	    }
@@ -1066,25 +1069,25 @@
     case GIMP_INDEXEDA_IMAGE:
       out_bpp = 1;
       header[16] = 8; /* bpp */
-      header[17] = 0x20; /* alpha + orientation */
+      header[17] = (tsvals.origin) ? 0 :  0x20; /* alpha + orientation */
       break;
 
     case GIMP_GRAYA_IMAGE:
       out_bpp = 2;
       header[16] = 16; /* bpp */
-      header[17] = 0x28; /* alpha + orientation */
+      header[17] = (tsvals.origin) ? 8 : 0x28; /* alpha + orientation */
       break;
 
     case GIMP_RGB_IMAGE:
       out_bpp = 3;
       header[16] = 24; /* bpp */
-      header[17] = 0x20; /* alpha + orientation */
+      header[17] = (tsvals.origin) ? 0 : 0x20; /* alpha + orientation */
       break;
 
     case GIMP_RGBA_IMAGE:
       out_bpp = 4;
       header[16] = 32; /* bpp */
-      header[17] = 0x28; /* alpha + orientation */
+      header[17] = (tsvals.origin) ? 8 : 0x28; /* alpha + orientation */
       break;
     }
 
@@ -1112,7 +1115,14 @@
 
   for (row = 0; row < height; ++row)
     {
-      gimp_pixel_rgn_get_rect (&pixel_rgn, pixels, 0, row, width, 1);
+      if(tsvals.origin)
+        {
+          gimp_pixel_rgn_get_rect (&pixel_rgn, pixels, 0, height-(row+1), width, 1);
+        } 
+      else 
+        {
+          gimp_pixel_rgn_get_rect (&pixel_rgn, pixels, 0, row, width, 1);
+        }
 
       if (dtype == GIMP_RGB_IMAGE)
 	{
@@ -1164,6 +1174,7 @@
 {
   GtkWidget *dlg;
   GtkWidget *toggle;
+  GtkWidget *origin;
   GtkWidget *frame;
   GtkWidget *vbox;
 
@@ -1201,6 +1212,15 @@
 		      &tsvals.rle);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), tsvals.rle);
   gtk_widget_show (toggle);
+
+  /*  origin  */
+  origin = gtk_check_button_new_with_label (_("Origin at bottom left"));
+  gtk_box_pack_start (GTK_BOX (vbox), origin, FALSE, FALSE, 0);
+  gtk_signal_connect (GTK_OBJECT (origin), "toggled",
+		      GTK_SIGNAL_FUNC (gimp_toggle_button_update),
+		      &tsvals.origin);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (origin), tsvals.origin);
+  gtk_widget_show (origin);
 
   gtk_widget_show (vbox);
   gtk_widget_show (frame);
