diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-08-01 20:13:06 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-08-01 20:13:06 -0400 |
commit | b35c4c031ae610bd21cf2dfd5876f54b2539079d (patch) | |
tree | 23e6acd830a65e03b0678f4cbc790bea088da636 | |
parent | 6073c155a3caf6feac4b19851777b53c70185e3f (diff) |
Move image support to separate file
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | complex.h | 1 | ||||
-rw-r--r-- | image.c | 51 | ||||
-rw-r--r-- | image.h | 21 | ||||
-rw-r--r-- | noise2.c | 59 |
5 files changed, 76 insertions, 60 deletions
@@ -16,5 +16,5 @@ trans: pngtrans.c fft.c fft.h bluenoise: fft.c fft.h bluenoise.c gtk-utils.c $(CC) $(GTKFLAGS) -o bluenoise fft.c bluenoise.c gtk-utils.c $(LDFLAGS) -noise2: noise2.c fft.c fft.h - $(CC) $(GTKFLAGS) -o noise2 noise2.c fft.c $(LDFLAGS) +noise2: noise2.c fft.c fft.h image.c image.h + $(CC) $(GTKFLAGS) -o noise2 noise2.c image.c fft.c $(LDFLAGS) @@ -1,4 +1,5 @@ #ifndef COMPLEX_H +#define COMPLEX_H #include <math.h> @@ -0,0 +1,51 @@ +#include <glib.h> +#include "image.h" + +complex_image_t * +complex_image_new (int width, int height) +{ + complex_image_t *image = g_new0 (complex_image_t, 1); + + image->width = width; + image->height = height; + image->red = g_new0 (complex_t, width * height); + image->green = g_new0 (complex_t, width * height); + image->blue = g_new0 (complex_t, width * height); + + return image; +} + +complex_image_t * +complex_image_copy (complex_image_t *image) +{ + complex_image_t *copy = complex_image_new (image->width, image->height); + int width = image->width; + int height = image->height; + + copy->red = g_memdup (image->red, width * height * sizeof (complex_t)); + copy->green = g_memdup (image->green, width * height * sizeof (complex_t)); + copy->blue = g_memdup (image->blue, width * height * sizeof (complex_t)); + + return copy; +} + +void +complex_image_subtract (complex_image_t *image, complex_image_t *other) +{ + int i, j; + int h = image->height; + int w = image->width; + + for (i = 0; i < h; ++i) + { + for (j = 0; j < w; ++j) + { + int idx = i * w + j; + + image->red[idx] = complex_sub (image->red[idx], other->red[idx]); + image->green[idx] = complex_sub (image->green[idx], other->green[idx]); + image->blue[idx] = complex_sub (image->blue[idx], other->blue[idx]); + } + } +} + @@ -0,0 +1,21 @@ +#include "complex.h" + +typedef struct complex_image_t complex_image_t; +struct complex_image_t +{ + int width; + int height; + complex_t *red; + complex_t *green; + complex_t *blue; +}; + +complex_image_t * +complex_image_new (int width, int height); + +complex_image_t * +complex_image_copy (complex_image_t *image); + +void +complex_image_subtract (complex_image_t *image, + complex_image_t *other); @@ -4,64 +4,7 @@ #include <gtk/gtk.h> #include <gdk/gdkpixbuf.h> #include "fft.h" - -typedef struct complex_image_t complex_image_t; -struct complex_image_t -{ - int width; - int height; - complex_t *red; - complex_t *green; - complex_t *blue; -}; - -static complex_image_t * -complex_image_new (int width, int height) -{ - complex_image_t *image = g_new0 (complex_image_t, 1); - - image->width = width; - image->height = height; - image->red = g_new0 (complex_t, width * height); - image->green = g_new0 (complex_t, width * height); - image->blue = g_new0 (complex_t, width * height); - - return image; -} - -static complex_image_t * -complex_image_copy (complex_image_t *image) -{ - complex_image_t *copy = complex_image_new (image->width, image->height); - int width = image->width; - int height = image->height; - - copy->red = g_memdup (image->red, width * height * sizeof (complex_t)); - copy->green = g_memdup (image->green, width * height * sizeof (complex_t)); - copy->blue = g_memdup (image->blue, width * height * sizeof (complex_t)); - - return copy; -} - -static void -complex_image_subtract (complex_image_t *image, complex_image_t *other) -{ - int i, j; - int h = image->height; - int w = image->width; - - for (i = 0; i < h; ++i) - { - for (j = 0; j < w; ++j) - { - int idx = i * w + j; - - image->red[idx] = complex_sub (image->red[idx], other->red[idx]); - image->green[idx] = complex_sub (image->green[idx], other->green[idx]); - image->blue[idx] = complex_sub (image->blue[idx], other->blue[idx]); - } - } -} +#include "image.h" static complex_image_t * complex_image_from_pixbuf (GdkPixbuf *pixbuf) |