OCRudoku  v1.0
Resolve word grid with ease
Loading...
Searching...
No Matches
ImageUtils.h
Go to the documentation of this file.
1#include <SDL2/SDL.h>
2#include <SDL2/SDL_image.h>
3#include <SDL2/SDL_render.h>
4#include <SDL.h>
5#include <SDL_image.h>
6#include <SDL_render.h>
7#include <SDL_error.h>
8#include <SDL_rect.h>
9#include <SDL_surface.h>
10
11#ifndef M_PI
12#define M_PI acos(-1.0)
13#endif
14
15#ifndef IMAGE_UTILS_H
16#define IMAGE_UTILS_H
17
18void render_image_file(const char* file, SDL_Renderer* renderer, const SDL_Rect* srcrect, const SDL_Rect* dstrect);
19
20void render_full_image_file(const char* file, SDL_Renderer* renderer, const SDL_Rect* dstrect);
21
22void render_surface(SDL_Surface* surface, SDL_Renderer* renderer, const SDL_Rect* srcrect, const SDL_Rect* dstrect);
23
24void* get_pixel_pt(SDL_Surface* surface, size_t x, size_t y);
25
26Uint32 get_pixel_val(void* pixel, SDL_PixelFormat* format);
27
28void set_pixel_val(void* pixel, SDL_PixelFormat* format, Uint32 val);
29
30void pixel_to_grayscale(void* pixel, SDL_PixelFormat* format);
31
32void pixel_to_black_white(void* pixel, SDL_PixelFormat* format, Uint8 threshold);
33
34void image_to_black_white(SDL_Surface* surface);
35
36SDL_Surface* create_sub_surface(SDL_Surface* surface, SDL_Rect rect);
37
38// void rotate_pixels(SDL_Surface* surface, double angle);
39
40SDL_Surface* rotate_pixels(SDL_Surface* surface, double angle);
41
42double* image_to_bool_array(const char* file, size_t* image_len);
43
44SDL_Surface* resize_image(SDL_Surface* source, int new_width, int new_height);
45
46#endif
void render_full_image_file(const char *file, SDL_Renderer *renderer, const SDL_Rect *dstrect)
Renders an entire image file onto a given SDL renderer.
Definition ImageUtils.c:33
void * get_pixel_pt(SDL_Surface *surface, size_t x, size_t y)
Retrieves a pointer to the pixel at the specified coordinates in an SDL surface.
Definition ImageUtils.c:82
SDL_Surface * create_sub_surface(SDL_Surface *surface, SDL_Rect rect)
Creates a sub-surface from a given SDL surface and rectangle.
Definition ImageUtils.c:287
double * image_to_bool_array(const char *file, size_t *image_len)
Definition ImageUtils.c:409
void render_surface(SDL_Surface *surface, SDL_Renderer *renderer, const SDL_Rect *srcrect, const SDL_Rect *dstrect)
Renders a given SDL surface onto a given SDL renderer.
Definition ImageUtils.c:59
void pixel_to_black_white(void *pixel, SDL_PixelFormat *format, Uint8 threshold)
Converts a pixel to black or white based on a threshold.
Definition ImageUtils.c:219
void render_image_file(const char *file, SDL_Renderer *renderer, const SDL_Rect *srcrect, const SDL_Rect *dstrect)
Renders an image file onto a given SDL renderer.
Definition ImageUtils.c:7
void set_pixel_val(void *pixel, SDL_PixelFormat *format, Uint32 val)
Sets the pixel value at a given memory location based on the SDL pixel format.
Definition ImageUtils.c:145
SDL_Surface * resize_image(SDL_Surface *source, int new_width, int new_height)
Definition ImageUtils.c:438
void image_to_black_white(SDL_Surface *surface)
Converts an entire SDL surface to black and white.
Definition ImageUtils.c:258
SDL_Surface * rotate_pixels(SDL_Surface *surface, double angle)
Definition ImageUtils.c:331
Uint32 get_pixel_val(void *pixel, SDL_PixelFormat *format)
Retrieves the pixel value from a given pixel pointer and SDL pixel format.
Definition ImageUtils.c:101
void pixel_to_grayscale(void *pixel, SDL_PixelFormat *format)
Converts a pixel to grayscale.
Definition ImageUtils.c:192