Skip to content

Commit

Permalink
Merged the two main branches.
Browse files Browse the repository at this point in the history
  • Loading branch information
schani committed Dec 16, 2007
2 parents dabc68c + 50a2f9c commit 62f5bce
Show file tree
Hide file tree
Showing 41 changed files with 1,838 additions and 2,843 deletions.
5 changes: 5 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
syntax: glob
.svn
*~
*.o
imagesize
metapixel
metapixel.1
50 changes: 29 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
PREFIX = /usr/local
INSTALL = install
MANPAGE_XSL = /sw/share/xml/xsl/docbook-xsl/manpages/docbook.xsl
MANPAGE_XSL = /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl

BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/man

VERSION = 0.11
VERSION = 1.1.0

DEBUG = -g
#OPTIMIZE = -O2
#PROFILE = -pg

MACOS_LDOPTS = -L/sw/lib
MACOS_CCOPTS = -I/sw/include
MACOS_CFLAGS = -I/sw/include

CC = gcc
CFLAGS = $(MACOS_CFLAGS) $(OPTIMIZE) $(DEBUG) $(PROFILE)
FORMATDEFS = -DRWIMG_JPEG -DRWIMG_PNG -DRWIMG_GIF

export CFLAGS CC FORMATDEFS

LDOPTS = $(MACOS_LDOPTS) -L/usr/X11R6/lib $(PROFILE) $(DEBUG)
CCOPTS = $(MACOS_CCOPTS) -I/usr/X11R6/include -I/usr/X11R6/include/X11 -I. -Wall $(OPTIMIZE) $(DEBUG) $(PROFILE) \
-DMETAPIXEL_VERSION=\"$(VERSION)\" -DRWIMG_JPEG -DRWIMG_PNG -DCONSOLE_OUTPUT
CCOPTS = $(CFLAGS) -I/usr/X11R6/include -I/usr/X11R6/include/X11 -I. -Wall \
-DMETAPIXEL_VERSION=\"$(VERSION)\" $(FORMATDEFS) -DCONSOLE_OUTPUT
CC = gcc
#LIBFFM = -lffm

LISPREADER_OBJS = lispreader.o pools.o allocator.o
OBJS = main.o bitmap.o metric.o matcher.o tiling.o metapixel.o library.o classic.o collage.o search.o utils.o error.o \
vector.o zoom.o rwpng.o rwjpeg.o readimage.o writeimage.o \
$(LISPREADER_OBJS) getopt.o getopt1.o
CONVERT_OBJS = convert.o $(LISPREADER_OBJS) getopt.o getopt1.o
IMAGESIZE_OBJS = imagesize.o rwpng.o rwjpeg.o readimage.o
BOREDOM_OBJS = boredom.o rwpng.o rwjpeg.o readimage.o
OBJS = main.o bitmap.o color.o metric.o matcher.o tiling.o metapixel.o library.o classic.o collage.o search.o \
utils.o error.o avl.o vector.o zoom.o \
getopt.o getopt1.o
IMAGESIZE_OBJS = imagesize.o
BOREDOM_OBJS = boredom.o

all : metapixel metapixel.1 imagesize boredom
# convert

metapixel : $(OBJS)
$(CC) $(LDOPTS) -o metapixel $(OBJS) -lpng -ljpeg $(LIBFFM) -lm -lz
librwimg :
$(MAKE) -C rwimg

liblispreader :
$(MAKE) -C lispreader

metapixel : $(OBJS) librwimg liblispreader
$(CC) $(LDOPTS) -o metapixel $(OBJS) rwimg/librwimg.a lispreader/liblispreader.a -lpng -ljpeg -lgif $(LIBFFM) -lm -lz

metapixel.1 : metapixel.xml
xsltproc --nonet $(MANPAGE_XSL) metapixel.xml

convert : $(CONVERT_OBJS)
$(CC) $(LDOPTS) -o convert $(CONVERT_OBJS)

imagesize : $(IMAGESIZE_OBJS)
$(CC) $(LDOPTS) -o imagesize $(IMAGESIZE_OBJS) -lpng -ljpeg -lm -lz
$(CC) $(LDOPTS) -o imagesize $(IMAGESIZE_OBJS) rwimg/librwimg.a -lpng -ljpeg -lgif -lm -lz

boredom : $(BOREDOM_OBJS)
$(CC) $(LDOPTS) -o boredom $(BOREDOM_OBJS) -lpng -ljpeg -lm -lz
$(CC) $(LDOPTS) -o boredom $(BOREDOM_OBJS) rwimg/librwimg.a -lpng -ljpeg -lgif -lm -lz

zoom : zoom.c rwjpeg.c rwpng.c readimage.c writeimage.c
$(CC) -o zoom $(OPTIMIZE) $(PROFILE) $(MACOS_CCOPTS) -DTEST_ZOOM -DRWIMG_JPEG -DRWIMG_PNG \
Expand All @@ -62,7 +68,9 @@ install : metapixel metapixel.1
# $(INSTALL) sizesort $(BINDIR)

clean :
rm -f *.o metapixel convert imagesize *~
rm -f *.o metapixel imagesize *~
$(MAKE) -C rwimg clean
$(MAKE) -C lispreader clean

realclean : clean
rm -f metapixel.1
Expand Down
4 changes: 4 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
flipping in metapixel-prepare

check all asserts

AppleScript GUI: http://members.aol.com/akseidel/MetapixelController/

Document flipping
Expand Down
66 changes: 0 additions & 66 deletions allocator.c

This file was deleted.

47 changes: 0 additions & 47 deletions allocator.h

This file was deleted.

80 changes: 63 additions & 17 deletions api.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#include <stdio.h>

#include "avl.h"
#include "error.h"

#include "zoom.h"

typedef struct _library_t library_t;
Expand Down Expand Up @@ -69,7 +69,9 @@ struct _bitmap_t

unsigned char *data;

int refcount;
int refcount; /* if negative, the data doesn't
belong to the bitmap and must not
be freed */
bitmap_t *super;
};

Expand All @@ -80,6 +82,11 @@ bitmap_t* bitmap_new (int color, unsigned int width, unsigned int height,
/* bitmap_new_copying doesn't take possession of data. */
bitmap_t* bitmap_new_copying (int color, unsigned int width, unsigned int height,
unsigned int pixel_stride, unsigned int row_stride, unsigned char *data);
/* bitmap_new_dont_possess doesn't take possession of data, but
doesn't copy it either, hence the bitmap must be freed before the
data is. */
bitmap_t* bitmap_new_dont_possess (int color, unsigned int width, unsigned int height,
unsigned int pixel_stride, unsigned int row_stride, unsigned char *data);
/* This is the same as bitmap_new, only that pixel_stride and
row_stride are assumed to take on their minimal values. */
bitmap_t* bitmap_new_packed (int color, unsigned int width, unsigned int height,
Expand Down Expand Up @@ -107,10 +114,6 @@ void bitmap_paste (bitmap_t *dst, bitmap_t *src, unsigned int x, unsigned int y)
/* Opacity is 0 for full transparency and 0x10000 (65536) for full opacity. */
void bitmap_alpha_compose (bitmap_t *dst, bitmap_t *src, unsigned int opacity);

#define COLOR_SPACE_RGB 1
#define COLOR_SPACE_HSV 2
#define COLOR_SPACE_YIQ 3

struct _metapixel_t
{
library_t *library;
Expand All @@ -120,6 +123,9 @@ struct _metapixel_t
/* Only used internally. Can be zero (for mem libraries). */
char *filename;

unsigned long file_len;
unsigned long file_checksum; /* only used if file_len > 0 */

unsigned int width;
unsigned int height;

Expand All @@ -142,7 +148,9 @@ struct _metapixel_t
wavelet_coefficients_t coeffs;
float means[NUM_CHANNELS];
*/
unsigned char subpixels[NUM_SUBPIXELS * NUM_CHANNELS];
unsigned char subpixels_rgb[NUM_SUBPIXELS * NUM_CHANNELS];
unsigned char subpixels_hsv[NUM_SUBPIXELS * NUM_CHANNELS];
unsigned char subpixels_yiq[NUM_SUBPIXELS * NUM_CHANNELS];

/* This is != 0 iff library == 0 || filename == 0, i.e., for
metapixels which are not in a library or only in a mem
Expand All @@ -158,6 +166,9 @@ struct _library_t

metapixel_t *metapixels;
unsigned int num_metapixels;

avltree_t *checksum_tree; /* can be 0, in which case checksums
will not be checked */
};

typedef struct
Expand All @@ -166,6 +177,27 @@ typedef struct
metapixel_match_t *matches;
} classic_mosaic_t;

typedef struct
{
unsigned int x;
unsigned int y;
unsigned int width;
unsigned int height;
metapixel_match_t match;
} collage_match_t;

typedef struct
{
unsigned int in_image_width;
unsigned int in_image_height;

unsigned int num_matches;
collage_match_t *matches;
} collage_mosaic_t;

/* value will be in the range 0.0 to 1.0 */
typedef void (*progress_report_func_t) (float value);

/* library_new and library_open return 0 on failure. */
/* library_new will not create the directory! */
library_t* library_new (const char *path);
Expand Down Expand Up @@ -212,8 +244,12 @@ void tiling_get_metapixel_coords (tiling_t *tiling, unsigned int image_width, un
#define METRIC_SUBPIXEL 2
#define METRIC_MIPMAP 3

#define COLOR_SPACE_RGB 1
#define COLOR_SPACE_HSV 2
#define COLOR_SPACE_YIQ 3

/* These do not allocate memory for the metric. */
metric_t* metric_init_subpixel (metric_t *metric, float weights[]);
metric_t* metric_init (metric_t *metric, int kind, int color_space, float weights[]);

/* These do not allocate memory for the matcher. */
matcher_t* matcher_init_local (matcher_t *matcher, metric_t *metric, unsigned int min_distance);
Expand All @@ -233,11 +269,20 @@ void classic_writer_free (classic_writer_t *writer);
classic_mosaic_t* classic_generate (int num_libraries, library_t **libraries,
classic_reader_t *reader, matcher_t *matcher,
unsigned int forbid_reconstruction_radius,
unsigned int allowed_flips);
unsigned int allowed_flips,
progress_report_func_t report_func);
classic_mosaic_t* classic_generate_from_bitmap (int num_libraries, library_t **libraries,
bitmap_t *in_image, tiling_t *tiling, matcher_t *matcher,
unsigned int forbid_reconstruction_radius,
unsigned int allowed_flips);
unsigned int allowed_flips,
progress_report_func_t report_func);
collage_mosaic_t* collage_generate_from_bitmap (int num_libraries, library_t **libraries, bitmap_t *in_bitmap,
unsigned int min_small_width, unsigned int min_small_height,
unsigned int max_small_width, unsigned int max_small_height,
unsigned int min_distance, metric_t *metric,
unsigned int allowed_flips,
progress_report_func_t report_func);

/* If some metapixel in the mosaic isn't in one of the supplied
libraries, classic_read tries to open the library. If
*num_new_libraries is >0 after classic_read returns, then each
Expand All @@ -246,25 +291,26 @@ classic_mosaic_t* classic_generate_from_bitmap (int num_libraries, library_t **l
the array with free. */
classic_mosaic_t* classic_read (int num_libraries, library_t **libraries, const char *filename,
int *num_new_libraries, library_t ***new_libraries);
collage_mosaic_t* collage_read (int num_libraries, library_t **libraries, const char *filename,
int *num_new_libraries, library_t ***new_libraries);

/* Each metapixel in the mosaic must be in a (saved) library. Returns
0 on failure. */
int classic_write (classic_mosaic_t *mosaic, FILE *out);
int collage_write (collage_mosaic_t *mosaic, FILE *out);

void classic_free (classic_mosaic_t *mosaic);
void collage_free (collage_mosaic_t *mosaic);

/* cheat must be in the range from 0 (full transparency, i.e., no
cheating) to 0x10000 (full opacity). If cheat == 0, then
reader/in_image can be 0. */
int classic_paste (classic_mosaic_t *mosaic, classic_reader_t *reader, unsigned int cheat,
classic_writer_t *writer);
classic_writer_t *writer, progress_report_func_t report_func);
/* width and height are the width and height of the resulting bitmap. */
bitmap_t* classic_paste_to_bitmap (classic_mosaic_t *mosaic, unsigned int width, unsigned int height,
bitmap_t *in_image, unsigned int cheat);

bitmap_t* collage_make (int num_libraries, library_t **libraries, bitmap_t *in_image, float in_image_scale,
unsigned int small_width, unsigned int small_height,
int min_distance, metric_t *metric, unsigned int cheat,
unsigned int allowed_flips);
bitmap_t *in_image, unsigned int cheat, progress_report_func_t report_func);
bitmap_t* collage_paste_to_bitmap (collage_mosaic_t *mosaic, unsigned int width, unsigned int height,
bitmap_t *in_image, unsigned int cheat, progress_report_func_t report_func);

#endif
Loading

0 comments on commit 62f5bce

Please sign in to comment.