OCRudoku
v1.0
Resolve word grid with ease
|
Functions | |
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. | |
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. | |
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. | |
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. | |
Uint32 | get_pixel_val (void *pixel, SDL_PixelFormat *format) |
Retrieves the pixel value from a given pixel pointer and SDL pixel format. | |
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. | |
void | pixel_to_grayscale (void *pixel, SDL_PixelFormat *format) |
Converts a pixel to grayscale. | |
void | pixel_to_black_white (void *pixel, SDL_PixelFormat *format, Uint8 threshold) |
Converts a pixel to black or white based on a threshold. | |
void | image_to_black_white (SDL_Surface *surface) |
Converts an entire SDL surface to black and white. | |
SDL_Surface * | create_sub_surface (SDL_Surface *surface, SDL_Rect rect) |
Creates a sub-surface from a given SDL surface and rectangle. | |
SDL_Surface * | rotate_pixels (SDL_Surface *surface, double angle) |
double * | image_to_bool_array (const char *file, size_t *image_len) |
SDL_Surface * | resize_image (SDL_Surface *source, int new_width, int new_height) |
SDL_Surface * create_sub_surface | ( | SDL_Surface * | surface, |
SDL_Rect | rect ) |
Creates a sub-surface from a given SDL surface and rectangle.
This function creates a new SDL surface that represents a sub-region of the provided surface, defined by the specified rectangle. The pixel data from the original surface within the rectangle is copied to the new sub-surface.
surface | The original SDL_Surface from which to create the sub-surface. |
rect | The SDL_Rect that defines the region of the original surface to be copied. |
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.
This function calculates the memory address of the pixel located at the given (x, y) coordinates within the provided SDL surface and returns a pointer to that pixel.
surface | The SDL_Surface from which to retrieve the pixel. |
x | The x-coordinate of the pixel. |
y | The y-coordinate of the pixel. |
Uint32 get_pixel_val | ( | void * | pixel, |
SDL_PixelFormat * | format ) |
Retrieves the pixel value from a given pixel pointer and SDL pixel format.
This function extracts the pixel value from the provided pixel pointer based on the specified SDL pixel format. It handles different bytes per pixel (bpp) cases and returns the pixel value as a Uint32.
pixel | A pointer to the pixel data. |
format | The SDL_PixelFormat structure that describes the format of the pixel. |
void image_to_black_white | ( | SDL_Surface * | surface | ) |
Converts an entire SDL surface to black and white.
This function iterates over each pixel in the provided SDL surface, converts each pixel to black or white based on a fixed threshold, and updates the surface with the new pixel values.
surface | The SDL_Surface to be converted to black and white. |
double * image_to_bool_array | ( | const char * | file, |
size_t * | image_len ) |
void pixel_to_black_white | ( | void * | pixel, |
SDL_PixelFormat * | format, | ||
Uint8 | threshold ) |
Converts a pixel to black or white based on a threshold.
This function takes a pointer to a pixel and its format, converts the pixel's color to grayscale by averaging its red, green, and blue components, and then sets the pixel to either black or white based on the provided threshold.
pixel | A pointer to the pixel data. |
format | The SDL_PixelFormat structure that describes the format of the pixel. |
threshold | The threshold value used to determine whether the pixel should be black or white. |
void pixel_to_grayscale | ( | void * | pixel, |
SDL_PixelFormat * | format ) |
Converts a pixel to grayscale.
This function takes a pointer to a pixel and its format, converts the pixel's color to grayscale by averaging its red, green, and blue components, and then sets the pixel to the resulting grayscale value.
pixel | A pointer to the pixel data. |
format | The SDL_PixelFormat structure that describes the format of the pixel. |
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.
This function loads an image from the specified file, creates a texture from the loaded surface, and renders it onto the provided SDL renderer within the specified destination rectangle.
file | The path to the image file to be rendered. |
renderer | The SDL_Renderer to render the image onto. |
dstrect | The destination rectangle on the renderer where the image will be rendered. |
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.
This function loads an image from the specified file, creates a texture from the loaded surface, and renders it onto the provided SDL renderer within the specified source and destination rectangles.
file | The path to the image file to be rendered. |
renderer | The SDL_Renderer to render the image onto. |
srcrect | The source rectangle to be used from the image. If NULL, the entire image is used. |
dstrect | The destination rectangle on the renderer where the image will be rendered. |
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.
This function creates a texture from the provided SDL surface and renders it onto the provided SDL renderer within the specified source and destination rectangles.
surface | The SDL_Surface to be rendered. |
renderer | The SDL_Renderer to render the surface onto. |
srcrect | The source rectangle to be used from the surface. If NULL, the entire surface is used. |
dstrect | The destination rectangle on the renderer where the surface will be rendered. |
SDL_Surface * resize_image | ( | SDL_Surface * | source, |
int | new_width, | ||
int | new_height ) |
Function to resize an image to a new width and height
source | The source image to resize |
new_width | The new width of the image |
new_height | The new height of the image |
SDL_Surface * rotate_pixels | ( | SDL_Surface * | surface, |
double | angle ) |
Rotates the pixels of an SDL surface by a given angle.
This function creates a new SDL surface with the dimensions adjusted to fit the rotated image. It then rotates the pixels of the original surface by the specified angle and copies them to the new surface. The background color of the new surface is set to white.
surface | The original SDL_Surface to be rotated. |
angle | The angle in degrees by which to rotate the surface. |
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.
This function assigns a new pixel value to the specified memory location, interpreting the memory layout according to the provided SDL pixel format. It handles different bytes per pixel (bpp) cases and sets the pixel value accordingly.
pixel | A pointer to the memory location where the pixel value should be set. |
format | The SDL_PixelFormat structure that describes the format of the pixel. |
val | The new pixel value to be set. |