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

ref: dba42e314392f59fc921daf5ef164c5891e1c986 CTU-FEE-B0B35APO-Semestral-project/image-viewer/include/image.h -rw-r--r-- 966 bytes
dba42e31 — František Boháček fix: ppm image loading 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
#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"

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);

image_region_t image_region_create(uint16_t x, uint16_t y, uint16_t width, uint16_t height);

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

#endif // __IMAGE_H__
Do not follow this link