rfreeimage 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3037632a027335cbbed19c60769235c56713f77d
4
- data.tar.gz: 1d1994a1051e7b32cd16e7277a61a3e1829a286f
3
+ metadata.gz: f1966079f9e10d783543577040e00a934b11dfd7
4
+ data.tar.gz: 5662dfe703c70495676d945bdaa24e0b92fef816
5
5
  SHA512:
6
- metadata.gz: 1fc05e814346fa10af49cc04ad96b4cc31958a3bb289a0ccd50839817c1eb0339b52001db7232db0d861aae828e3d01289a7f2cf2320e4fd9690da72537bdc8f
7
- data.tar.gz: d5af3bb4a6f892e2afeacaefdcf0f1d9a61685c9db92f7c4f78905d00a0cce5ca7213a32c15d3b0e4e854783eb9fc0cbb7f8f2bfd84bfd715a634081ec6f9a70
6
+ metadata.gz: 82c912070bb034f7ee8ee955ab13945b2018f57cc47c8f8bf77a3d239d8c80fa82dadc8cdd2e32ccee20ecc759a9170a1fb8379525398d3e4759cbd1b520ed01
7
+ data.tar.gz: bda3b9a43fc0418ce7de317c151927cb91a40db8895275520377daf1efc6ccd4d02132c7f9eef58ff8259a5e12706cdda40806316a003e124490a917e8dd55f8
@@ -417,19 +417,23 @@ VALUE Image_clone(VALUE self)
417
417
  return rfi_get_image(nh);
418
418
  }
419
419
 
420
- VALUE Image_resize(VALUE self, VALUE dst_width, VALUE dst_height)
420
+ VALUE Image_rescale(VALUE self, VALUE dst_width, VALUE dst_height, VALUE filter_type)
421
421
  {
422
422
  struct native_image *img;
423
423
  FIBITMAP *nh;
424
424
  int w = NUM2INT(dst_width);
425
425
  int h = NUM2INT(dst_height);
426
+ int f = NUM2INT(filter_type);
426
427
  if (w <= 0 || h <= 0)
427
428
  rb_raise(rb_eArgError, "Invalid size");
428
429
 
430
+ if (f < FILTER_BOX || f > FILTER_LANCZOS3)
431
+ rb_raise(rb_eArgError, "Invalid image filter type");
432
+
429
433
  Data_Get_Struct(self, struct native_image, img);
430
434
  RFI_CHECK_IMG(img);
431
435
 
432
- nh = FreeImage_Rescale(img->handle, w, h, FILTER_CATMULLROM);
436
+ nh = FreeImage_Rescale(img->handle, w, h, f);
433
437
  return rfi_get_image(nh);
434
438
  }
435
439
 
@@ -630,7 +634,7 @@ void Init_rfreeimage(void)
630
634
 
631
635
  rb_define_method(Class_Image, "to_bpp", Image_to_bpp, 1);
632
636
  rb_define_method(Class_Image, "rotate", Image_rotate, 1);
633
- rb_define_method(Class_Image, "resize", Image_resize, 2);
637
+ rb_define_method(Class_Image, "rescale", Image_rescale, 3);
634
638
  rb_define_method(Class_Image, "crop", Image_crop, 4);
635
639
  rb_define_method(Class_Image, "to_blob", Image_to_blob, 1);
636
640
 
@@ -14,6 +14,14 @@ module RFreeImage
14
14
  BLACK = 0xff000000
15
15
  GRAY = 0xffa9a9a9
16
16
  end
17
+ module Filter
18
+ FILTER_BOX = 0
19
+ FILTER_BICUBIC = 1
20
+ FILTER_BILINEAR = 2
21
+ FILTER_BSPLINE = 3
22
+ FILTER_CATMULLROM = 4
23
+ FILTER_LANCZOS3 = 5
24
+ end
17
25
  class Image
18
26
  def bytes
19
27
  @bytes ||= read_bytes
@@ -42,6 +50,10 @@ module RFreeImage
42
50
  to_bpp 32
43
51
  end
44
52
 
53
+ def resize(width, height, filter = Filter::FILTER_CATMULLROM)
54
+ return self.rescale(width, height, filter)
55
+ end
56
+
45
57
 
46
58
  alias_method :write, :save
47
59
  alias_method :columns, :cols
@@ -1,3 +1,3 @@
1
1
  module RFreeImage
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfreeimage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuheng Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler