pikl 0.2.8-x86-mswin32 → 0.3.0-x86-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +9 -0
- data/License.txt +0 -0
- data/Manifest.txt +17 -17
- data/README.txt +0 -0
- data/config/hoe.rb +9 -6
- data/config/requirements.rb +0 -0
- data/ext/pikl/pikl.h +617 -465
- data/ext/pikl/pikl_affine.c +38 -91
- data/ext/pikl/pikl_affine.h +0 -0
- data/ext/pikl/pikl_bitmap.c +0 -0
- data/ext/pikl/pikl_bitmap.h +0 -0
- data/ext/pikl/pikl_blur.c +4 -8
- data/ext/pikl/pikl_blur.h +0 -0
- data/ext/pikl/pikl_camera.c +218 -0
- data/ext/pikl/{pikl_effect3.h → pikl_camera.h} +2 -2
- data/ext/pikl/pikl_composite.c +175 -0
- data/ext/pikl/pikl_composite.h +12 -0
- data/ext/pikl/pikl_decrease.c +110 -45
- data/ext/pikl/pikl_decrease.h +0 -7
- data/ext/pikl/pikl_divide.c +116 -0
- data/ext/pikl/pikl_divide.h +11 -0
- data/ext/pikl/pikl_effect.c +583 -151
- data/ext/pikl/pikl_effect.h +32 -6
- data/ext/pikl/pikl_enhance.c +274 -0
- data/ext/pikl/pikl_enhance.h +20 -0
- data/ext/pikl/pikl_io.c +174 -23
- data/ext/pikl/pikl_io.h +0 -0
- data/ext/pikl/pikl_jpeg.c +0 -0
- data/ext/pikl/pikl_jpeg.h +0 -0
- data/ext/pikl/pikl_pattern.c +383 -357
- data/ext/pikl/pikl_pattern.h +0 -0
- data/ext/pikl/pikl_pixel.c +173 -0
- data/ext/pikl/{pikl_trim.h → pikl_pixel.h} +2 -2
- data/ext/pikl/pikl_png.c +0 -0
- data/ext/pikl/pikl_png.h +0 -0
- data/ext/pikl/pikl_private.h +12 -5
- data/ext/pikl/pikl_resize.c +0 -0
- data/ext/pikl/pikl_resize.h +0 -0
- data/ext/pikl/pikl_rotate.c +409 -51
- data/ext/pikl/pikl_rotate.h +8 -0
- data/ext/pikl/pikl_scrap.c +263 -483
- data/ext/pikl/pikl_scrap.h +0 -0
- data/ext/pikl/pikl_special.c +168 -0
- data/ext/pikl/{pikl_effect4.h → pikl_special.h} +2 -2
- data/ext/pikl/pikl_voronoi.c +320 -0
- data/ext/pikl/pikl_voronoi.h +37 -0
- data/lib/pikl.rb +4 -2
- data/lib/pikl/color.rb +47 -0
- data/lib/pikl/const.rb +106 -22
- data/lib/pikl/errors.rb +0 -0
- data/lib/pikl/ext.rb +115 -8
- data/lib/pikl/filter.rb +371 -0
- data/lib/pikl/image.rb +124 -117
- data/lib/pikl/pikl.dll +0 -0
- data/lib/pikl/version.rb +2 -2
- data/setup.rb +0 -0
- data/test/sample.jpg +0 -0
- data/test/test_helper.rb +0 -0
- data/test/test_pikl_image.rb +0 -14
- data/test/test_pikl_image2.rb +541 -0
- metadata +35 -23
- data/ext/pikl/decrease/fsdither.h +0 -554
- data/ext/pikl/decrease/median.c +0 -1179
- data/ext/pikl/decrease/median.h +0 -7
- data/ext/pikl/decrease/neuquan5.c +0 -563
- data/ext/pikl/decrease/neuquant.h +0 -62
- data/ext/pikl/decrease/wu.c +0 -447
- data/ext/pikl/decrease/wu.h +0 -7
- data/ext/pikl/pikl_effect2.c +0 -240
- data/ext/pikl/pikl_effect2.h +0 -55
- data/ext/pikl/pikl_effect3.c +0 -266
- data/ext/pikl/pikl_effect4.c +0 -495
- data/ext/pikl/pikl_rotate2.c +0 -312
- data/ext/pikl/pikl_rotate2.h +0 -19
- data/ext/pikl/pikl_trim.c +0 -28
data/ext/pikl/pikl_affine.c
CHANGED
@@ -3,55 +3,26 @@
|
|
3
3
|
static int pkl_affine_nn(PKLImage pkl, point2 *p, unsigned char *dst);
|
4
4
|
static int pkl_affine_bl(PKLImage pkl, point2 *p, unsigned char *dst);
|
5
5
|
static point2 *transform(matrix *mat, int x, int y, point2 *p);
|
6
|
-
static matrix *pkl_matrix(PKLImage pkl, matrix *mat);
|
7
|
-
|
6
|
+
static matrix *pkl_matrix(PKLImage pkl, matrix *mat, double x_scale, double y_scale, double angle, int x, int y);
|
8
7
|
static void matrix_init(matrix *mat);
|
9
|
-
static void matrix_scale(matrix *mat, double x_scale, double y_scale);
|
10
|
-
static void matrix_translate(matrix *mat, double x_trns, double y_trns);
|
11
|
-
static void matrix_rotate(matrix *mat, double angle);
|
12
8
|
static void matrix_build(matrix *mat1, matrix *mat2);
|
13
9
|
|
14
|
-
//=============================================================================
|
15
|
-
// pkl_matrix_scale
|
16
|
-
//=============================================================================
|
17
|
-
PKLExport void pkl_matrix_scale(PKLImage pkl, double x_scale, double y_scale)
|
18
|
-
{
|
19
|
-
pkl->x_scale = x_scale;
|
20
|
-
pkl->y_scale = y_scale;
|
21
|
-
}
|
22
|
-
|
23
|
-
//=============================================================================
|
24
|
-
// pkl_matrix_rotate
|
25
|
-
//=============================================================================
|
26
|
-
PKLExport void pkl_matrix_rotate(PKLImage pkl, double angle)
|
27
|
-
{
|
28
|
-
pkl->angle = angle;
|
29
|
-
}
|
30
|
-
|
31
|
-
//=============================================================================
|
32
|
-
// pkl_matrix_translate
|
33
|
-
//=============================================================================
|
34
|
-
PKLExport void pkl_matrix_translate(PKLImage pkl, int x, int y)
|
35
|
-
{
|
36
|
-
pkl->x_trns = x;
|
37
|
-
pkl->y_trns = y;
|
38
|
-
}
|
39
|
-
|
40
10
|
//=============================================================================
|
41
11
|
// pkl_affine
|
42
12
|
//=============================================================================
|
43
|
-
PKLExport int pkl_affine(PKLImage pkl, PKL_SAMPLE sampler, int width, int height,
|
13
|
+
PKLExport int pkl_affine(PKLImage pkl, PKL_SAMPLE sampler, int width, int height, PKLColor backcolor,
|
14
|
+
double x_scale, double y_scale, double angle, int x, int y)
|
44
15
|
{
|
45
16
|
int (*sample)(PKLImage pkl, point2 *p, unsigned char *dst);
|
46
|
-
unsigned char *wrk, back[
|
17
|
+
unsigned char *wrk, back[PKL_CHANNEL];
|
47
18
|
int i, j;
|
48
19
|
point2 p;
|
49
20
|
matrix mat;
|
50
21
|
|
51
22
|
//affine-matrix�̍\�z
|
52
|
-
pkl_matrix(pkl, &mat);
|
23
|
+
pkl_matrix(pkl, &mat, x_scale, y_scale, angle, x, y);
|
53
24
|
|
54
|
-
//�T���v�����O
|
25
|
+
//�T���v�����O���o�C���h
|
55
26
|
switch(sampler){
|
56
27
|
case PKL_SAMPLE_NN:
|
57
28
|
sample = pkl_affine_nn;
|
@@ -62,11 +33,14 @@ PKLExport int pkl_affine(PKLImage pkl, PKL_SAMPLE sampler, int width, int height
|
|
62
33
|
|
63
34
|
wrk = malloc(width * height * pkl->channel);
|
64
35
|
if(!wrk) return(1);
|
65
|
-
memset(wrk, 0, width*height*pkl->channel);
|
66
36
|
|
67
37
|
//�w�i�F�����
|
68
|
-
for(i=0; i<pkl->channel; i++)
|
69
|
-
|
38
|
+
//for(i=0; i<pkl->channel; i++)
|
39
|
+
// back[i] = (backcolor>>((pkl->channel-i)*8) & 0xFF);
|
40
|
+
if(backcolor)
|
41
|
+
memcpy(back, backcolor->color, PKL_CHANNEL);
|
42
|
+
else
|
43
|
+
memset(back, 0xff, PKL_CHANNEL);
|
70
44
|
|
71
45
|
//�ό`��T�C�Y��loop
|
72
46
|
for(i=0; i<height; i++){
|
@@ -100,7 +74,6 @@ static int pkl_affine_nn(PKLImage pkl, point2 *p, unsigned char *dst)
|
|
100
74
|
return(1);
|
101
75
|
}
|
102
76
|
|
103
|
-
|
104
77
|
//=============================================================================
|
105
78
|
// pkl_affine_bl
|
106
79
|
//=============================================================================
|
@@ -139,7 +112,7 @@ static int pkl_affine_bl(PKLImage pkl, point2 *p, unsigned char *dst)
|
|
139
112
|
}
|
140
113
|
}else{
|
141
114
|
for(i=0; i<pkl->channel; i++)
|
142
|
-
pixel[i] += pkl->image[(
|
115
|
+
pixel[i] += pkl->image[(p0y*pkl->width+p0x)*pkl->channel+i];
|
143
116
|
}
|
144
117
|
}
|
145
118
|
|
@@ -148,25 +121,46 @@ static int pkl_affine_bl(PKLImage pkl, point2 *p, unsigned char *dst)
|
|
148
121
|
return(0);
|
149
122
|
}
|
150
123
|
|
124
|
+
//=============================================================================
|
125
|
+
// transform
|
126
|
+
//=============================================================================
|
127
|
+
static point2 *transform(matrix *mat, int x, int y, point2 *p)
|
128
|
+
{
|
129
|
+
p->x = mat->a*x + mat->c*y + mat->e;
|
130
|
+
p->y = mat->b*x + mat->d*y + mat->f;
|
131
|
+
return p;
|
132
|
+
}
|
133
|
+
|
151
134
|
//=============================================================================
|
152
135
|
// pkl_matrix
|
153
136
|
//=============================================================================
|
154
|
-
static matrix *pkl_matrix(PKLImage pkl, matrix *mat)
|
137
|
+
static matrix *pkl_matrix(PKLImage pkl, matrix *mat, double x_scale, double y_scale, double angle, int x, int y)
|
155
138
|
{
|
156
139
|
matrix mat2;
|
140
|
+
double c, s;
|
157
141
|
|
158
142
|
matrix_init(mat);
|
159
143
|
|
160
144
|
//scale
|
161
|
-
|
145
|
+
matrix_init(&mat2);
|
146
|
+
mat2.a = x_scale;
|
147
|
+
mat2.d = y_scale;
|
162
148
|
matrix_build(mat, &mat2);
|
163
149
|
|
164
150
|
//rotate
|
165
|
-
|
151
|
+
matrix_init(&mat2);
|
152
|
+
c = cos(angle*3.14/180.0);
|
153
|
+
s = sin(angle*3.14/180.0);
|
154
|
+
mat2.a = c;
|
155
|
+
mat2.b = s;
|
156
|
+
mat2.c = -s;
|
157
|
+
mat2.d = c;
|
166
158
|
matrix_build(mat, &mat2);
|
167
159
|
|
168
160
|
//translate
|
169
|
-
|
161
|
+
matrix_init(&mat2);
|
162
|
+
mat2.e = x;
|
163
|
+
mat2.f = y;
|
170
164
|
matrix_build(mat, &mat2);
|
171
165
|
|
172
166
|
return(mat);
|
@@ -185,43 +179,6 @@ static void matrix_init(matrix *mat)
|
|
185
179
|
mat->f = 0.0;
|
186
180
|
}
|
187
181
|
|
188
|
-
//=============================================================================
|
189
|
-
// matrix_init
|
190
|
-
//=============================================================================
|
191
|
-
static void matrix_scale(matrix *mat, double x_scale, double y_scale)
|
192
|
-
{
|
193
|
-
matrix_init(mat);
|
194
|
-
mat->a = x_scale;
|
195
|
-
mat->d = y_scale;
|
196
|
-
}
|
197
|
-
|
198
|
-
//=============================================================================
|
199
|
-
// matrix_translate
|
200
|
-
//=============================================================================
|
201
|
-
static void matrix_translate(matrix *mat, double x_trns, double y_trns)
|
202
|
-
{
|
203
|
-
matrix_init(mat);
|
204
|
-
mat->e = x_trns;
|
205
|
-
mat->f = y_trns;
|
206
|
-
}
|
207
|
-
|
208
|
-
//=============================================================================
|
209
|
-
// matrix_rotate
|
210
|
-
//=============================================================================
|
211
|
-
static void matrix_rotate(matrix *mat, double angle)
|
212
|
-
{
|
213
|
-
double c, s;
|
214
|
-
|
215
|
-
matrix_init(mat);
|
216
|
-
|
217
|
-
c = cos(angle*3.14/180.0);
|
218
|
-
s = sin(angle*3.14/180.0);
|
219
|
-
mat->a = c;
|
220
|
-
mat->b = s;
|
221
|
-
mat->c = -s;
|
222
|
-
mat->d = c;
|
223
|
-
}
|
224
|
-
|
225
182
|
//=============================================================================
|
226
183
|
// matrix_init
|
227
184
|
//=============================================================================
|
@@ -238,13 +195,3 @@ static void matrix_build(matrix *mat1, matrix *mat2)
|
|
238
195
|
mat1->f = mat.e * mat2->b + mat.f * mat2->d + mat2->f;
|
239
196
|
}
|
240
197
|
|
241
|
-
//=============================================================================
|
242
|
-
// transform
|
243
|
-
//=============================================================================
|
244
|
-
static point2 *transform(matrix *mat, int x, int y, point2 *p)
|
245
|
-
{
|
246
|
-
p->x = mat->a*x + mat->c*y + mat->e;
|
247
|
-
p->y = mat->b*x + mat->d*y + mat->f;
|
248
|
-
return p;
|
249
|
-
}
|
250
|
-
|
data/ext/pikl/pikl_affine.h
CHANGED
File without changes
|
data/ext/pikl/pikl_bitmap.c
CHANGED
File without changes
|
data/ext/pikl/pikl_bitmap.h
CHANGED
File without changes
|
data/ext/pikl/pikl_blur.c
CHANGED
@@ -13,7 +13,6 @@ PKLExport int pkl_blur(PKLImage pkl, int weight)
|
|
13
13
|
|
14
14
|
wrk = malloc(pkl->height * pkl->width * pkl->channel);
|
15
15
|
if(!wrk) return(1);
|
16
|
-
memset(wrk, 0, pkl->height * pkl->width * pkl->channel);
|
17
16
|
|
18
17
|
for(i=0; i<pkl->height; i++){
|
19
18
|
for(j=0; j<pkl->width; j++){
|
@@ -22,11 +21,10 @@ PKLExport int pkl_blur(PKLImage pkl, int weight)
|
|
22
21
|
|
23
22
|
for(p=-weight; p<=weight; p++){
|
24
23
|
for(q=-weight; q<=weight; q++){
|
25
|
-
if(j+q
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
}
|
24
|
+
if(j+q<0 || j+q>=pkl->width || i+p<0 || i+p>=pkl->height) continue;
|
25
|
+
for(k=0; k<pkl->channel; k++)
|
26
|
+
stock[k] += pkl->image[((i+p)*pkl->width+(j+q))*pkl->channel+k];
|
27
|
+
cnt++;
|
30
28
|
}
|
31
29
|
}
|
32
30
|
if(cnt==0) continue;
|
@@ -53,7 +51,6 @@ PKLExport int pkl_gaussblur(PKLImage pkl, double weight)
|
|
53
51
|
|
54
52
|
wrk = malloc(pkl->height * pkl->width * pkl->channel);
|
55
53
|
if(!wrk) return(1);
|
56
|
-
memset(wrk, 0, pkl->height * pkl->width * pkl->channel);
|
57
54
|
|
58
55
|
range = weight * 3;
|
59
56
|
gauss = malloc(sizeof(double)*(range+1));
|
@@ -102,7 +99,6 @@ PKLExport int pkl_gaussblur(PKLImage pkl, double weight)
|
|
102
99
|
return(0);
|
103
100
|
}
|
104
101
|
|
105
|
-
|
106
102
|
//=============================================================================
|
107
103
|
// pkl_rblur(����)
|
108
104
|
//=============================================================================
|
data/ext/pikl/pikl_blur.h
CHANGED
File without changes
|
@@ -0,0 +1,218 @@
|
|
1
|
+
#include "pikl_camera.h"
|
2
|
+
|
3
|
+
//=============================================================================
|
4
|
+
// pkl_vignette
|
5
|
+
//=============================================================================
|
6
|
+
PKLExport int pkl_vignette(PKLImage pkl, PKLColor color, int trans, int radius, int x, int y)
|
7
|
+
{
|
8
|
+
double t, t1, tr, r, rr, a, w;
|
9
|
+
unsigned char *p, at[PKL_CHANNEL][PKL_COLOR];
|
10
|
+
int i, j, k, cx, cy;;
|
11
|
+
|
12
|
+
if(trans<0 || trans>100) return(1);
|
13
|
+
if(!color) return(1);
|
14
|
+
|
15
|
+
t = (double)trans/100.0;
|
16
|
+
t1 = 1.0 - t;
|
17
|
+
|
18
|
+
for(i=0; i<pkl->channel; i++){
|
19
|
+
w = (double)color->color[i]/255.0;
|
20
|
+
for(j=0; j<PKL_COLOR; j++)
|
21
|
+
at[i][j] = PKL_COLOR_CLIP((double)j * (t+t1 * w));
|
22
|
+
}
|
23
|
+
|
24
|
+
cx = (x<0 || x>=pkl->width) ? pkl->width/2 : x;
|
25
|
+
cy = (y<0 || y>=pkl->height) ? pkl->height/2 : y;
|
26
|
+
|
27
|
+
for(i=0; i<pkl->height; i++){
|
28
|
+
for(j=0; j<pkl->width; j++){
|
29
|
+
r = sqrt((cx-j)*(cx-j) + (cy-i)*(cy-i));
|
30
|
+
p = &pkl->image[(i*pkl->width+j)*pkl->channel];
|
31
|
+
if(r > radius){
|
32
|
+
for(k=0; k<pkl->channel; k++)
|
33
|
+
*(p+k) = at[k][*(p+k)];
|
34
|
+
}else{
|
35
|
+
rr = r/(double)radius;
|
36
|
+
tr = 1.2 - 1.2 * rr * rr;
|
37
|
+
a = 1.0 < tr ? 1.0 : tr;
|
38
|
+
|
39
|
+
for(k=0; k<pkl->channel; k++)
|
40
|
+
*(p+k) = PKL_COLOR_CLIP((1.0-a) * at[k][*(p+k)] + a * *(p+k));
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
return(0);
|
45
|
+
}
|
46
|
+
|
47
|
+
//=================================================================================
|
48
|
+
// pkl_vaseline
|
49
|
+
//=================================================================================
|
50
|
+
PKLExport int pkl_vaseline(PKLImage pkl, int radius, int x, int y)
|
51
|
+
{
|
52
|
+
int i, j, s, t, k, z, cnt, stock[PKL_CHANNEL], cx, cy;
|
53
|
+
unsigned char *wrk;
|
54
|
+
double r;
|
55
|
+
|
56
|
+
wrk = malloc(pkl->width*pkl->height*pkl->channel);
|
57
|
+
if(!wrk) return(1);
|
58
|
+
memcpy(wrk, pkl->image, pkl->width*pkl->height*pkl->channel);
|
59
|
+
|
60
|
+
cx = (x<0 || x>=pkl->width) ? pkl->width/2 : x;
|
61
|
+
cy = (y<0 || y>=pkl->height) ? pkl->height/2 : y;
|
62
|
+
|
63
|
+
for(i=0; i<pkl->height; i++){
|
64
|
+
for(j=0; j<pkl->width; j++){
|
65
|
+
r = sqrt((j-cx)*(j-cx)+(i-cy)*(i-cy));
|
66
|
+
z = (int)((r-radius)*0.2);
|
67
|
+
z = z>10 ? 10 : z;
|
68
|
+
|
69
|
+
cnt = 0;
|
70
|
+
memset(stock, 0, sizeof(stock));
|
71
|
+
|
72
|
+
for(s=i-z; s<=i+z; s++){
|
73
|
+
for(t=j-z; t<=j+z; t++){
|
74
|
+
if(s<0 || s>=pkl->height || t<0 || t>=pkl->width) continue;
|
75
|
+
for(k=0; k<pkl->channel; k++)
|
76
|
+
stock[k] += pkl->image[(s*pkl->width+t)*pkl->channel+k];
|
77
|
+
cnt++;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
if(cnt){
|
81
|
+
for(k=0; k<pkl->channel; k++)
|
82
|
+
wrk[(i*pkl->width+j)*pkl->channel+k] = PKL_COLOR_CLIP(stock[k]/cnt);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
free(pkl->image);
|
87
|
+
pkl->image= wrk;
|
88
|
+
return(0);
|
89
|
+
}
|
90
|
+
|
91
|
+
//=============================================================================
|
92
|
+
// pkl_vv
|
93
|
+
//=============================================================================
|
94
|
+
PKLExport int pkl_vv(PKLImage pkl, PKLColor color, int trans, int radius, int x, int y)
|
95
|
+
{
|
96
|
+
double t, t1, tr, r, rr, a, w;
|
97
|
+
unsigned char at[PKL_CHANNEL][PKL_COLOR], *wrk;
|
98
|
+
int i, j, k, p, q, offset, cnt, stock[PKL_CHANNEL], cx, cy;
|
99
|
+
|
100
|
+
if(trans<0 || trans>100) return(1);
|
101
|
+
if(!color) return(1);
|
102
|
+
|
103
|
+
wrk = malloc(pkl->width*pkl->height*pkl->channel);
|
104
|
+
if(!wrk) return(1);
|
105
|
+
|
106
|
+
t = (double)trans/100.0;
|
107
|
+
t1 = 1.0 - t;
|
108
|
+
|
109
|
+
for(i=0; i<pkl->channel; i++){
|
110
|
+
w = (double)color->color[i]/255.0;
|
111
|
+
for(j=0; j<PKL_COLOR; j++)
|
112
|
+
at[i][j] = PKL_COLOR_CLIP((double)j * (t+t1 * w));
|
113
|
+
}
|
114
|
+
|
115
|
+
cx = (x<0 || x>=pkl->width) ? pkl->width/2 : x;
|
116
|
+
cy = (y<0 || y>=pkl->height) ? pkl->height/2 : y;
|
117
|
+
|
118
|
+
for(i=0; i<pkl->height; i++){
|
119
|
+
for(j=0; j<pkl->width; j++){
|
120
|
+
r = sqrt((cx-j)*(cx-j) + (cy-i)*(cy-i));
|
121
|
+
if(r > radius){
|
122
|
+
offset = (int)((r-radius)*0.2); //0.2��ς��邱�ƂŁA�ڂ�������ς��
|
123
|
+
offset = offset>10 ? 10 : offset;
|
124
|
+
cnt = 0;
|
125
|
+
memset(stock, 0, sizeof(stock));
|
126
|
+
|
127
|
+
for(p=i-offset; p<=i+offset; p++){
|
128
|
+
for(q=j-offset; q<=j+offset; q++){
|
129
|
+
if(p<0 || p>=pkl->height || q<0 || q>=pkl->width) continue;
|
130
|
+
for(k=0; k<pkl->channel; k++)
|
131
|
+
stock[k] += pkl->image[(p*pkl->width+q)*pkl->channel+k];
|
132
|
+
cnt++;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
if(cnt==0) continue;
|
137
|
+
for(k=0; k<pkl->channel; k++)
|
138
|
+
wrk[(i*pkl->width+j)*pkl->channel+k] = at[k][PKL_COLOR_CLIP(stock[k]/cnt)];
|
139
|
+
}else{
|
140
|
+
rr = r/(double)radius;
|
141
|
+
tr = 1.2 - 1.2 * rr * rr;
|
142
|
+
a = 1.0 < tr ? 1.0 : tr;
|
143
|
+
for(k=0; k<pkl->channel; k++)
|
144
|
+
wrk[(i*pkl->width+j)*pkl->channel+k] =
|
145
|
+
PKL_COLOR_CLIP((1.0-a) * at[k][pkl->image[(i*pkl->width+j)*pkl->channel+k]] +
|
146
|
+
a * pkl->image[(i*pkl->width+j)*pkl->channel+k]);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
free(pkl->image);
|
152
|
+
pkl->image=wrk;
|
153
|
+
return(0);
|
154
|
+
}
|
155
|
+
|
156
|
+
//=============================================================================
|
157
|
+
// pkl_film
|
158
|
+
//=============================================================================
|
159
|
+
PKLExport int pkl_film(PKLImage pkl, PKLColor color, int trans)
|
160
|
+
{
|
161
|
+
double t, t1, w;
|
162
|
+
unsigned char at[PKL_CHANNEL][PKL_COLOR];
|
163
|
+
int i, j, k;
|
164
|
+
|
165
|
+
if(trans<0 || trans>100) return(1);
|
166
|
+
if(!color) return(1);
|
167
|
+
|
168
|
+
t = (double)trans/100.0;
|
169
|
+
t1 = 1.0 - t;
|
170
|
+
|
171
|
+
for(i=0; i<pkl->channel; i++){
|
172
|
+
w = (double)color->color[i]/255.0;
|
173
|
+
for(j=0; j<PKL_COLOR; j++)
|
174
|
+
at[i][j] = PKL_COLOR_CLIP((double)j * (t+t1 * w));
|
175
|
+
}
|
176
|
+
|
177
|
+
for(i=0; i<pkl->height; i++){
|
178
|
+
for(j=0; j<pkl->width; j++){
|
179
|
+
for(k=0; k<pkl->channel; k++)
|
180
|
+
pkl->image[(i*pkl->width+j)*pkl->channel+k] = at[k][pkl->image[(i*pkl->width+j)*pkl->channel+k]];
|
181
|
+
}
|
182
|
+
}
|
183
|
+
return(0);
|
184
|
+
}
|
185
|
+
|
186
|
+
////=============================================================================
|
187
|
+
//// pkl_spotlight
|
188
|
+
////=============================================================================
|
189
|
+
//PKLExport int pkl_spotlight(PKLImage pkl, int radius, PKLColor color, int trans)
|
190
|
+
//{
|
191
|
+
// int i, j, k;
|
192
|
+
// double rr, r, f, cx, cy, tr;
|
193
|
+
//
|
194
|
+
// if(radius < 0) return(1);
|
195
|
+
//
|
196
|
+
// tr = (double)trans/100.0;
|
197
|
+
// rr = radius * radius;
|
198
|
+
// cx = (double)pkl->width/2.0;
|
199
|
+
// cy = (double)pkl->height/2.0;
|
200
|
+
//
|
201
|
+
// for(i=0; i<pkl->height; i++){
|
202
|
+
// for(j=0; j<pkl->width; j++){
|
203
|
+
// r = (j-cx)*(j-cx) + (i-cy)*(i-cy);
|
204
|
+
// f = 1.2 * (1.0 - r / rr);
|
205
|
+
// f = f > 1.0 ? 1.0 : f;
|
206
|
+
//
|
207
|
+
// if(f > 0.0){
|
208
|
+
// for(k=0; k<pkl->channel; k++)
|
209
|
+
// pkl->image[(i*pkl->width+j)*pkl->channel+k]
|
210
|
+
// = PKL_COLOR_CLIP(pkl->image[(i*pkl->width+j)*pkl->channel+k]*tr*f + color->color[k]*(1.0-tr*f));
|
211
|
+
// }else{
|
212
|
+
// memcpy(&pkl->image[(i*pkl->width+j)*pkl->channel], color, pkl->channel);
|
213
|
+
// }
|
214
|
+
// }
|
215
|
+
// }
|
216
|
+
// return(0);
|
217
|
+
//}
|
218
|
+
//
|