-
Notifications
You must be signed in to change notification settings - Fork 1
/
source2.c
69 lines (53 loc) · 956 Bytes
/
source2.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
typedef struct pixel{
int R;
int G;
int B;
}
;
typedef struct image{
/*private:*/
int *s;
int picsize;
/*public:*/
void imageimage(image *this,int count){
this->s=(pixel *)malloc(sizeof(pixel)*count);
this->picsize=count;
}
}
;
void imageSet(image *this,pixel p,int i){
if(!isFull()&& i<this->picsize)
this->s[i]=p;
}
pixel imageGet(image *this,int i){
if(i<this->picsize)
return this->s[i];
}
void main(){
int n=0;
int i=0;
pixel p;
printf("Enter image size:");
scanf("%d",n);
image img1;
imageimage (&img1,n);
image img2;
imageimage (&img2,1024);
printf("How many pixels:");
scanf("%d",n);
while(i<n){
printf("Enter Red number:");
scanf("%d",p.R);
printf("Enter Green number:");
scanf("%d",p.G);
printf("Enter Blue number:");
scanf("%d",p.B);
img1.imageSet(p,i);
img2.imageSet(p,i++);
}
printf("Enter pixel number:");
scanf("%d",i);
p=img1.imageGet(i);
if(p.R==255 && p.G==255 && p.B==255)
printf("This pixel is black!");
}