-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectpixels.h
More file actions
46 lines (41 loc) · 1003 Bytes
/
Copy pathselectpixels.h
File metadata and controls
46 lines (41 loc) · 1003 Bytes
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
#include <stdio.h>
#include <stdlib.h>
#include "structs.h"
#ifndef SELECTPIXELS_H
#define SELECTPIXELS_H
void selectpixels(image img, selection *select, int x1, int y1, int x2, int y2)
{
int aux;
// verific daca x1 > x2 si realizez swap ul
if (x1 > x2) {
aux = x1;
x1 = x2;
x2 = aux;
}
// verific daca y1 > y2 si realizez swap ul
if (y1 > y2) {
aux = y1;
y1 = y2;
y2 = aux;
}
// verific daca exista o imagine sau daca selectia exista in imagine
if (!img.data && !img.rgb) {
printf("No image loaded");
printf("\n");
} else if (x1 < 0 || y1 < 0 || x2 > img.width || y2 > img.height) {
printf("Invalid set of coordinates");
printf("\n");
} else if (x1 == x2 || y1 == y2) {
printf("Invalid set of coordinates");
printf("\n");
} else {
// actualizez selectia daca este valida
select->x1 = x1;
select->y1 = y1;
select->x2 = x2;
select->y2 = y2;
// confirm ca selectia s-a realizat cu succes
printf("Selected %d %d %d %d\n", x1, y1, x2, y2);
}
}
#endif