pikl 0.2.3-x86-mswin32 → 0.2.5-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 CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.2.5
2
+ * Added fit method.
3
+
4
+ == 0.2.4
5
+ * Added flexible rotate.
6
+
1
7
  == 0.2.3
2
8
  * Change description.
3
9
 
data/Manifest.txt CHANGED
@@ -2,7 +2,6 @@ History.txt
2
2
  License.txt
3
3
  Manifest.txt
4
4
  README.txt
5
- Rakefile
6
5
  config/hoe.rb
7
6
  config/requirements.rb
8
7
  ext/pikl/extconf.rb
@@ -22,6 +21,8 @@ ext/pikl/pikl_resize.c
22
21
  ext/pikl/pikl_resize.h
23
22
  ext/pikl/pikl_rotate.c
24
23
  ext/pikl/pikl_rotate.h
24
+ ext/pikl/pikl_rotate2.c
25
+ ext/pikl/pikl_rotate2.h
25
26
  ext/pikl/pikl_trim.c
26
27
  ext/pikl/pikl_trim.h
27
28
  lib/pikl.rb
data/config/hoe.rb CHANGED
@@ -70,7 +70,7 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
70
70
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
71
71
  #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
72
72
  if PACKAGE_PLATFORM =~ /mswin32/
73
- platform = Gem::Platform.new('mswin32')
73
+ platform = Gem::Platform.respond_to?(:new) ? Gem::Platform.new('mswin32') : Gem::Platform::WIN32
74
74
  p.spec_extras[:platform] = platform
75
75
  else
76
76
  p.spec_extras[:extensions] = ['ext/pikl/extconf.rb']
data/ext/pikl/pikl.h CHANGED
@@ -131,6 +131,11 @@ PKLExport int pkl_trim(PKLImage pkl, int sx, int sy, int width, int height);
131
131
  */
132
132
  PKLExport int pkl_rotate(PKLImage pkl, PKL_ANGLE angle);
133
133
 
134
+ //#define pkl_color(a,b,c,d) ((a<<24)+(b<<16)+(c<<8)+d)
135
+ //PKLExport int pkl_rotate2(PKLImage pkl, float angle, PKL_SAMPLE sample, int backcolor);
136
+ PKLExport int pkl_rotate2(PKLImage pkl, float angle, PKL_SAMPLE sample,
137
+ unsigned char a, unsigned char b, unsigned char c, unsigned char d);
138
+
134
139
  /*!
135
140
  拡大・縮小します。<br>
136
141
  @param pkl [in] PKLImageオブジェクト
data/ext/pikl/pikl_png.c CHANGED
@@ -24,11 +24,11 @@ int load_png(PKLImage pkl, FILE *image)
24
24
  return(1);
25
25
  }
26
26
 
27
- if( setjmp(png_jmpbuf(png_ptr)) ){
28
- png_destroy_info_struct(png_ptr, &info_ptr);
29
- png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
30
- return(1);
31
- }
27
+ //if( setjmp(png_jmpbuf(png_ptr)) ){
28
+ // png_destroy_info_struct(png_ptr, &info_ptr);
29
+ // png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
30
+ // return(1);
31
+ //}
32
32
 
33
33
  png_init_io(png_ptr, image);
34
34
  png_read_info(png_ptr, info_ptr);
@@ -75,11 +75,11 @@ int save_png(PKLImage pkl, FILE *image)
75
75
  return(1);
76
76
  }
77
77
 
78
- if( setjmp(png_jmpbuf(png_ptr)) ){
79
- png_destroy_info_struct(png_ptr, &info_ptr);
80
- png_destroy_write_struct(&png_ptr, &info_ptr);
81
- return(1);
82
- }
78
+ //if( setjmp(png_jmpbuf(png_ptr)) ){
79
+ // png_destroy_info_struct(png_ptr, &info_ptr);
80
+ // png_destroy_write_struct(&png_ptr, &info_ptr);
81
+ // return(1);
82
+ //}
83
83
 
84
84
  png_init_io(png_ptr, image);
85
85
  info_ptr->width = pkl->width;
data/ext/pikl/pikl_png.h CHANGED
@@ -4,7 +4,7 @@
4
4
  #include <stdio.h>
5
5
  #include <stdlib.h>
6
6
  #include <string.h>
7
- #include <setjmp.h>
7
+ //#include <setjmp.h>
8
8
  #include <png.h>
9
9
 
10
10
  #include "pikl.h"
@@ -0,0 +1,312 @@
1
+ #include "pikl_rotate2.h"
2
+
3
+ static void get_rect(PIKL_RECT *rect, int w, int h, float rad);
4
+ static int ext_cmp_int(const void *a, const void *b);
5
+ static int pkl_rotate_nn(PKLImage pkl, float angle, unsigned char *backcolor);
6
+ static int pkl_rotate_bl(PKLImage pkl, float angle, unsigned char *backcolor);
7
+ static int pkl_rotate_bc(PKLImage pkl, float angle, unsigned char *backcolor);
8
+ //static int pkl_rotate_pa(PKLImage pkl, float angle, int backcolor);
9
+ //===================================================================
10
+ // pkl_rotate2
11
+ //===================================================================
12
+ PKLExport int pkl_rotate2(PKLImage pkl, float angle, PKL_SAMPLE sample,
13
+ unsigned char a, unsigned char b, unsigned char c, unsigned char d)
14
+ {
15
+ unsigned char backcolor[4];
16
+
17
+ backcolor[0] = a;
18
+ backcolor[1] = b;
19
+ backcolor[2] = c;
20
+ backcolor[3] = d;
21
+
22
+ switch(sample){
23
+ case PKL_SAMPLE_NN:
24
+ return pkl_rotate_nn(pkl, angle, backcolor);
25
+ case PKL_SAMPLE_BL:
26
+ return pkl_rotate_bl(pkl, angle, backcolor);
27
+ case PKL_SAMPLE_BC:
28
+ case PKL_SAMPLE_PA:
29
+ case PKL_SAMPLE_LZ:
30
+ return pkl_rotate_bc(pkl, angle, backcolor);
31
+ //return pkl_rotate_pa(pkl, angle, backcolor);
32
+ default:
33
+ return(1);
34
+ }
35
+ return(1);
36
+ }
37
+
38
+ //=============================================================================
39
+ // rotate_pos
40
+ //=============================================================================
41
+ static void get_rect(PIKL_RECT *rect, int width, int height, float rad)
42
+ {
43
+ int nimg_x[4], nimg_y[4];
44
+ int i, x, y;
45
+
46
+ nimg_x[0] = 0;
47
+ nimg_y[0] = 0;
48
+ nimg_x[1] = width;
49
+ nimg_y[1] = 0;
50
+ nimg_x[2] = 0;
51
+ nimg_y[2] = height;
52
+ nimg_x[3] = width;
53
+ nimg_y[3] = height;
54
+
55
+ for(i=0; i<4; i++){
56
+ x = (int)(cos(-rad)*nimg_x[i] - sin(-rad)*nimg_y[i]);
57
+ y = (int)(sin(-rad)*nimg_x[i] + cos(-rad)*nimg_y[i]);
58
+ nimg_x[i] = x;
59
+ nimg_y[i] = y;
60
+ }
61
+ qsort(nimg_x, 4, sizeof(int), ext_cmp_int);
62
+ qsort(nimg_y, 4, sizeof(int), ext_cmp_int);
63
+ rect->left = nimg_x[0];
64
+ rect->top = nimg_y[0];
65
+ rect->right = nimg_x[3];
66
+ rect->bottom = nimg_y[3];
67
+ }
68
+
69
+ //=================================================================================
70
+ // ext_cmp_int
71
+ //=================================================================================
72
+ static int ext_cmp_int(const void *a, const void *b)
73
+ {
74
+ return *((int *)a) - *((int *)b);
75
+ }
76
+
77
+ //=============================================================================
78
+ // pkl_rotate_nn
79
+ //=============================================================================
80
+ static int pkl_rotate_nn(PKLImage pkl, float angle, unsigned char *backcolor)
81
+ {
82
+ int width, height;
83
+ PIKL_RECT rect;
84
+ float rad;
85
+ unsigned char *wrk, back[4];
86
+ int i, j, px, py;
87
+
88
+ rad = -angle*M_PI/180;
89
+ get_rect(&rect, pkl->width, pkl->height, rad);
90
+ width = rect.right - rect.left;
91
+ height = rect.bottom - rect.top;
92
+
93
+ wrk = malloc(width * height * pkl->channel);
94
+ if(!wrk) return(1);
95
+ memset(wrk, 0, width*height*pkl->channel);
96
+
97
+ //for(i=0; i<pkl->channel; i++)
98
+ // back[i] = (backcolor>>((pkl->channel-i)*8) & 0xFF);
99
+ memcpy(back, backcolor, pkl->channel);
100
+
101
+ for(i=rect.top; i<rect.bottom; i++){
102
+ for(j=rect.left; j<rect.right; j++){
103
+ px = (int)(cos(rad) * j - sin(rad) * i);
104
+ py = (int)(sin(rad) * j + cos(rad) * i);
105
+ if(px>=0 && px<pkl->width && py>=0 && py<pkl->height){
106
+ memcpy(&wrk[((i-rect.top)*width+j-rect.left)*pkl->channel],
107
+ &pkl->image[(py*pkl->width+px)*pkl->channel], pkl->channel);
108
+ }else{
109
+ memcpy(&wrk[((i-rect.top)*width+j-rect.left)*pkl->channel], back, pkl->channel);
110
+ }
111
+ }
112
+ }
113
+
114
+ free(pkl->image);
115
+ pkl->image = wrk;
116
+ pkl->width = width;
117
+ pkl->height = height;
118
+ return(0);
119
+ }
120
+
121
+ //=============================================================================
122
+ // pkl_rotate_bl
123
+ //=============================================================================
124
+ static int pkl_rotate_bl(PKLImage pkl, float angle, unsigned char *backcolor)
125
+ {
126
+ int width, height;
127
+ PIKL_RECT rect;
128
+ float rad;
129
+ unsigned char *wrk, back[4];
130
+ int i, j, k, wx, wy, sx, sy;
131
+ double dx, dy, px, py, f[4];
132
+
133
+ rad = -angle*M_PI/180;
134
+ get_rect(&rect, pkl->width, pkl->height, rad);
135
+ width = rect.right - rect.left;
136
+ height = rect.bottom - rect.top;
137
+
138
+ wrk = malloc(width * height * pkl->channel);
139
+ if(!wrk) return(1);
140
+ memset(wrk, 0, width*height*pkl->channel);
141
+
142
+ //for(i=0; i<pkl->channel; i++)
143
+ // back[i] = (backcolor>>((pkl->channel-i)*8) & 0xFF);
144
+ memcpy(back, backcolor, pkl->channel);
145
+
146
+ for(i=rect.top; i<rect.bottom; i++){
147
+ for(j=rect.left; j<rect.right; j++){
148
+ dx = modf(cos(rad)*j-sin(rad)*i, &px);
149
+ dy = modf(sin(rad)*j+cos(rad)*i, &py);
150
+ f[0] = (1.0-dx)*(1.0-dy);
151
+ f[1] = dx*(1.0-dy);
152
+ f[2] = (1.0-dx)*dy;
153
+ f[3] = dx*dy;
154
+
155
+ for(wy=0; wy<2; wy++){
156
+ for(wx=0; wx<2; wx++){
157
+ sx = ((int)px+wx<0) ? pkl->width +((int)px+wx)%pkl->width -1 : ((int)px+wx)%pkl->width;
158
+ sy = ((int)py+wy<0) ? pkl->height+((int)py+wy)%pkl->height-1 : ((int)py+wy)%pkl->height;
159
+ if(px>=0 && px<pkl->width && py>=0 && py<pkl->height){
160
+ for(k=0; k<pkl->channel; k++){
161
+ wrk[((i-rect.top)*width+j-rect.left)*pkl->channel+k] =
162
+ PKL_RGB(wrk[((i-rect.top)*width+j-rect.left)*pkl->channel+k] +
163
+ pkl->image[(sy*pkl->width+sx)*pkl->channel+k] * f[wy*2+wx]);
164
+ }
165
+ }else{
166
+ memcpy(&wrk[((i-rect.top)*width+j-rect.left)*pkl->channel], back, pkl->channel);
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
172
+
173
+ free(pkl->image);
174
+ pkl->image = wrk;
175
+ pkl->width = width;
176
+ pkl->height = height;
177
+ return(0);
178
+ }
179
+
180
+ //=============================================================================
181
+ // pkl_rotate_bc
182
+ //=============================================================================
183
+ static int pkl_rotate_bc(PKLImage pkl, float angle, unsigned char *backcolor)
184
+ {
185
+ int width, height;
186
+ PIKL_RECT rect;
187
+ float rad;
188
+ unsigned char *wrk, back[4];
189
+ int i, j, k, px, py, x0, y0;
190
+ double wx, wy, dx, dy, sx, sy;
191
+ double data[PKL_CHANNEL];
192
+
193
+ rad = -angle*M_PI/180;
194
+ get_rect(&rect, pkl->width, pkl->height, rad);
195
+ width = rect.right - rect.left;
196
+ height = rect.bottom - rect.top;
197
+
198
+ wrk = malloc(width * height * pkl->channel);
199
+ if(!wrk) return(1);
200
+ memset(wrk, 0, width*height*pkl->channel);
201
+
202
+ //for(i=0; i<pkl->channel; i++)
203
+ // back[i] = (backcolor>>((pkl->channel-i)*8) & 0xFF);
204
+ memcpy(back, backcolor, pkl->channel);
205
+
206
+ for(i=rect.top; i<rect.bottom; i++){
207
+ for(j=rect.left; j<rect.right; j++){
208
+ memset(&data, 0, sizeof(data));
209
+ sx = cos(rad) * j - sin(rad) * i;
210
+ sy = sin(rad) * j + cos(rad) * i;
211
+ for(py=(int)sy-1; py<=(int)sy+2; py++){
212
+ for(px=(int)sx-1; px<=(int)sx+2; px++){
213
+ dx = fabs(sx-px);
214
+ dy = fabs(sy-py);
215
+ wx = (dx<1) ? (dx-1)*(dx*dx-dx-1) : -(dx-1)*(dx-2)*(dx-2);
216
+ wy = (dy<1) ? (dy-1)*(dy*dy-dy-1) : -(dy-1)*(dy-2)*(dy-2);
217
+ x0 = (px<0 || px>pkl->width -1) ? sx : px;
218
+ y0 = (py<0 || py>pkl->height-1) ? sy : py;
219
+
220
+ if(x0>=0 && x0<pkl->width && y0>=0 && y0<pkl->height){
221
+ for(k=0; k<pkl->channel; k++)
222
+ data[k] += pkl->image[(y0*pkl->width+x0)*pkl->channel+k]*wx*wy;
223
+ }
224
+ }
225
+ }
226
+
227
+ if(sx>=0 && sx<pkl->width && sy>=0 && sy<pkl->height){
228
+ for(k=0; k<pkl->channel; k++)
229
+ wrk[((i-rect.top)*width+j-rect.left)*pkl->channel+k] = PKL_RGB(data[k]);
230
+ }else{
231
+ memcpy(&wrk[((i-rect.top)*width+j-rect.left)*pkl->channel], back, pkl->channel);
232
+ }
233
+ }
234
+ }
235
+
236
+ free(pkl->image);
237
+ pkl->image = wrk;
238
+ pkl->width = width;
239
+ pkl->height = height;
240
+ return(0);
241
+ }
242
+
243
+ ////=============================================================================
244
+ //// pkl_rotate_pa
245
+ ////=============================================================================
246
+ //static int pkl_rotate_pa(PKLImage pkl, float angle, int backcolor)
247
+ //{
248
+ // int width, height;
249
+ // PIKL_RECT rect;
250
+ // float rad;
251
+ // unsigned char *wrk, back[4];
252
+ // int i, j;
253
+ // double zx, zy, power;
254
+ //
255
+ // rad = -angle*M_PI/180;
256
+ // get_rect(&rect, pkl->width, pkl->height, rad);
257
+ // width = rect.right - rect.left;
258
+ // height = rect.bottom - rect.top;
259
+ //
260
+ // wrk = malloc(width * height * pkl->channel);
261
+ // if(!wrk) return(1);
262
+ // memset(wrk, 0, width*height*pkl->channel);
263
+ //
264
+ // for(i=0; i<pkl->channel; i++)
265
+ // back[i] = (backcolor>>((pkl->channel-i)*8) & 0xFF);
266
+ //
267
+ // zx = (double)pkl->width / (double)width;
268
+ // zy = (double)pkl->height / (double)height;
269
+ // //���_�����������ϒl�Z�o�l
270
+ // power= zx*zy + (zx*zy * angle*M_PI/180 * angle*M_PI/180);
271
+ //
272
+ // for(i=rect.top; i<rect.bottom; i++){
273
+ // for(j=rect.left; j<rect.right; j++){
274
+ // double w1, w2, h1, h2;
275
+ // double w1b, w2b, h1b, h2b;
276
+ // double bi, ixg[PKL_CHANNEL] = {0.0, 0.0, 0.0, 0.0};
277
+ // int fsx ,fsy, s, t, k;
278
+ //
279
+ // w1b = modf(cos(rad)*j -sin(rad)*i, &w1);
280
+ // w2b = modf(cos(rad)*(j+1)-sin(rad)*i, &w2);
281
+ // h1b = modf(sin(rad)*j +cos(rad)*i, &h1);
282
+ // h2b = modf(sin(rad)*j+cos(rad)*(i+1), &h2);
283
+ //
284
+ // for(s=(int)w1; s<=(int)w2; s++){
285
+ // for(t=(int)h1; t<=(int)h2; t++){
286
+ // bi = 1.0;
287
+ // if(s == (int)w1) bi*=(1-w1b);
288
+ // if(s == (int)w2) bi*=(w2b);
289
+ // if(t == (int)h1) bi*=(1-h1b);
290
+ // if(t == (int)h2) bi*=(h2b);
291
+ // fsx = (s < 0) ? 0 : (s > pkl->width -1) ? pkl->width -1 : s;
292
+ // fsy = (t < 0) ? 0 : (t > pkl->height-1) ? pkl->height-1 : t;
293
+ // for(k=0; k<pkl->channel; k++)
294
+ // ixg[k] += pkl->image[(fsy*pkl->width+fsx)*pkl->channel+k] * bi;
295
+ // }
296
+ // }
297
+ //
298
+ // if((int)w1>=0 && (int)w1<pkl->width && (int)h1>=0 && (int)h1<pkl->height){
299
+ // for(k=0; k<pkl->channel; k++)
300
+ // wrk[((i-rect.top)*width+j-rect.left)*pkl->channel+k] = PKL_RGB(ixg[k]/power);
301
+ // }else{
302
+ // memcpy(&wrk[((i-rect.top)*width+j-rect.left)*pkl->channel], back, pkl->channel);
303
+ // }
304
+ //
305
+ // }
306
+ // }
307
+ // free(pkl->image);
308
+ // pkl->image = wrk;
309
+ // pkl->width = width;
310
+ // pkl->height = height;
311
+ // return(0);
312
+ //}
@@ -0,0 +1,19 @@
1
+ #ifndef _LIB_PIKL_ROTATE2_
2
+ #define _LIB_PIKL_ROTATE2_
3
+
4
+ #include <stdio.h>
5
+ #include <stdlib.h>
6
+ #include <string.h>
7
+ #include <math.h>
8
+ #include "pikl.h"
9
+ #include "pikl_private.h"
10
+
11
+ typedef struct{
12
+ int left;
13
+ int top;
14
+ int right;
15
+ int bottom;
16
+ } PIKL_RECT;
17
+
18
+ #endif
19
+
data/lib/pikl/ext.rb CHANGED
@@ -13,6 +13,7 @@ module Pikl
13
13
  typealias("PKL_FORMAT", "int")
14
14
  typealias("PKL_ANGLE", "int")
15
15
  typealias("PKL_SAMPLE", "int")
16
+ typealias("uchar", "unsigned char")
16
17
 
17
18
  extern "PKLImage *pkl_open(char*)"
18
19
  extern "void pkl_close(PKLImage*)"
@@ -22,7 +23,8 @@ module Pikl
22
23
  extern "int pkl_width(PKLImage *)"
23
24
  extern "int pkl_height(PKLImage *)"
24
25
  extern "int pkl_trim(PKLImage *, int, int, int, int)"
25
- extern "int pkl_rotate(PKLImage *, PKL_ANGLE)"
26
+ extern "int pkl_rotate(PKLImage*, PKL_ANGLE)"
27
+ extern "int pkl_rotate2(PKLImage*, float, PKL_SAMPLE, uchar, uchar, uchar, uchar)"
26
28
  extern "int pkl_resize(PKLImage*, int, int, PKL_SAMPLE)"
27
29
  extern "int pkl_unsharp(PKLImage *, int, double)"
28
30
  extern "int pkl_contrast(PKLImage *, int)"
data/lib/pikl/image.rb CHANGED
@@ -70,11 +70,46 @@ module Pikl
70
70
  end
71
71
  end
72
72
 
73
- def rotate(angle)
74
- validate_rotate(angle)
75
- Ext.pkl_rotate(@pkl_image, ROTATE_ANGLE[angle.to_i])
73
+ def rotate(angle, backcolor = "#FFFFFF", sample = :bilinear)
74
+
75
+ if ROTATE_ANGLE.has_key?(angle.to_i)
76
+ validate_rotate(angle)
77
+ Ext.pkl_rotate(@pkl_image, ROTATE_ANGLE[angle.to_i])
78
+ else
79
+ ci = color_int(backcolor)
80
+ Ext.pkl_rotate2(@pkl_image, angle.to_f, SAMPLES[sample.to_sym], ci[0], ci[1], ci[2], ci[3])
81
+ end
76
82
  self
77
83
  end
84
+
85
+ def fit(width, height, mode = :inner)
86
+ error("invalid mode parameter. # => #{mode}") unless [:inner, :outer].include?(mode)
87
+ self.send("fit_#{mode.to_s}", width, height)
88
+ end
89
+
90
+ def fit_inner(width, height)
91
+ to_w, to_h = ((width.to_f / self.width.to_f) < (height.to_f / self.height.to_f)) ? [width, :auto] : [:auto, height]
92
+ resize(to_w,to_h)
93
+ end
94
+
95
+ def fit_outer(width, height)
96
+ to_w, to_h = ((width.to_f / self.width.to_f) > (height.to_f / self.height.to_f)) ? [width, :auto] : [:auto, height]
97
+ resize(to_w,to_h)
98
+ end
99
+
100
+ def color_int(colorstr)
101
+ validate_color(colorstr)
102
+ cs = colorstr.gsub(/^#/,"")
103
+ color = []
104
+ 0.step(6,2) do |i|
105
+ color << ( cs[i,2].to_s.empty? ? "FF" : cs[i,2] )
106
+ end
107
+ color.map!{|c| c.hex}
108
+ end
109
+
110
+ def validate_color(v)
111
+ error("invalid color parameter. # => #{v}") unless /^#[a-f|A-F|0-9]+$/ =~ v.to_s
112
+ end
78
113
 
79
114
  def resize(width, height, sample = :pixcel_averate)
80
115
  validate_auto(width,height)
data/lib/pikl/pikl.dll CHANGED
Binary file
data/lib/pikl/version.rb CHANGED
@@ -2,7 +2,7 @@ module Pikl #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 3
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -27,6 +27,61 @@ class TestPiklImage < Test::Unit::TestCase
27
27
 
28
28
  end
29
29
 
30
+ def test_fit_inner
31
+ #sample.jpg must be 120x160.
32
+ img = Pikl::Image.open(SAMPLE_IMAGE)
33
+ img.fit(60,81)
34
+ assert_equal(60, img.width)
35
+ assert_equal(80, img.height)
36
+ img.close()
37
+
38
+ img = Pikl::Image.open(SAMPLE_IMAGE)
39
+ img.fit(61,80)
40
+ assert_equal(60, img.width)
41
+ assert_equal(80, img.height)
42
+ img.close()
43
+
44
+ img = Pikl::Image.open(SAMPLE_IMAGE)
45
+ img.fit(240,321)
46
+ assert_equal(240, img.width)
47
+ assert_equal(320, img.height)
48
+ img.close()
49
+
50
+ img = Pikl::Image.open(SAMPLE_IMAGE)
51
+ img.fit(361,480)
52
+ assert_equal(360, img.width)
53
+ assert_equal(480, img.height)
54
+ img.close()
55
+ end
56
+
57
+ def test_fit_outer
58
+ #sample.jpg must be 120x160.
59
+ img = Pikl::Image.open(SAMPLE_IMAGE)
60
+ img.fit(360,479,:outer)
61
+ assert_equal(360, img.width)
62
+ assert_equal(480, img.height)
63
+ img.close()
64
+
65
+ img = Pikl::Image.open(SAMPLE_IMAGE)
66
+ img.fit(359,480,:outer)
67
+ assert_equal(360, img.width)
68
+ assert_equal(480, img.height)
69
+ img.close()
70
+
71
+ img = Pikl::Image.open(SAMPLE_IMAGE)
72
+ img.fit(119,160,:outer)
73
+ assert_equal(120, img.width)
74
+ assert_equal(160, img.height)
75
+ img.close()
76
+
77
+ img = Pikl::Image.open(SAMPLE_IMAGE)
78
+ img.fit(120,159,:outer)
79
+ assert_equal(120, img.width)
80
+ assert_equal(160, img.height)
81
+ img.close()
82
+ end
83
+
84
+
30
85
  def test_trim
31
86
  Pikl::Image.open(SAMPLE_IMAGE) do |img|
32
87
 
@@ -119,7 +174,13 @@ class TestPiklImage < Test::Unit::TestCase
119
174
  assert_equal(SAMPLE_IMAGE_H,imgout.width)
120
175
  assert_equal(SAMPLE_IMAGE_W,imgout.height)
121
176
  end
122
-
177
+
178
+ img.rotate(285,"#000000")
179
+ img.save(SAMPLE_OUTPUT)
180
+ Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
181
+ assert_equal(157,imgout.width)
182
+ assert_equal(185,imgout.height)
183
+ end
123
184
  end
124
185
  end
125
186
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pikl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: x86-mswin32
6
6
  authors:
7
7
  - Ryota Maruko
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-24 00:00:00 +09:00
12
+ date: 2008-06-22 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,7 +30,6 @@ files:
30
30
  - License.txt
31
31
  - Manifest.txt
32
32
  - README.txt
33
- - Rakefile
34
33
  - config/hoe.rb
35
34
  - config/requirements.rb
36
35
  - ext/pikl/pikl.h
@@ -49,6 +48,8 @@ files:
49
48
  - ext/pikl/pikl_resize.h
50
49
  - ext/pikl/pikl_rotate.c
51
50
  - ext/pikl/pikl_rotate.h
51
+ - ext/pikl/pikl_rotate2.c
52
+ - ext/pikl/pikl_rotate2.h
52
53
  - ext/pikl/pikl_trim.c
53
54
  - ext/pikl/pikl_trim.h
54
55
  - lib/pikl.rb
data/Rakefile DELETED
@@ -1,4 +0,0 @@
1
- PACKAGE_PLATFORM = (ARGV[0] =~ /mswin32$/) ? 'mswin32' : RUBY_PLATFORM
2
- require 'config/requirements'
3
- require 'config/hoe' # setup Hoe + all gem configuration
4
- Dir['tasks/**/*.rake'].each { |rake| load rake }