1 /*
2 * This file is part of Unpaper.
3 *
4 * Copyright © 2005-2007 Jens Gulden
5 * Copyright © 2011-2011 Diego Elio Pettenò
6 *
7 * Unpaper is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, version 2 of the License.
10 *
11 * Unpaper is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21 /* --- tool functions for image handling ---------------------------------- */
22
23 void initImage(AVFrame **image, int width, int height, int pixel_format, bool fill);
24
replaceImage(AVFrame ** image,AVFrame ** newimage)25 static inline void replaceImage(AVFrame **image, AVFrame **newimage) {
26 av_frame_free(image);
27 *image = *newimage;
28 }
29
30 bool setPixel(int pixel, const int x, const int y, AVFrame *image);
31
32 int getPixel(int x, int y, AVFrame *image);
33
34 uint8_t getPixelDarknessInverse(int x, int y, AVFrame *image);
35
36 int clearRect(const int left, const int top, const int right, const int bottom, AVFrame *image, const int blackwhite);
37
38 void copyImageArea(const int x, const int y, const int width, const int height, AVFrame *source, const int toX, const int toY, AVFrame *target);
39
40 void centerImage(AVFrame *source, int toX, int toY, int ww, int hh, AVFrame *target);
41
42 uint8_t inverseBrightnessRect(const int x1, const int y1, const int x2, const int y2, AVFrame *image);
43
44 uint8_t inverseLightnessRect(const int x1, const int y1, const int x2, const int y2, AVFrame *image);
45
46 uint8_t darknessRect(const int x1, const int y1, const int x2, const int y2, AVFrame *image);
47
48 int countPixelsRect(int left, int top, int right, int bottom, int minColor, int maxBrightness, bool clear, AVFrame *image);
49
50 int countPixelNeighbors(int x, int y, int intensity, int whiteMin, AVFrame *image);
51
52 void clearPixelNeighbors(int x, int y, int whiteMin, AVFrame *image);
53
54 void floodFill(int x, int y, int color, int maskMin, int maskMax, int intensity, AVFrame *image);
55