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
@@ -0,0 +1,37 @@
|
|
1
|
+
#ifndef _LIB_PIKL_VORONOI_
|
2
|
+
#define _LIB_PIKL_VORONOI_
|
3
|
+
|
4
|
+
#include <stdio.h>
|
5
|
+
#include <stdlib.h>
|
6
|
+
#include <string.h>
|
7
|
+
#include <math.h>
|
8
|
+
|
9
|
+
#include "pikl.h"
|
10
|
+
#include "pikl_private.h"
|
11
|
+
|
12
|
+
|
13
|
+
//=============================================================================
|
14
|
+
// voronoi_zone datatype
|
15
|
+
//=============================================================================
|
16
|
+
struct VoronoiPoint {
|
17
|
+
int x, y;
|
18
|
+
long color[PKL_CHANNEL];
|
19
|
+
unsigned char ave[PKL_CHANNEL];
|
20
|
+
int count;
|
21
|
+
};
|
22
|
+
|
23
|
+
//=============================================================================
|
24
|
+
// voronoi_count datatype
|
25
|
+
//=============================================================================
|
26
|
+
//�{���m�C�̕�_�Ǘ��p(1�̕�_����אڂ����_�̌�)
|
27
|
+
#define VORONOI_CNT 10 //�����͂Ȃ�
|
28
|
+
|
29
|
+
struct VORONOI {
|
30
|
+
int x, y; //��_���W
|
31
|
+
int id; //�Ǘ��pID
|
32
|
+
long color[PKL_CHANNEL]; //�^�[�Q�b�g�̈�̐F�ݐϗ̈�
|
33
|
+
int count; //�ݐσs�N�Z����
|
34
|
+
int next[VORONOI_CNT]; //�אڂ����_��ID
|
35
|
+
};
|
36
|
+
|
37
|
+
#endif
|
data/lib/pikl.rb
CHANGED
data/lib/pikl/color.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module Pikl
|
2
|
+
|
3
|
+
class Color
|
4
|
+
|
5
|
+
def initialize(a,b,c,d)
|
6
|
+
validate_color(a)
|
7
|
+
validate_color(b)
|
8
|
+
validate_color(c)
|
9
|
+
validate_color(d)
|
10
|
+
@color = Pikl::Ext.pkl_color_create(a,b,c,d)
|
11
|
+
end
|
12
|
+
|
13
|
+
def Color.gray(g)
|
14
|
+
new(g,0,0,0)
|
15
|
+
end
|
16
|
+
|
17
|
+
def Color.rgb(r, g, b)
|
18
|
+
new(r,g,b,0)
|
19
|
+
end
|
20
|
+
|
21
|
+
def Color.cmyk(c,m,y,k)
|
22
|
+
new(c,m,y,k)
|
23
|
+
end
|
24
|
+
|
25
|
+
#attr_accessor :color
|
26
|
+
def rawdata
|
27
|
+
@color
|
28
|
+
end
|
29
|
+
|
30
|
+
def getcolor(colormodel)
|
31
|
+
error("invalid colormodel parameter. # => #{colormodel}") unless COLORMODEL.include?(colormodel)
|
32
|
+
Ext.pkl_color(@color, COLORMODEL[colormodel])
|
33
|
+
end
|
34
|
+
|
35
|
+
def close
|
36
|
+
Ext.pkl_color_close(@color)
|
37
|
+
@color=nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate_color(v)
|
41
|
+
error("invalid color parameter. # => #{v}") unless /^\d+$/ =~ v.to_s
|
42
|
+
error("invalid color parameter. # => #{v}") unless v.to_i >= 0 && v.to_i <= 255
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/lib/pikl/const.rb
CHANGED
@@ -11,33 +11,32 @@ module Pikl
|
|
11
11
|
ANGLE180 = 2
|
12
12
|
ANGLE270 = 3
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
14
|
+
SAMPLE_NN = 1 #nearest neighbor
|
15
|
+
SAMPLE_BL = 2 #bilinear
|
16
|
+
SAMPLE_BC = 3 #bicubic
|
17
|
+
SAMPLE_PA = 4 #pixcel average(reduce only)
|
18
|
+
SAMPLE_LZ = 5 #lanczos
|
19
|
+
|
20
|
+
SAMPLES = {
|
21
|
+
:nearest_neighbor => SAMPLE_NN,
|
22
|
+
:bilinear => SAMPLE_BL,
|
23
|
+
:bicubic => SAMPLE_BC,
|
24
|
+
:pixcel_averate => SAMPLE_PA,
|
25
|
+
:lanczos => SAMPLE_LZ,
|
26
|
+
:nn => SAMPLE_NN,
|
27
|
+
:bl => SAMPLE_BL,
|
28
|
+
:bc => SAMPLE_BC,
|
29
|
+
:pa => SAMPLE_PA,
|
30
|
+
:lz => SAMPLE_LZ,
|
31
|
+
}
|
32
32
|
|
33
33
|
ROTATE_ANGLE = {
|
34
34
|
0 => ANGLE000,
|
35
35
|
90 => ANGLE090,
|
36
36
|
180 => ANGLE180,
|
37
|
-
270 => ANGLE270,
|
38
|
-
360 => ANGLE000,
|
37
|
+
270 => ANGLE270,
|
38
|
+
360 => ANGLE000,
|
39
39
|
}
|
40
|
-
|
41
40
|
|
42
41
|
EXTENSIONS_FORMATS = {
|
43
42
|
"jpeg" => JPEG,
|
@@ -51,4 +50,89 @@ module Pikl
|
|
51
50
|
|
52
51
|
PIX_LIMIT = 6000
|
53
52
|
|
54
|
-
|
53
|
+
|
54
|
+
##----soezimaster add.
|
55
|
+
# dummy image ... umm
|
56
|
+
DEFAULT_IMAGE = ''
|
57
|
+
|
58
|
+
# COLORSPACE
|
59
|
+
COLORSPACE = {
|
60
|
+
:GRAY => 2,
|
61
|
+
:RGB => 3,
|
62
|
+
:CMYK => 6
|
63
|
+
}
|
64
|
+
|
65
|
+
# COLORMODEL
|
66
|
+
COLORMODEL = {
|
67
|
+
:gray => 0,
|
68
|
+
:red => 1,
|
69
|
+
:green => 2,
|
70
|
+
:blue => 3,
|
71
|
+
:cyan => 4,
|
72
|
+
:magenta => 5,
|
73
|
+
:yellow => 6,
|
74
|
+
:black => 7
|
75
|
+
}
|
76
|
+
|
77
|
+
# dither-type
|
78
|
+
DITHER = {
|
79
|
+
:non => 0,
|
80
|
+
:floydsteinberg => 1,
|
81
|
+
:stucci => 2,
|
82
|
+
:sierra => 3,
|
83
|
+
:jajuni => 4
|
84
|
+
}
|
85
|
+
|
86
|
+
# focus-type
|
87
|
+
FOCUS = {
|
88
|
+
:detail => 0,
|
89
|
+
:focus => 1,
|
90
|
+
:edges => 2
|
91
|
+
}
|
92
|
+
|
93
|
+
# emboss-type
|
94
|
+
EMBOSS = {
|
95
|
+
:emboss => 0,
|
96
|
+
:heavy => 1,
|
97
|
+
:light => 2,
|
98
|
+
:laplacian => 3
|
99
|
+
}
|
100
|
+
|
101
|
+
# gray-type
|
102
|
+
GRAY = {
|
103
|
+
:nrm => 0,
|
104
|
+
:med => 1,
|
105
|
+
:ave => 2
|
106
|
+
}
|
107
|
+
|
108
|
+
# wave-type
|
109
|
+
WAVE = {
|
110
|
+
:horz => 0,
|
111
|
+
:vert => 1,
|
112
|
+
:both => 2
|
113
|
+
}
|
114
|
+
|
115
|
+
# pattern-type
|
116
|
+
PATTERN = {
|
117
|
+
:p_hexagon => 0,
|
118
|
+
:p_diamond => 1,
|
119
|
+
:p_circle => 2,
|
120
|
+
:p_brick => 3
|
121
|
+
}
|
122
|
+
|
123
|
+
# paint-type
|
124
|
+
PAINT = {
|
125
|
+
:line => 0,
|
126
|
+
:ave => 1
|
127
|
+
}
|
128
|
+
|
129
|
+
# tile-type
|
130
|
+
TILE = {
|
131
|
+
:t_rect => 0,
|
132
|
+
:t_hexagon => 1,
|
133
|
+
:t_diamond => 2,
|
134
|
+
:t_circle => 3,
|
135
|
+
:t_brick => 4
|
136
|
+
}
|
137
|
+
|
138
|
+
end
|
data/lib/pikl/errors.rb
CHANGED
File without changes
|
data/lib/pikl/ext.rb
CHANGED
@@ -9,33 +9,140 @@ module Pikl
|
|
9
9
|
dlext = (RbConfig::CONFIG["host_os"] == 'mswin32') ? 'dll' : RbConfig::CONFIG['DLEXT']
|
10
10
|
dlload "#{File.dirname(__FILE__)}/pikl.#{dlext}"
|
11
11
|
|
12
|
-
typealias("
|
12
|
+
typealias("FILE", "void")
|
13
|
+
typealias("PKLImage", "void")
|
14
|
+
typealias("PKLColor", "void")
|
13
15
|
typealias("PKL_FORMAT", "int")
|
14
16
|
typealias("PKL_ANGLE", "int")
|
15
17
|
typealias("PKL_SAMPLE", "int")
|
16
18
|
typealias("uchar", "unsigned char")
|
19
|
+
typealias("PKL_COLOR_SPACE", "int")
|
20
|
+
typealias("PKL_PATTERN_TYPE", "int")
|
21
|
+
typealias("PKL_PAINT_TYPE", "int")
|
22
|
+
typealias("PKL_DITHER", "int")
|
23
|
+
typealias("PKL_WAVE", "int")
|
24
|
+
typealias("PKL_FOCUS", "int")
|
25
|
+
typealias("PKL_EMBOSS", "int")
|
26
|
+
typealias("PKL_COLOR_MODEL", "int")
|
27
|
+
typealias("PKL_TILE_TYPE", "int")
|
28
|
+
typealias("PKL_GRAYTYPE", "int")
|
17
29
|
|
30
|
+
## utility
|
31
|
+
extern "PKLColor *pkl_color_gray(uchar)"
|
32
|
+
extern "PKLColor *pkl_color_rgb(uchar, uchar, uchar)"
|
33
|
+
extern "PKLColor *pkl_color_cmyk(uchar, uchar, uchar, uchar)"
|
34
|
+
extern "PKLColor *pkl_color_create(uchar, uchar, uchar, uchar)"
|
35
|
+
extern "void pkl_color_close(PKLColor*)"
|
36
|
+
extern "uchar pkl_get_color(PKLImage*, int, int, PKL_COLOR_MODEL)"
|
37
|
+
extern "int pkl_set_color(PKLImage*, int, int, PKL_COLOR_MODEL, uchar)"
|
38
|
+
extern "PKLColor *pkl_get_pixel(PKLImage*, int, int)"
|
39
|
+
extern "int pkl_set_pixel(PKLImage*, int, int, PKLColor*)"
|
40
|
+
extern "uchar pkl_color(PKLColor*, PKL_COLOR_MODEL)"
|
41
|
+
|
42
|
+
## basic method
|
18
43
|
extern "PKLImage *pkl_open(char*)"
|
19
44
|
extern "void pkl_close(PKLImage*)"
|
20
45
|
extern "int pkl_save(PKLImage*, const char *, PKL_FORMAT)"
|
21
46
|
extern "int pkl_compress(PKLImage*, int)"
|
47
|
+
extern "PKLImage *pkl_canvas(int, int, PKL_COLOR_SPACE, PKLColor*)"
|
48
|
+
extern "PKLImage *pkl_fdopen(FILE*)"
|
49
|
+
extern "int pkl_output(PKLImage*, FILE*, PKL_FORMAT)"
|
50
|
+
extern "PKLImage *pkl_dup(PKLImage*)"
|
51
|
+
|
52
|
+
## information
|
22
53
|
extern "PKL_FORMAT pkl_format(PKLImage *)"
|
23
54
|
extern "int pkl_width(PKLImage *)"
|
24
55
|
extern "int pkl_height(PKLImage *)"
|
56
|
+
extern "int pkl_count(PKLImage *)"
|
57
|
+
extern "PKL_COLOR_SPACE pkl_colorspace(PKLImage*)"
|
58
|
+
|
59
|
+
## basic operation
|
25
60
|
extern "int pkl_trim(PKLImage *, int, int, int, int)"
|
26
|
-
extern "int pkl_rotate(PKLImage*, PKL_ANGLE)"
|
27
|
-
extern "int pkl_rotate2(PKLImage*, float, PKL_SAMPLE, uchar, uchar, uchar, uchar)"
|
28
61
|
extern "int pkl_resize(PKLImage*, int, int, PKL_SAMPLE)"
|
62
|
+
extern "int pkl_rotate(PKLImage*, float, PKL_SAMPLE, PKLColor*)"
|
63
|
+
extern "int pkl_affine(PKLImage*, PKL_SAMPLE, int, int, PKLColor*, double, double, double, int, int)"
|
64
|
+
|
65
|
+
## enhance
|
29
66
|
extern "int pkl_unsharp(PKLImage *, int, double)"
|
30
|
-
extern "int pkl_contrast(PKLImage
|
67
|
+
extern "int pkl_contrast(PKLImage*, int)"
|
31
68
|
extern "int pkl_level(PKLImage *, double, double, double)"
|
32
69
|
extern "int pkl_brightness(PKLImage*, int)"
|
33
70
|
extern "int pkl_hls(PKLImage*, double, double, double)"
|
34
71
|
extern "int pkl_gamma(PKLImage*, double)"
|
72
|
+
extern "int pkl_noisecut(PKLImage*)"
|
73
|
+
|
74
|
+
## blur
|
75
|
+
extern "int pkl_blur(PKLImage*, int)"
|
76
|
+
extern "int pkl_gaussblur(PKLImage*, double)"
|
77
|
+
extern "int pkl_rblur(PKLImage*, int, int, double, int)"
|
78
|
+
extern "int pkl_ablur(PKLImage*, int, int, double, int)"
|
79
|
+
extern "int pkl_wblur(PKLImage*, int, int, double, int, double)"
|
80
|
+
extern "int pkl_mblur(PKLImage*, double, int)"
|
81
|
+
|
82
|
+
## pattern
|
83
|
+
extern "int pkl_pattern(PKLImage*, int, int, PKL_PATTERN_TYPE, PKL_PAINT_TYPE)"
|
84
|
+
extern "int pkl_mosaic(PKLImage*, int, int)"
|
85
|
+
extern "int pkl_pixelate(PKLImage*, int)"
|
86
|
+
extern "int pkl_grid(PKLImage*, int, int, int)"
|
87
|
+
extern "int pkl_tile(PKLImage*, PKL_TILE_TYPE, int, int, uchar)"
|
88
|
+
|
89
|
+
## voronoi
|
90
|
+
extern "int pkl_voronoi_zone(PKLImage*, int, PKLColor*, int)"
|
91
|
+
extern "int pkl_voronoi_count(PKLImage*, int, PKLColor*, int)"
|
92
|
+
|
93
|
+
## decrease
|
94
|
+
extern "int pkl_posterize(PKLImage*, int)"
|
95
|
+
extern "int pkl_cutcolor(PKLImage*, int)"
|
96
|
+
extern "int pkl_rgb(PKLImage*)"
|
97
|
+
extern "int pkl_gray(PKLImage*, PKL_GRAYTYPE)"
|
98
|
+
extern "int pkl_2c(PKLImage*, int)"
|
99
|
+
|
100
|
+
## divide
|
101
|
+
extern "int pkl_tileslit(PKLImage*, int, int)"
|
102
|
+
extern "int pkl_splitframe(PKLImage*, PKLColor*, int, int, int, int)"
|
103
|
+
|
104
|
+
## composite
|
105
|
+
extern "int pkl_composite(PKLImage*, PKLImage*, int, int, PKLColor*)"
|
106
|
+
extern "int pkl_alphablend(PKLImage*, PKLImage*, int, int, int)"
|
107
|
+
extern "int pkl_shadowframe(PKLImage*, int, PKLColor*, PKLColor*)"
|
108
|
+
extern "int pkl_randomshadow(PKLImage*, PKLImage*, int, int, int, PKLColor*)"
|
109
|
+
|
110
|
+
## basic effect
|
111
|
+
extern "int pkl_invert(PKLImage*)"
|
112
|
+
extern "int pkl_sepia(PKLImage*, double, double, double)"
|
113
|
+
extern "int pkl_oilpaint(PKLImage*, int)"
|
114
|
+
extern "int pkl_kuwahara(PKLImage*, int)"
|
115
|
+
extern "int pkl_noise(PKLImage*, int)"
|
116
|
+
extern "int pkl_vtr(PKLImage*, int, int, int)"
|
117
|
+
extern "int pkl_dither(PKLImage*, PKL_DITHER)"
|
118
|
+
extern "int pkl_edgepaint(PKLImage*, int)"
|
119
|
+
extern "int pkl_edge(PKLImage*, int)"
|
120
|
+
extern "int pkl_contour(PKLImage*)"
|
121
|
+
extern "int pkl_focus(PKLImage*, PKL_FOCUS)"
|
122
|
+
extern "int pkl_emboss(PKLImage*, PKL_EMBOSS)"
|
123
|
+
extern "int pkl_emboss2(PKLImage*, int *, int, int, double, int)"
|
124
|
+
|
125
|
+
## camera
|
126
|
+
extern "int pkl_vignette(PKLImage*, PKLColor*, int, int, int, int)"
|
127
|
+
extern "int pkl_vaseline(PKLImage*, int, int, int)"
|
128
|
+
extern "int pkl_film(PKLImage*, PKLColor*, int)"
|
129
|
+
extern "int pkl_vv(PKLImage*, PKLColor*, int, int, int, int)"
|
130
|
+
|
131
|
+
## special
|
132
|
+
extern "int pkl_edgeposter(PKLImage*, int, double, double, double, int)"
|
133
|
+
extern "int pkl_crayon(PKLImage*, double, int, int, int)"
|
134
|
+
extern "int pkl_rinkaku(PKLImage*, double)"
|
135
|
+
extern "int pkl_hydrangea(PKLImage*, int, double, double, double, double, double)"
|
136
|
+
extern "int pkl_alphaedge(PKLImage*, int, double, double, double, int, int)"
|
137
|
+
|
138
|
+
## scrap
|
139
|
+
extern "int pkl_swirl(PKLImage*, double, int, int, PKLColor*)"
|
140
|
+
extern "int pkl_wave(PKLImage*, PKL_WAVE, double, double)"
|
141
|
+
extern "int pkl_dots(PKLImage*, int, PKLColor*)"
|
142
|
+
extern "int pkl_colordither(PKLImage*, int)"
|
143
|
+
extern "int pkl_sobelpaint(PKLImage*, int, float, float, float)"
|
144
|
+
extern "int pkl_illust(PKLImage*, int, int, int)"
|
145
|
+
extern "int pkl_color_emboss(PKLImage*, double, double)"
|
35
146
|
|
36
|
-
extern "int pkl_mosaic(PKLImage *, int, int)"
|
37
|
-
extern "int pkl_composite(PKLImage *, PKLImage *, int, int)"
|
38
|
-
extern "int pkl_mediancut(PKLImage *, int, int)"
|
39
|
-
extern "int pkl_alphablend(PKLImage *, PKLImage *, int, int, int)"
|
40
147
|
end
|
41
148
|
end
|
data/lib/pikl/filter.rb
ADDED
@@ -0,0 +1,371 @@
|
|
1
|
+
module Pikl
|
2
|
+
|
3
|
+
class Image
|
4
|
+
|
5
|
+
# unshapmask
|
6
|
+
def unshapmask(threshold, edge)
|
7
|
+
error("invalid parameter. # => #{threshold}") if threshold.to_i<0 || threshold.to_i>255
|
8
|
+
error("invalid parameter. # => #{edge}") if edge.to_f<-10.0 || edge.to_f>10.0
|
9
|
+
Ext.pkl_unsharp(@pkl_image, threshold.to_i, edge.to_f)
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
# コントラスト調整
|
14
|
+
def contrast(rate)
|
15
|
+
error("invalid parameter. # => #{rate}") if rate<-127 || rate>127
|
16
|
+
Ext.pkl_contrast(@pkl_image, rate.to_i)
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
# レベル補正
|
21
|
+
def level(low, high, coeff)
|
22
|
+
Ext.pkl_level(@pkl_image, low.to_f, high.to_f, coeff.to_f)
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
# 明るさ調整
|
27
|
+
def brightness(color)
|
28
|
+
Ext.pkl_brightness(@pkl_image, color.to_i)
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
# 輝度(明るさ)・彩度(鮮やかさ)・色相(色合い)調整
|
33
|
+
def hls(ym, sm ,hd)
|
34
|
+
error("invalid parameter. # => #{ym}") if ym.to_f<-1.0 || ym.to_f>1.0
|
35
|
+
error("invalid parameter. # => #{sm}") if sm.to_f<-1.0 || sm.to_f>1.0
|
36
|
+
Ext.pkl_hls(@pkl_image, ym.to_f, sm.to_f, hd.to_f)
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
# gamma correction
|
41
|
+
# _gm_ :: compensating rate.
|
42
|
+
# gm must be >= 0 and image is neutral if gm value is 1.0.
|
43
|
+
def gamma(gm)
|
44
|
+
Ext.pkl_gamma(@pkl_image, gm.to_f)
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
# compose image
|
49
|
+
# _image_ :: another pikl image object.
|
50
|
+
# _xpos_ :: left position of composing image.
|
51
|
+
# _ypos_ :: top position of composing image.
|
52
|
+
def compose(image, xpos, ypos)
|
53
|
+
Ext.pkl_composite(@pkl_image, image.rawdata, xpos, ypos)
|
54
|
+
self
|
55
|
+
end
|
56
|
+
|
57
|
+
# alphablend
|
58
|
+
# _image_ :: another pikl image object.
|
59
|
+
# _xpos_ :: left position of blend image.
|
60
|
+
# _ypos_ :: top position of blend image.
|
61
|
+
# _alpha_ :: alpha: α-value(0-255). 255 is complete transparent.
|
62
|
+
def alphablend(image, xpos, ypos, alpha)
|
63
|
+
Ext.pkl_alphablend(@pkl_image, image.rawdata, xpos, ypos, alpha);
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
# mosaic effect
|
68
|
+
# _width_ :: width for mosaic unit.
|
69
|
+
# _height_ :: height for mosaic unit.
|
70
|
+
def mosaic(width, height)
|
71
|
+
Ext.pkl_mosaic(@pkl_image, width, height)
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
# 反転
|
76
|
+
def invert
|
77
|
+
Ext.pkl_invert(@pkl_image) if(@pkl_image)
|
78
|
+
end
|
79
|
+
|
80
|
+
# 手書き風
|
81
|
+
def alphaedge(level=8, low=1.5, high=1.5, coeff=1.0, threshold=50, alpha=80)
|
82
|
+
error("invalid parameter. # => #{level}") if level<1 || level>256
|
83
|
+
error("invalid parameter. # => #{threshold}") if threshold<0 || threshold>80
|
84
|
+
error("invalid parameter. # => #{alpha}") if alpha<0 || alpha>=256
|
85
|
+
Ext.pkl_alphaedge(@pkl_image, level.to_i, low.to_f, high.to_f, coeff.to_f, threshold.to_i, alpha.to_i)
|
86
|
+
end
|
87
|
+
|
88
|
+
# クレヨン風
|
89
|
+
def crayon(factor=15.0, bv1=3, bv2=2, alpha=80)
|
90
|
+
error("invalid parameter. # => #{factor}") if factor.to_f<5.0 || factor.to_f>80.0
|
91
|
+
error("invalid parameter. # => #{alpha}") if alpha<0 || alpha>=256
|
92
|
+
Ext.pkl_crayon(@pkl_image, factor.to_f, bv1.to_i, bv2.to_i, alpha.to_i)
|
93
|
+
end
|
94
|
+
|
95
|
+
# ポスター風
|
96
|
+
def edgeposter(level=4, low=1.5, high=1.5, coeff=1.0, edge=1)
|
97
|
+
error("invalid parameter. # => #{level}") if level<2 || level>8
|
98
|
+
error("invalid parameter. # => #{edge}") if edge<0 || edge>5
|
99
|
+
Ext.pkl_edgeposter(@pkl_image, level.to_i, low.to_f, high.to_f, coeff.to_f, edge.to_i)
|
100
|
+
end
|
101
|
+
|
102
|
+
# あじさい風
|
103
|
+
def hydrangea(zone=10, low=1.5, high=1.5, coeff=1.0, mil=50, env=70)
|
104
|
+
error("invalid parameter. # => #{mil}") if mil.to_f<1 || mil.to_f>400
|
105
|
+
error("invalid parameter. # => #{env}") if env.to_f<1 || env.to_f>100
|
106
|
+
Ext.pkl_hydrangea(@pkl_image, zone.to_i, low.to_f, high.to_f, coeff.to_f, mil.to_f, env.to_f)
|
107
|
+
end
|
108
|
+
|
109
|
+
# 凝った輪郭
|
110
|
+
def rinkaku(factor=30.0)
|
111
|
+
Ext.pkl_rinkaku(@pkl_image, factor.to_f)
|
112
|
+
end
|
113
|
+
|
114
|
+
# voronoi-zone
|
115
|
+
def voronoi_zone(zone, color=nil, edge=false)
|
116
|
+
_color = nil
|
117
|
+
unless color.nil?
|
118
|
+
_color=color.rawdata if color.class.name == 'Pikl::Color'
|
119
|
+
end
|
120
|
+
_edge = edge ? 1 : 0
|
121
|
+
Ext.pkl_voronoi_zone(@pkl_image, zone.to_i, _color, _edge)
|
122
|
+
end
|
123
|
+
|
124
|
+
# voronoi-count
|
125
|
+
def voronoi_count(count, color=nil, edge=false)
|
126
|
+
_color = nil
|
127
|
+
unless color.nil?
|
128
|
+
_color=color.rawdata if color.class.name == 'Pikl::Color'
|
129
|
+
end
|
130
|
+
_edge = edge ? 1 : 0
|
131
|
+
Pikl::Ext.pkl_voronoi_count(@pkl_image, count.to_i, _color, _edge)
|
132
|
+
end
|
133
|
+
|
134
|
+
# sepia
|
135
|
+
def sepia(red_weight, green_weight, blue_weight)
|
136
|
+
error("invalid parameter. # => #{red_weight}") if red_weight.to_f<0.0 || red_weight.to_f>1.0
|
137
|
+
error("invalid parameter. # => #{green_weight}") if green_weight.to_f<0.0 || green_weight.to_f>1.0
|
138
|
+
error("invalid parameter. # => #{blue_weight}") if blue_weight.to_f<0.0 || blue_weight.to_f>1.0
|
139
|
+
Ext.pkl_sepia(@pkl_image, red_weight.to_f, green_weight.to_f, blue_weight.to_f)
|
140
|
+
end
|
141
|
+
|
142
|
+
# oilpaint
|
143
|
+
def oilpaint(weight=3)
|
144
|
+
error("invalid parameter. # => #{weight}") if weight.to_i<2 || weight.to_i>6
|
145
|
+
Ext.pkl_oilpaint(@pkl_image, weight.to_i)
|
146
|
+
end
|
147
|
+
|
148
|
+
# kuwahara
|
149
|
+
def kuwahara(weight=3)
|
150
|
+
error("invalid parameter. # => #{weight}") if weight.to_i<2 || weight.to_i>5
|
151
|
+
Ext.pkl_kuwahara(@pkl_image, weight.to_i)
|
152
|
+
end
|
153
|
+
|
154
|
+
# blot
|
155
|
+
def blot(level=3)
|
156
|
+
Ext.pkl_noise(@pkl_image, level.to_i)
|
157
|
+
end
|
158
|
+
|
159
|
+
# vtr
|
160
|
+
def vtr(colspace=3, gst=10, cst=10)
|
161
|
+
Ext.pkl_vtr(@pkl_image, colspace.to_i, gst.to_i, cst.to_i)
|
162
|
+
end
|
163
|
+
|
164
|
+
# dither
|
165
|
+
def dither(type=:floydsteinberg)
|
166
|
+
error("invalid parameter. # => #{type}") unless DITHER.include?(type)
|
167
|
+
Ext.pkl_dither(@pkl_image, DITHER[type])
|
168
|
+
end
|
169
|
+
|
170
|
+
# edgepaint
|
171
|
+
def edgepaint(edge=1)
|
172
|
+
Ext.pkl_edgepaint(@pkl_image, edge.to_i)
|
173
|
+
end
|
174
|
+
|
175
|
+
# edge
|
176
|
+
# threshold=0..30
|
177
|
+
def edge(threshold=15)
|
178
|
+
Ext.pkl_edge(@pkl_image, threshold.to_i)
|
179
|
+
end
|
180
|
+
|
181
|
+
def contour
|
182
|
+
Ext.pkl_contour(@pkl_image)
|
183
|
+
end
|
184
|
+
|
185
|
+
def focus(type=:detail)
|
186
|
+
error("invalid parameter. # => #{type}") unless FOCUS.include?(type)
|
187
|
+
Ext.pkl_focus(@pkl_image, FOCUS[type])
|
188
|
+
end
|
189
|
+
|
190
|
+
def emboss(type=:light)
|
191
|
+
error("invalid parameter. # => #{type}") unless EMBOSS.include?(type)
|
192
|
+
Ext.pkl_emboss(@pkl_image, EMBOSS[type])
|
193
|
+
end
|
194
|
+
|
195
|
+
def emboss2(mask, w, h, factor=1.0, offset=0)
|
196
|
+
error("invalid parameter. # => #{mask}") unless mask.class.name == 'Array'
|
197
|
+
error("invalid parameter. # => #{mask} or #{w} or #{h}") unless mask.length == w.to_i*h.to_i
|
198
|
+
Ext.pkl_emboss2(@pkl_image, mask, w.to_i, h.to_i, factor.to_f, offset.to_i)
|
199
|
+
end
|
200
|
+
|
201
|
+
def noisecut
|
202
|
+
Ext.pkl_noisecut(@pkl_image)
|
203
|
+
end
|
204
|
+
|
205
|
+
def blur(weight)
|
206
|
+
Ext.pkl_blur(@pkl_image, weight.to_i)
|
207
|
+
end
|
208
|
+
|
209
|
+
def gaussblur(weight)
|
210
|
+
Ext.pkl_gaussblur(@pkl_image, weight.to_f)
|
211
|
+
end
|
212
|
+
|
213
|
+
def rblur(x=-1, y=-1, ef=30.0, weight=5)
|
214
|
+
Ext.pkl_rblur(@pkl_image, x.to_i, y.to_i, ef.to_f, weight.to_i)
|
215
|
+
end
|
216
|
+
|
217
|
+
def ablur(x=-1, y=-1, ef=30.0, weight=5)
|
218
|
+
Ext.pkl_ablur(@pkl_image, x.to_i, y.to_i, ef.to_f, weight.to_i)
|
219
|
+
end
|
220
|
+
|
221
|
+
def wblur(x=-1, y=-1, ef=30.0, weight=5, angle=45.0)
|
222
|
+
Ext.pkl_wblur(@pkl_image, x.to_i, y.to_i, ef.to_f, weight.to_i, angle.to_f)
|
223
|
+
end
|
224
|
+
|
225
|
+
def mblur(angle, weight)
|
226
|
+
Ext.pkl_mblur(@pkl_image, angle.to_f, weight.to_i)
|
227
|
+
end
|
228
|
+
|
229
|
+
def shadowframe(margin, backcolor=nil, shadowcolor=nil)
|
230
|
+
_backcolor = nil
|
231
|
+
unless backcolor.nil?
|
232
|
+
_backcolor = backcolor.rawdata if backcolor.class.name == 'Pikl::Color'
|
233
|
+
end
|
234
|
+
|
235
|
+
_shadowcolor = nil
|
236
|
+
unless shadowcolor.nil?
|
237
|
+
_shadowcolor = shadowcolor.rawdata if shadowcolor.class.name == 'Pikl::Color'
|
238
|
+
end
|
239
|
+
|
240
|
+
Ext.pkl_shadowframe(@pkl_image, margin.to_i, _backcolor, _shadowcolor)
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
def randomshadow(child, x, y, margin, shadowcolor=nil)
|
245
|
+
error("invalid parameter. # => #{child}") unless child.class.name == 'Pikl::Image'
|
246
|
+
_shadowcolor = nil
|
247
|
+
unless shadowcolor.nil?
|
248
|
+
_shadowcolor = shadowcolor.rawdata if shadowcolor.class.name == 'Pikl::Color'
|
249
|
+
end
|
250
|
+
Pikl::Ext.pkl_randomshadow(@pkl_image, child.rawdata, x.to_i, y.to_i, margin.to_i, _shadowcolor)
|
251
|
+
end
|
252
|
+
|
253
|
+
def pixelate(ms)
|
254
|
+
Ext.pkl_pixelate(@pkl_image, ms.to_i)
|
255
|
+
end
|
256
|
+
|
257
|
+
def grid(msx, msy, color)
|
258
|
+
Ext.pkl_grid(@pkl_image, msx.to_i, msy.to_i, color.to_i)
|
259
|
+
end
|
260
|
+
|
261
|
+
def posterize(level)
|
262
|
+
error("invalid parameter. # => #{level}") unless level>1 && level<256
|
263
|
+
Ext.pkl_posterize(@pkl_image, level.to_i)
|
264
|
+
end
|
265
|
+
|
266
|
+
def cutcolor(level)
|
267
|
+
Ext.pkl_cutcolor(@pkl_image, level)
|
268
|
+
end
|
269
|
+
|
270
|
+
# cmyk-model only
|
271
|
+
def rgb
|
272
|
+
Ext.pkl_rgb(@pkl_image)
|
273
|
+
end
|
274
|
+
|
275
|
+
def gray(type=:nrm)
|
276
|
+
error("invalid parameter. # => #{type}") unless GRAY.include?(type)
|
277
|
+
Ext.pkl_gray(@pkl_image, GRAY[type])
|
278
|
+
end
|
279
|
+
|
280
|
+
def blackwhite(level=127)
|
281
|
+
Ext.pkl_2c(@pkl_image, level.to_i)
|
282
|
+
end
|
283
|
+
|
284
|
+
def tileslit(area, shift)
|
285
|
+
Ext.pkl_tileslit(@pkl_image, area.to_i, shift.to_i)
|
286
|
+
end
|
287
|
+
|
288
|
+
def splitframe(backcolor, wbs, hbs, margin, frame)
|
289
|
+
error("invalid parameter. # => #{backcolor}") unless backcolor != nil
|
290
|
+
error("invalid parameter. # => #{backcolor}") unless backcolor.class.name == 'Pikl::Color'
|
291
|
+
Ext.pkl_splitframe(@pkl_image, backcolor.rawdata, wbs.to_i, hbs.to_i, margin.to_i, frame.to_i)
|
292
|
+
end
|
293
|
+
|
294
|
+
def vignette(color, trans, radius, x=-1, y=-1)
|
295
|
+
error("invalid parameter. # => #{color}") unless color != nil
|
296
|
+
error("invalid parameter. # => #{color}") unless color.class.name == 'Pikl::Color'
|
297
|
+
Ext.pkl_vignette(@pkl_image, color.rawdata, trans.to_i, radius.to_i, x.to_i, y.to_i)
|
298
|
+
end
|
299
|
+
|
300
|
+
def vaseline(radius, x=-1, y=-1)
|
301
|
+
Ext.pkl_vaseline(@pkl_image, radius.to_i, x.to_i, y.to_i)
|
302
|
+
end
|
303
|
+
|
304
|
+
def vv(color, trans, radius, x=-1, y=-1)
|
305
|
+
error("invalid parameter. # => #{color}") unless color != nil
|
306
|
+
error("invalid parameter. # => #{color}") unless color.class.name == 'Pikl::Color'
|
307
|
+
Ext.pkl_vv(@pkl_image, color.rawdata, trans.to_i, radius.to_i, x.to_i, y.to_i)
|
308
|
+
end
|
309
|
+
|
310
|
+
def film(color, trans)
|
311
|
+
error("invalid parameter. # => #{color}") unless color != nil
|
312
|
+
error("invalid parameter. # => #{color}") unless color.class.name == 'Pikl::Color'
|
313
|
+
Ext.pkl_film(@pkl_image, color.rawdata, trans.to_i)
|
314
|
+
end
|
315
|
+
|
316
|
+
def swirl(factor, x, y, color)
|
317
|
+
error("invalid parameter. # => #{color}") unless color != nil
|
318
|
+
error("invalid parameter. # => #{color}") unless color.class.name == 'Pikl::Color'
|
319
|
+
Ext.pkl_swirl(@pkl_image, factor.to_f, x.to_i, y.to_i, color.rawdata)
|
320
|
+
end
|
321
|
+
|
322
|
+
def wave(factor, frequency, type=:both)
|
323
|
+
error("invalid parameter. # => #{type}") unless WAVE.include?(type)
|
324
|
+
Ext.pkl_wave(@pkl_image, WAVE[type], factor.to_f, frequency.to_f)
|
325
|
+
end
|
326
|
+
|
327
|
+
def dots(zone, color)
|
328
|
+
error("invalid parameter. # => #{color}") unless color != nil
|
329
|
+
error("invalid parameter. # => #{color}") unless color.class.name == 'Pikl::Color'
|
330
|
+
Ext.pkl_dots(@pkl_image, zone, color.rawdata)
|
331
|
+
end
|
332
|
+
|
333
|
+
def colordither(weight)
|
334
|
+
Ext.pkl_colordither(@pkl_image, weight.to_i)
|
335
|
+
end
|
336
|
+
|
337
|
+
def fantasy(edgeweight, mix, saturation, hue)
|
338
|
+
Ext.pkl_sobelpaint(@pkl_image, edgeweight.to_i, mix.to_f, saturation.to_f, hue.to_f)
|
339
|
+
end
|
340
|
+
|
341
|
+
def illust(gap, edge, gammaint)
|
342
|
+
Ext.pkl_illust(@pkl_image, gap.to_i, edge.to_i, gammaint.to_i)
|
343
|
+
end
|
344
|
+
|
345
|
+
def color_emboss(mil, env)
|
346
|
+
Ext.pkl_color_emboss(@pkl_image, mil.to_f, env.to_f)
|
347
|
+
end
|
348
|
+
|
349
|
+
def pattern(width, height, pattern=:p_hexagon, paint=:ave)
|
350
|
+
error("invalid parameter. # => #{pattern}") unless PATTERN.include?(pattern)
|
351
|
+
error("invalid parameter. # => #{paint}") unless PAINT.include?(paint)
|
352
|
+
Ext.pkl_pattern(@pkl_image, width.to_i, height.to_i, PATTERN[pattern], PAINT[paint])
|
353
|
+
end
|
354
|
+
|
355
|
+
def tile(msx, msy, level, type=:t_rect)
|
356
|
+
error("invalid parameter. # => #{type}") unless TILE.include?(type)
|
357
|
+
Ext.pkl_tile(@pkl_image, TILE[type], msx.to_i, msy.to_i, level.to_i)
|
358
|
+
end
|
359
|
+
|
360
|
+
def affine(width, height, color, xscale, yscale, angle, x, y, sample=:bilinear)
|
361
|
+
error("invalid parameter. # => #{type}") unless SAMPLES.include?(sample)
|
362
|
+
error("invalid parameter. # => #{color}") unless color != nil
|
363
|
+
error("invalid parameter. # => #{color}") unless color.class.name == 'Pikl::Color'
|
364
|
+
Ext.pkl_affine(@pkl_image, SAMPLES[sample], width.to_i, height.to_i, color.rawdata, xscale.to_f, yscale.to_f, angle.to_f, x.to_i, y.to_i)
|
365
|
+
end
|
366
|
+
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
|
371
|
+
|