~ruther/CTU-FEE-B0B35APO-Semestral-project

ref: 5350f89393d84636b1caad8382669556448ca0cd CTU-FEE-B0B35APO-Semestral-project/image-viewer/include/image.h -rw-r--r-- 1.4 KiB
5350f893 — František Boháček feat: optimize upscale to not use floats 3 years ago
                                                                                
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
58
59
60
61
62
63
64
65
66
#ifndef __IMAGE_H__
#define __IMAGE_H__

#include <magic.h>
#include <stdio.h>
#include <jpeglib.h>
#include <png.h>

#include <stdbool.h>
#include <stdint.h>

#include "display_utils.h"
#include "direction.h"

typedef enum {
  IMG_UNKNOWN,
  IMG_PNG,
  IMG_JPG,
  IMG_PPM,
} image_type_t;

typedef enum {
  IMERR_SUCCESS,
  IMERR_UNKNOWN_FORMAT,
  IMERR_FILE_NOT_FOUND,
  IMERR_FILE_NO_PERMISSIONS,
  IMERR_FILE_CANT_OPEN,
  IMERR_WRONG_FORMAT,
  IMERR_UNKNOWN,
} image_error_t;

typedef struct {
  char *path;
  image_type_t type;

  display_pixel_t *pixels;

  uint16_t width;
  uint16_t height;
} image_t;

typedef struct {
  uint16_t x;
  uint16_t y;

  uint16_t width;
  uint16_t height;
} image_region_t;

image_t image_create(char *path);
void image_destroy(image_t *image);

display_pixel_t image_get_pixel(image_t *image, uint16_t x, uint16_t y);

void image_set_pixel(image_t *image, uint16_t x, uint16_t y,
                     display_pixel_t pixel);

image_region_t image_region_create(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
bool image_region_move_within(image_region_t *to_move, direction_t direction,
                              int amount, image_region_t *border);

double image_write_to_display(image_t *image, display_t *display,
                              image_region_t region,
                              image_region_t display_region);

#endif // __IMAGE_H__
Do not follow this link