1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
// Copyright © 2005-2007 Jens Gulden
// Copyright © 2011-2011 Diego Elio Pettenò
// SPDX-FileCopyrightText: 2005 The unpaper authors
//
// SPDX-License-Identifier: GPL-2.0-only
#pragma once
#include <stdbool.h>
#include <libavutil/frame.h>
/* --- tool functions for image handling ---------------------------------- */
void initImage(AVFrame **image, int width, int height, int pixel_format,
bool fill);
static inline void replaceImage(AVFrame **image, AVFrame **newimage) {
av_frame_free(image);
*image = *newimage;
}
bool setPixel(int pixel, const int x, const int y, AVFrame *image);
int getPixel(int x, int y, AVFrame *image);
uint8_t getPixelDarknessInverse(int x, int y, AVFrame *image);
int clearRect(const int left, const int top, const int right, const int bottom,
AVFrame *image, const int blackwhite);
void copyImageArea(const int x, const int y, const int width, const int height,
AVFrame *source, const int toX, const int toY,
AVFrame *target);
void centerImage(AVFrame *source, int toX, int toY, int ww, int hh,
AVFrame *target);
uint8_t inverseBrightnessRect(const int x1, const int y1, const int x2,
const int y2, AVFrame *image);
uint8_t inverseLightnessRect(const int x1, const int y1, const int x2,
const int y2, AVFrame *image);
uint8_t darknessRect(const int x1, const int y1, const int x2, const int y2,
AVFrame *image);
int countPixelsRect(int left, int top, int right, int bottom, int minColor,
int maxBrightness, bool clear, AVFrame *image);
int countPixelNeighbors(int x, int y, int intensity, int whiteMin,
AVFrame *image);
void clearPixelNeighbors(int x, int y, int whiteMin, AVFrame *image);
void floodFill(int x, int y, int color, int maskMin, int maskMax, int intensity,
AVFrame *image);
|