Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Common header files and definitions for bmpedit.
- */
- #if defined(__GNUC__)
- #define unlikely_if(cond) if (__builtin_expect((cond), 0))
- #define likely_if(cond) if (__builtin_expect((cond), !0))
- #else
- #define unlikely_if if
- #define likely_if if
- #endif
- /* This pragma removes the requirement for aligned structs. It allows mapping of
- * the struct directly onto the file's contents in memory.
- */
- #pragma pack(push, 1)
- /**
- * Structs for the 24-bit pixel type, as well as the bmp header.
- *
- * The pixel struct is in reverse order because we read them directly from
- * mmap'd memory, which reverses the endianness.
- */
- typedef struct {
- uint8_t blue;
- uint8_t green;
- uint8_t red;
- } pixel;
- typedef struct {
- uint32_t size;
- uint32_t width;
- uint32_t height;
- uint16_t colorplanes;
- uint16_t bpp;
- uint32_t compression;
- uint32_t arraysize;
- uint32_t h_res;
- uint32_t v_res;
- uint32_t colors;
- uint32_t important_colors;
- } dib_header;
- typedef struct {
- uint16_t magic;
- uint32_t size;
- uint16_t reserved1;
- uint16_t reserved2;
- uint32_t data_offset;
- dib_header dib;
- } bmp_header;
- typedef struct {
- int x;
- int y;
- } gradients;
- #pragma pack(pop)
- inline static int get_gradient(gradients *gs, int rowsize, int xpos, int ypos);
- inline static int bounded(int bound, int pos);
- inline static pixel* lookup(pixel *data, int width, int height, int padding, int x, int y);
- inline static int gen_padding(bmp_header *header);
- inline static void convert_grayscale(pixel *p);
- inline static int get_direction(gradients *gs, int rowsize, int xpos, int ypos);
- gradients* sobel_operator(pixel *data, int rowsize, int rows, int padding);
- void threshold_shade(bmp_header *header, pixel *data, int, double threshold, double);
- void gaussian_blur(bmp_header *header, pixel *data, int radius, double, double);
- void linear_blur(bmp_header *header, pixel *data, int lblur_times, double, double);
- void monochrome_shade(bmp_header *header, pixel *data, int, double, double);
- void sobel_detect(bmp_header *header, pixel *data, int radius, double threshold, double);
- void canny_detect(bmp_header *header, pixel *data, int radius, double upper, double lower);
- void canny_follow(pixel *data, gradients *gs, int width, int height, int padding, int x, int y, double lower);
- static void usage(void);
- int main(int argc, char *argv[]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement