[gimp] app/tests: Add gimp_test_utils_create_image()



commit 2056042e967b135d2aa818351a927f3b68ff3bdf
Author: Martin Nordholts <martinn src gnome org>
Date:   Mon Oct 25 08:47:27 2010 +0200

    app/tests: Add gimp_test_utils_create_image()

 app/tests/gimp-app-test-utils.c |   56 ++++++++++++++++++++++++++++++++++++++-
 app/tests/gimp-app-test-utils.h |    9 ++++--
 2 files changed, 61 insertions(+), 4 deletions(-)
---
diff --git a/app/tests/gimp-app-test-utils.c b/app/tests/gimp-app-test-utils.c
index b8eda87..6a9af0f 100644
--- a/app/tests/gimp-app-test-utils.c
+++ b/app/tests/gimp-app-test-utils.c
@@ -15,7 +15,15 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <glib.h>
+#include "config.h"
+
+#include <gegl.h>
+
+#include "core/core-types.h"
+
+#include "core/gimp.h"
+#include "core/gimpimage.h"
+#include "core/gimplayer.h"
 
 #include "gimp-app-test-utils.h"
 
@@ -77,3 +85,49 @@ gimp_test_utils_setup_menus_dir (void)
                                      "menus" /*subdir*/,
                                      "GIMP_TESTING_MENUS_DIR" /*target_env_var*/);
 }
+
+/**
+ * gimp_test_utils_create_image:
+ * @gimp:   A #Gimp instance.
+ * @width:  Width of image (and layer)
+ * @height: Height of image (and layer)
+ *
+ * Creates a new image of a given size with one layer of same size and
+ * a display.
+ *
+ * Returns: The new #GimpImage.
+ **/
+GimpImage *
+gimp_test_utils_create_image (Gimp *gimp,
+                              gint  width,
+                              gint  height)
+{
+  GimpImage *image;
+  GimpLayer *layer;
+
+  image = gimp_image_new (gimp,
+                          width,
+                          height,
+                          GIMP_RGB);
+
+  layer = gimp_layer_new (image,
+                          width,
+                          height,
+                          GIMP_RGBA_IMAGE,
+                          "layer1",
+                          1.0,
+                          GIMP_NORMAL_MODE);
+
+  gimp_image_add_layer (image,
+                        layer,
+                        NULL /*parent*/,
+                        0 /*position*/,
+                        FALSE /*push_undo*/);
+
+  gimp_create_display (gimp,
+                       image,
+                       GIMP_UNIT_PIXEL,
+                       1.0 /*scale*/);
+
+  return image;
+}
diff --git a/app/tests/gimp-app-test-utils.h b/app/tests/gimp-app-test-utils.h
index af3feb1..3224cf4 100644
--- a/app/tests/gimp-app-test-utils.h
+++ b/app/tests/gimp-app-test-utils.h
@@ -19,9 +19,12 @@
 #define  __GIMP_RECTANGLE_SELECT_TOOL_H__
 
 
-void  gimp_test_utils_set_gimp2_directory (const gchar *root_env_var,
-                                           const gchar *subdir);
-void  gimp_test_utils_setup_menus_dir     (void);
+void        gimp_test_utils_set_gimp2_directory (const gchar *root_env_var,
+                                                 const gchar *subdir);
+void        gimp_test_utils_setup_menus_dir     (void);
+GimpImage * gimp_test_utils_create_image        (Gimp        *gimp,
+                                                 gint         width,
+                                                 gint         height);
 
 
 #endif /* __GIMP_RECTANGLE_SELECT_TOOL_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]