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 +4 -4
- data/ext/rfreeimage/rfi_main.c +7 -3
- data/lib/rfreeimage/image.rb +12 -0
- data/lib/rfreeimage/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1966079f9e10d783543577040e00a934b11dfd7
|
4
|
+
data.tar.gz: 5662dfe703c70495676d945bdaa24e0b92fef816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82c912070bb034f7ee8ee955ab13945b2018f57cc47c8f8bf77a3d239d8c80fa82dadc8cdd2e32ccee20ecc759a9170a1fb8379525398d3e4759cbd1b520ed01
|
7
|
+
data.tar.gz: bda3b9a43fc0418ce7de317c151927cb91a40db8895275520377daf1efc6ccd4d02132c7f9eef58ff8259a5e12706cdda40806316a003e124490a917e8dd55f8
|
data/ext/rfreeimage/rfi_main.c
CHANGED
@@ -417,19 +417,23 @@ VALUE Image_clone(VALUE self)
|
|
417
417
|
return rfi_get_image(nh);
|
418
418
|
}
|
419
419
|
|
420
|
-
VALUE
|
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,
|
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, "
|
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
|
|
data/lib/rfreeimage/image.rb
CHANGED
@@ -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
|
data/lib/rfreeimage/version.rb
CHANGED
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.
|
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
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|