forked from ugocapeto/thepainter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scale_rgb_image.c
59 lines (47 loc) · 968 Bytes
/
scale_rgb_image.c
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
#include "header.h"
void scale_rgb_image(
int *rgb_image_arr1,
int width1,
int height1,
int *rgb_image_arr2,
int width2,
int height2,
char *method,
char *gaussian
)
{
int cind;
int *image_arr1;
int i;
int j;
int pixel;
int *image_arr2;
for ( cind= 0 ; cind< 3 ; cind++ ) {
image_arr1= (int *)calloc(width1*height1,sizeof(int));
for ( i= 0 ; i< height1 ; i++ ) {
for ( j= 0 ; j< width1 ; j++ ) {
pixel= i*width1+j;
image_arr1[pixel]= rgb_image_arr1[3*pixel+cind];
}
}
image_arr2= (int *)calloc(width2*height2,sizeof(int));
scale_image(
image_arr1,
width1,
height1,
image_arr2,
width2,
height2,
method,
gaussian
);
for ( i= 0 ; i< height2 ; i++ ) {
for ( j= 0 ; j< width2 ; j++ ) {
pixel= i*width2+j;
rgb_image_arr2[3*pixel+cind]= image_arr2[pixel];
}
}
free(image_arr1);
free(image_arr2);
}
}