Permalink
Browse files

* configure.ac, Makefile.am, gdkcutter-pixbuf/,

  gdkcutter-pixbuf.pc.in, test/fixtures/pixbuf/,
  test/test-gdkcut-pixbuf.c: start GdkPixbuf support.


git-svn-id: https://cutter.svn.sourceforge.net/svnroot/cutter/cutter/trunk@2399 10a583ed-1e3d-0410-b285-c80daaaae891
  • Loading branch information...
1 parent 2f955cf commit 3537000d73d342a550756f91cb6a45752e44532c @kou kou committed Sep 15, 2008
View
@@ -1,5 +1,9 @@
2008-09-15 Kouhei Sutou <kou@cozmixng.org>
+ * configure.ac, Makefile.am, gdkcutter-pixbuf/,
+ gdkcutter-pixbuf.pc.in, test/fixtures/pixbuf/,
+ test/test-gdkcut-pixbuf.c: start GdkPixbuf support.
+
* cutter/Makefile.am, gcutter/Makefile.am: cleanup.
2008-09-14 Kouhei Sutou <kou@cozmixng.org>
View
@@ -1,16 +1,17 @@
ACLOCAL_AMFLAGS = -I m4macros
-SUBDIRS = \
- m4macros \
- gcutter \
- cutter \
- module \
- test \
- sample \
- gst-plugins \
- po \
- misc \
- doc \
+SUBDIRS = \
+ m4macros \
+ gcutter \
+ gdkcutter-pixbuf \
+ cutter \
+ module \
+ test \
+ sample \
+ gst-plugins \
+ po \
+ misc \
+ doc \
html
pkgconfigdir = $(libdir)/pkgconfig
@@ -19,6 +20,10 @@ pkgconfig_DATA = \
gcutter.pc \
libcutter.pc
+if HAVE_GDK_PIXBUF
+pkgconfig_DATA += gdkcutter-pixbuf.pc
+endif
+
EXTRA_DIST = \
autogen.sh \
TUTORIAL \
View
@@ -145,6 +145,19 @@ AM_PATH_GLIB_2_0($GLIB_REQUIRED,
[AC_MSG_ERROR([GLib >= $GLIB_REQUIRED required.])],
[gmodule gobject gthread])
+dnl **************************************************************
+dnl Check for GdkPixbuf
+dnl **************************************************************
+PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0,
+ [gdk_pixbuf_exists=yes], [gdk_pixbuf_exists=no])
+AC_SUBST(GDK_PIXBUF_CFLAGS)
+AC_SUBST(GDK_PIXBUF_LIBS)
+
+if test "$gdk_pixbuf_exists" = "yes"; then
+ AC_DEFINE(HAVE_GDK_PIXBUF, 1, [Define to 1 if you have gdk-pixbuf installed])
+fi
+AM_CONDITIONAL([HAVE_GDK_PIXBUF], [test "$gdk_pixbuf_exists" = "yes"])
+
# Checks for libraries.
AC_MSG_CHECKING([whether to try to use BFD])
AC_ARG_ENABLE([bfd],
@@ -461,8 +474,10 @@ AC_CONFIG_FILES([Makefile
cutter.pc
gcutter.pc
libcutter.pc
+ gdkcutter-pixbuf.pc
m4macros/Makefile
gcutter/Makefile
+ gdkcutter-pixbuf/Makefile
cutter/cut-version.h
cutter/Makefile
module/Makefile
@@ -504,6 +519,7 @@ AC_CONFIG_FILES([Makefile
test/fixtures/repository/Makefile
test/fixtures/xml-stream/Makefile
test/fixtures/file-stream-reader/Makefile
+ test/fixtures/pixbuf/Makefile
test/lib/Makefile
po/Makefile.in
misc/Makefile
View
@@ -3,7 +3,6 @@ exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
includedir=@includedir@
-cutter=${bindir}/cutter@EXEEXT@
Name: GCutter
Description: Cutter with GLib support.
View
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+bindir=@bindir@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: GdkCutter Pixbuf
+Description: Cutter with gdk-pixbuf support.
+Version: @VERSION@
+Requires: gcutter >= @VERSION@, gdk-pixbuf-2.0
+Libs: -L${libdir} -lgdkcutter-pixbuf
@@ -0,0 +1,37 @@
+INCLUDES = \
+ -I$(top_builddir) \
+ -I$(top_srcdir)
+
+AM_CFLAGS = \
+ $(CUTTER_CFLAGS) \
+ $(GDK_PIXBUF_CFLAGS) \
+ $(COVERAGE_CFLAGS)
+
+CLEANFILES = *.gcno *.gcda
+
+if HAVE_GDK_PIXBUF
+lib_LTLIBRARIES = libgdkcutter-pixbuf.la
+endif
+
+gdkcutter_pixbuf_public_headers = \
+ gdkcut-pixbuf-assertions.h \
+ gdkcut-pixbuf.h
+
+pkginclude_HEADERS = \
+ gdkcutter-pixbuf.h
+
+gdkcutter_pixbuf_includedir=$(includedir)/gdkcutter-pixbuf
+gdkcutter_pixbuf_include_HEADERS = \
+ $(gdkcutter_pixbuf_public_headers)
+
+libgdkcutter_pixbuf_la_SOURCES = \
+ $(gcutter_public_headers) \
+ gdkcut-pixbuf.c
+
+libgdkcutter_pixbuf_la_LDFLAGS = \
+ -version-info $(LT_VERSION_INFO) \
+ -no-undefined
+
+libgdkcutter_pixbuf_la_LIBADD = \
+ $(top_builddir)/cutter/libcutter.la \
+ $(GDK_PIXBUF_LIBS)
@@ -0,0 +1,110 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2008 Kouhei Sutou <kou@cozmixng.org>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __GDKCUT_PIXBUF_ASSERTIONS_H__
+#define __GDKCUT_PIXBUF_ASSERTIONS_H__
+
+#include <glib.h>
+
+#include <gdkcutter-pixbuf/gdkcut-pixbuf.h>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: gdkcut-pixbuf-assertions
+ * @title: Assertions with gdk-pixbuf support
+ * @short_description: Checks that your program works as you
+ * expect with gdk-pixbuf support.
+ *
+ */
+
+/**
+ * gdkcut_pixbuf_assert_equal:
+ * @expected: an expected GdkPixbuf *.
+ * @actual: an actual GdkPixbuf *.
+ * @threshold: an threshold used for detecting pixel difference.
+ * @...: optional format string, followed by parameters to insert
+ * into the format string (as with printf())
+ *
+ * Passes if @expected == @actual within threshold difference.
+ *
+ * Since: 1.0.5
+ */
+#define gdkcut_pixbuf_assert_equal(expected, actual, threshold, ...) do \
+{ \
+ GdkPixbuf *_expected; \
+ GdkPixbuf *_actual; \
+ gint _threshold; \
+ \
+ _expected = (expected); \
+ _actual = (actual); \
+ _threshold = (threshold); \
+ if (gdkcut_pixbuf_equal_content(_expected, _actual, _threshold)) { \
+ cut_test_pass(); \
+ } else { \
+ const gchar *message; \
+ \
+ message = cut_take_printf("<%s == %s> (%s)", \
+ #expected, #actual, #threshold); \
+ if (gdkcut_pixbuf_equal_property(_expected, _actual)) { \
+ gchar *diff_image_file; \
+ \
+ diff_iamge_file = \
+ gdkcut_pixbuf_save_diff(_expected, \
+ _actual, \
+ threshold, \
+ cut_take_printf("%s-%d", \
+ __FILE__, \
+ __LINE__)); \
+ message = cut_take_printf("%s\n" \
+ " threshold: <%d>\n" \
+ "diff image: <%s>", \
+ message, \
+ _threshold, \
+ diff_iamge_file); \
+ g_free(diff_iamge_file); \
+ } else { \
+ gchar *expected_property; \
+ gchar *actual_property; \
+ \
+ expected_property = \
+ gdkcut_pixbuf_inspect_property(_expected); \
+ actual_property = \
+ gdkcut_pixbuf_inspect_property(_actual); \
+ message = cut_take_printf("%s\n" \
+ "expected: <%s>\n" \
+ " but was: <%s>", \
+ message, \
+ expected_property, \
+ actual_property); \
+ message = cut_append_diff(message, \
+ expected_property, \
+ actual_property); \
+ } \
+ cut_test_fail(FAILURE, message, ## __VA_ARGS__); \
+ } \
+} while(0)
+
+G_END_DECLS
+
+#endif /* __GDKCUT_PIXBUF_ASSERTIONS_H__ */
+
+/*
+vi:nowrap:ai:expandtab:sw=4
+*/
@@ -0,0 +1,133 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2008 Kouhei Sutou <kou@cozmixng.org>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "gdkcut-pixbuf.h"
+
+gboolean
+gdkcut_pixbuf_equal_property (const GdkPixbuf *pixbuf1, const GdkPixbuf *pixbuf2)
+{
+ if (pixbuf1 == pixbuf2)
+ return TRUE;
+
+ if (pixbuf1 == NULL || pixbuf2 == NULL)
+ return FALSE;
+
+ if (gdk_pixbuf_get_n_channels(pixbuf1) != gdk_pixbuf_get_n_channels(pixbuf2))
+ return FALSE;
+
+ if (gdk_pixbuf_get_has_alpha(pixbuf1) != gdk_pixbuf_get_has_alpha(pixbuf2))
+ return FALSE;
+
+ if (gdk_pixbuf_get_bits_per_sample(pixbuf1) !=
+ gdk_pixbuf_get_bits_per_sample(pixbuf2))
+ return FALSE;
+
+ if (gdk_pixbuf_get_width(pixbuf1) != gdk_pixbuf_get_width(pixbuf2))
+ return FALSE;
+
+ if (gdk_pixbuf_get_height(pixbuf1) != gdk_pixbuf_get_height(pixbuf2))
+ return FALSE;
+
+ if (gdk_pixbuf_get_rowstride(pixbuf1) != gdk_pixbuf_get_rowstride(pixbuf2))
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+pixels_equal (const guchar *pixels1, const guchar *pixels2,
+ guint threshold, gint n_channels, gboolean has_alpha,
+ gint bits_per_sample, gint width, gint height, gint row_stride)
+{
+ gint x, y;
+
+ for (y = 0; y < height; y++) {
+ const guchar *row1, *row2;
+
+ row1 = pixels1 + y * row_stride;
+ row2 = pixels2 + y * row_stride;
+ for (x = 0; x < width; x++) {
+ gint channel;
+
+ for (channel = 0; channel < n_channels; channel++) {
+ guchar value1, value2;
+
+ value1 = row1[x + channel];
+ value2 = row2[x + channel];
+ if (value1 != value2) {
+ guchar diff;
+
+ if (value1 > value2)
+ diff = value1 - value2;
+ else
+ diff = value2 - value1;
+
+ if (diff > threshold)
+ return FALSE;
+ }
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+
+gboolean
+gdkcut_pixbuf_equal_content (const GdkPixbuf *pixbuf1,
+ const GdkPixbuf *pixbuf2,
+ guint threshold)
+{
+ if (pixbuf1 == pixbuf2)
+ return TRUE;
+
+ if (!gdkcut_pixbuf_equal_property(pixbuf1, pixbuf2))
+ return FALSE;
+
+ return pixels_equal(gdk_pixbuf_get_pixels(pixbuf1),
+ gdk_pixbuf_get_pixels(pixbuf2),
+ threshold,
+ gdk_pixbuf_get_n_channels(pixbuf1),
+ gdk_pixbuf_get_has_alpha(pixbuf1),
+ gdk_pixbuf_get_bits_per_sample(pixbuf1),
+ gdk_pixbuf_get_width(pixbuf1),
+ gdk_pixbuf_get_height(pixbuf1),
+ gdk_pixbuf_get_rowstride(pixbuf1));
+}
+
+GdkPixbuf *
+gdkcut_pixbuf_diff (const GdkPixbuf *pixbuf1,
+ const GdkPixbuf *pixbuf2,
+ guint threshold)
+{
+ return NULL;
+}
+
+gchar *
+gdkcut_pixbuf_save_diff (const GdkPixbuf *pixbuf1,
+ const GdkPixbuf *pixbuf2,
+ guint threshold,
+ const gchar *prefix)
+{
+ return NULL;
+}
+
+/*
+vi:nowrap:ai:expandtab:sw=4:ts=4
+*/
Oops, something went wrong.

0 comments on commit 3537000

Please sign in to comment.