summaryrefslogtreecommitdiff
path: root/pngtrans.c
diff options
context:
space:
mode:
Diffstat (limited to 'pngtrans.c')
-rw-r--r--pngtrans.c62
1 files changed, 1 insertions, 61 deletions
diff --git a/pngtrans.c b/pngtrans.c
index aeb910e..7aaf0b8 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -4,67 +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_from_pixbuf (GdkPixbuf *pixbuf)
-{
- complex_image_t *result;
- uint8_t *pdata;
- int w, h, s;
- int i, j;
- gboolean has_alpha;
- int n_channels;
-
- w = gdk_pixbuf_get_width (pixbuf);
- h = gdk_pixbuf_get_height (pixbuf);
- s = gdk_pixbuf_get_rowstride (pixbuf);
- pdata = gdk_pixbuf_get_pixels (pixbuf);
- has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
- n_channels = 3 + has_alpha;
-
- printf ("has alpha: %d\n", has_alpha);
-
- result = complex_image_new (w, h);
-
- for (i = 0; i < h; ++i)
- {
- for (j = 0; j < w; ++j)
- {
- uint8_t *p = &pdata[i * s + j * n_channels];
- int idx = i * w + j;
-
- result->red[idx].re = p[0] / 255.0;
- result->green[idx].re = p[1] / 255.0;
- result->blue[idx].re = p[2] / 255.0;
- }
- }
-
- return result;
-}
+#include "image.h"
typedef uint8_t (* convert_t) (complex_t c);