| 1 | /* |
|---|
| 2 | * commin.h: common stuff |
|---|
| 3 | * $Id$ |
|---|
| 4 | * |
|---|
| 5 | * Copyright: (c) 2004 Sam Hocevar <sam@zoy.org> |
|---|
| 6 | * This program is free software; you can redistribute it and/or |
|---|
| 7 | * modify it under the terms of the Do What The Fuck You Want To |
|---|
| 8 | * Public License as published by Banlu Kemiyatorn. See |
|---|
| 9 | * http://sam.zoy.org/projects/COPYING.WTFPL for more details. |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | /* image structure */ |
|---|
| 13 | struct image |
|---|
| 14 | { |
|---|
| 15 | int width, height, pitch, channels; |
|---|
| 16 | unsigned char *pixels; |
|---|
| 17 | void *priv; |
|---|
| 18 | }; |
|---|
| 19 | |
|---|
| 20 | /* font structure */ |
|---|
| 21 | struct font |
|---|
| 22 | { |
|---|
| 23 | struct image *img; |
|---|
| 24 | struct glyph |
|---|
| 25 | { |
|---|
| 26 | int xmin, xmax, ymin, ymax; |
|---|
| 27 | int count; /* Black pixel count */ |
|---|
| 28 | char c; |
|---|
| 29 | } *glyphs; |
|---|
| 30 | int size; |
|---|
| 31 | }; |
|---|
| 32 | |
|---|
| 33 | /* global variables */ |
|---|
| 34 | extern char *argv0; |
|---|
| 35 | extern char *share; |
|---|
| 36 | |
|---|
| 37 | /* debug function */ |
|---|
| 38 | void dprintf(const char *fmt, ...); |
|---|
| 39 | |
|---|
| 40 | /* available CAPTCHA decoders */ |
|---|
| 41 | char *decode_authimage(struct image *img); |
|---|
| 42 | char *decode_clubic(struct image *img); |
|---|
| 43 | char *decode_linuxfr(struct image *img); |
|---|
| 44 | char *decode_phpbb(struct image *img); |
|---|
| 45 | char *decode_scode(struct image *img); |
|---|
| 46 | char *decode_slashdot(struct image *img); |
|---|
| 47 | char *decode_vbulletin(struct image *img); |
|---|
| 48 | char *decode_xanga(struct image *img); |
|---|
| 49 | char *decode_test(struct image *img); |
|---|
| 50 | |
|---|
| 51 | /* image operations */ |
|---|
| 52 | struct image *image_load(const char *name); |
|---|
| 53 | struct image *image_new(int width, int height); |
|---|
| 54 | struct image *image_dup(struct image *img); |
|---|
| 55 | void image_free(struct image *img); |
|---|
| 56 | void image_save(struct image *img, const char *name); |
|---|
| 57 | void image_swap(struct image *img1, struct image *img2); |
|---|
| 58 | int getgray(struct image *img, int x, int y, int *g); |
|---|
| 59 | int getpixel(struct image *img, int x, int y, int *r, int *g, int *b); |
|---|
| 60 | int setpixel(struct image *img, int x, int y, int r, int g, int b); |
|---|
| 61 | |
|---|
| 62 | /* font operations */ |
|---|
| 63 | struct font *font_load_fixed(char *file, char *chars); |
|---|
| 64 | struct font *font_load_variable(char *file, char *chars); |
|---|
| 65 | void font_free(struct font *font); |
|---|
| 66 | |
|---|
| 67 | /* image filters */ |
|---|
| 68 | void filter_flood_fill(struct image *img, int x, int y, int r, int g, int b); |
|---|
| 69 | void filter_fill_holes(struct image *img); |
|---|
| 70 | void filter_scale(struct image *img, float ratio); |
|---|
| 71 | void filter_black_stuff(struct image *img); |
|---|
| 72 | void filter_detect_lines(struct image *img); |
|---|
| 73 | void filter_equalize(struct image *img, int threshold); |
|---|
| 74 | void filter_trick(struct image *img); |
|---|
| 75 | void filter_smooth(struct image *img); |
|---|
| 76 | void filter_median(struct image *img); |
|---|
| 77 | void filter_contrast(struct image *img); |
|---|
| 78 | void filter_crop(struct image *img, int xmin, int ymin, int xmax, int ymax); |
|---|
| 79 | int filter_count(struct image *img); |
|---|
| 80 | |
|---|