-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_comp.c
86 lines (77 loc) · 2.02 KB
/
image_comp.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stdio.h>
#include <stdlib.h>
#include "targa.h"
#define NUM_IMAGES 133
int main()
{
uint8_t alpha[NUM_IMAGES],
r[NUM_IMAGES],
g[NUM_IMAGES],
b[NUM_IMAGES];
tga_image image[NUM_IMAGES];
int *pixels_addr[NUM_IMAGES];
int *pixels_addr_new;
pixels_addr_new = malloc(sizeof(int));
int height[NUM_IMAGES],
width[NUM_IMAGES];
int i = 0;
tga_result result;
char addr[256];
for(i=0;i<NUM_IMAGES;i++)
{
char path[256];
if(i<10)
{
sprintf(addr,"%s%d%s","/home/ankit/Work/Ankit/BlockColors_WithoutRLE/BlockColors_WithoutRLE_0000",i,".tga");
}
else if(i>=10 && i<100)
{
sprintf(addr,"%s%d%s","/home/ankit/Work/Ankit/BlockColors_WithoutRLE/BlockColors_WithoutRLE_000",i,".tga");
}
else if(i>=100 && i<1000)
{
sprintf(addr,"%s%d%s","/home/ankit/Work/Ankit/BlockColors_WithoutRLE/BlockColors_WithoutRLE_00",i,".tga");
}
else if(i>=1000)
{
sprintf(addr,"%s%d%s","/home/ankit/Work/Ankit/BlockColors_WithoutRLE/BlockColors_WithoutRLE_0",i,".tga");
}
printf("The image being opened is %s\n",addr);
result = tga_read(&image[i],addr);
if(result != TGA_NOERR)
{
printf("Error opening the image\n");
}
else
{
pixels_addr[i] = (int *)image[i].image_data;
height[i] = (int)image[i].height;
width[i] = (int)image[i].width;
}
printf("The Height is %d\n",width[i]);
}
int j = 0, k = 0;
tga_image img_new;
int img[NUM_IMAGES];
char output[256];
for(k=0;k<NUM_IMAGES-1;k++)
{
for(i=0;i<height[k];i++)
// for(i=0;i<18;i++)
{
for(j=0;j<width[k];j++)
// for(j=0;j<86;j++)
{
img[k] = *(pixels_addr[k] + (i * width[k]) + j);
img[k+1] = *(pixels_addr[k+1] + (i * width[k]) + j);
*(pixels_addr[k] + (i *width[k]) + j ) = img[k] ^ img[k+1];
// printf("This is printing %d %d\n",i,j);
}
}
// img_new.image_data = pixels_addr_new;
sprintf(output,"%s%s%d%s","/home/ankit/Work/Ankit/BlockColors_WithoutRLE/","new",k+1,".tga");
result = tga_write(output,&image[k]);
memset(pixels_addr[k],0,height[k]*width[k]);
// tga_close();
}
}