psd_native 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/ext/psd_native/image_mode_cmyk.c +5 -13
- data/ext/psd_native/image_mode_cmyk.h +2 -2
- data/ext/psd_native/image_mode_greyscale.c +27 -0
- data/ext/psd_native/image_mode_greyscale.h +6 -0
- data/ext/psd_native/image_mode_rgb.h +2 -2
- data/ext/psd_native/psd_native_ext.c +4 -0
- data/ext/psd_native/psd_native_ext.h +1 -0
- data/lib/psd_native/version.rb +1 -1
- data/lib/psd_native.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bc8f941614e4d6e7a4f3262d95a6d46b81a226f
|
4
|
+
data.tar.gz: b8085ead0d1a7977ba66806109c31b8e57fa836c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 039e4149c2182f105ab85cd8a67442e099edb4bc48f230aa7f9e54021439bdafbef60f7b9d848c074ec0fd2c98b5bab9732c4de60199ce34576ac445ce584382
|
7
|
+
data.tar.gz: a1910ddae6d3cb053e7c4acafa12cff2125427e8f43832ffb90b79fc34c576960641e3b65f84524aa1996da7b3716eacb0e6e9c90211c791c02dee9907ca22b5
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'rspec/core/rake_task'
|
|
4
4
|
|
5
5
|
Rake::ExtensionTask.new('psd_native') do |ext|
|
6
6
|
ext.lib_dir = File.join('lib', 'psd_native')
|
7
|
-
ext.config_options = '--with-cflags="-std=c99"'
|
7
|
+
ext.config_options = '--with-cflags="-std=c99 -openmp"'
|
8
8
|
end
|
9
9
|
|
10
10
|
Rake::Task['spec'].prerequisites << :compile
|
@@ -16,19 +16,11 @@ VALUE psd_native_combine_cmyk_channel(VALUE self) {
|
|
16
16
|
|
17
17
|
// Loop through every pixel in the image
|
18
18
|
for (i = 0; i < num_pixels; i += pixel_step) {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
k = channel_data[i + channel_length * 4];
|
25
|
-
} else {
|
26
|
-
a = 255;
|
27
|
-
c = channel_data[i];
|
28
|
-
m = channel_data[i + channel_length];
|
29
|
-
y = channel_data[i + channel_length * 2];
|
30
|
-
k = channel_data[i + channel_length * 3];
|
31
|
-
}
|
19
|
+
c = channel_data[i];
|
20
|
+
m = channel_data[i + channel_length];
|
21
|
+
y = channel_data[i + channel_length * 2];
|
22
|
+
k = channel_data[i + channel_length * 3];
|
23
|
+
a = (channel_count == 5 ? channel_data[i + channel_length * 4] : 255);
|
32
24
|
|
33
25
|
rgb = psd_native_cmyk_to_rgb(
|
34
26
|
self,
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#include "psd_native_ext.h"
|
2
|
+
|
3
|
+
VALUE psd_native_combine_greyscale_channel(VALUE self) {
|
4
|
+
psd_logger("debug", "Beginning greyscale processing");
|
5
|
+
|
6
|
+
uint32_t channel_count = FIX2UINT(rb_funcall(self, rb_intern("channels"), 0));
|
7
|
+
uint32_t num_pixels = FIX2UINT(rb_iv_get(self, "@num_pixels"));
|
8
|
+
uint32_t pixel_step = FIX2UINT(rb_funcall(self, rb_intern("pixel_step"), 0));
|
9
|
+
|
10
|
+
VALUE* channel_data = RARRAY_PTR(rb_iv_get(self, "@channel_data"));
|
11
|
+
uint32_t channel_length = FIX2UINT(rb_iv_get(self, "@channel_length"));
|
12
|
+
|
13
|
+
uint32_t i, alpha, grey;
|
14
|
+
for (i = 0; i < num_pixels; i += pixel_step) {
|
15
|
+
if (channel_count == 2) {
|
16
|
+
grey = FIX2UINT(channel_data[i]);
|
17
|
+
alpha = FIX2UINT(channel_data[channel_length + i]);
|
18
|
+
|
19
|
+
rb_ary_push(rb_iv_get(self, "@pixel_data"), INT2FIX(BUILD_PIXEL(grey, grey, grey, alpha)));
|
20
|
+
} else {
|
21
|
+
grey = FIX2UINT(channel_data[i]);
|
22
|
+
rb_ary_push(rb_iv_get(self, "@pixel_data"), INT2FIX(BUILD_PIXEL(grey, grey, grey, 255)));
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
return Qnil;
|
27
|
+
}
|
@@ -12,6 +12,10 @@ void Init_psd_native() {
|
|
12
12
|
VALUE ImageMode_CMYK = rb_define_module_under(ImageMode, "CMYK");
|
13
13
|
rb_define_private_method(ImageMode_CMYK, "combine_cmyk_channel", psd_native_combine_cmyk_channel, 0);
|
14
14
|
|
15
|
+
// Greyscale Processing
|
16
|
+
VALUE ImageMode_Greyscale = rb_define_module_under(ImageMode, "Greyscale");
|
17
|
+
rb_define_private_method(ImageMode_Greyscale, "combine_greyscale_channel", psd_native_combine_greyscale_channel, 0);
|
18
|
+
|
15
19
|
// RLE decoding
|
16
20
|
VALUE ImageFormat = rb_define_module_under(PSDNative, "ImageFormat");
|
17
21
|
VALUE RLE = rb_define_module_under(ImageFormat, "RLE");
|
data/lib/psd_native/version.rb
CHANGED
data/lib/psd_native.rb
CHANGED
@@ -4,6 +4,7 @@ module PSDNative
|
|
4
4
|
def self.included(base)
|
5
5
|
base::Image.send(:include, PSDNative::ImageMode::RGB)
|
6
6
|
base::Image.send(:include, PSDNative::ImageMode::CMYK)
|
7
|
+
base::Image.send(:include, PSDNative::ImageMode::Greyscale)
|
7
8
|
base::Image.send(:include, PSDNative::ImageFormat::RLE)
|
8
9
|
end
|
9
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psd_native
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan LeFevre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: psd
|
@@ -142,6 +142,8 @@ files:
|
|
142
142
|
- ext/psd_native/extconf.rb
|
143
143
|
- ext/psd_native/image_mode_cmyk.c
|
144
144
|
- ext/psd_native/image_mode_cmyk.h
|
145
|
+
- ext/psd_native/image_mode_greyscale.c
|
146
|
+
- ext/psd_native/image_mode_greyscale.h
|
145
147
|
- ext/psd_native/image_mode_rgb.c
|
146
148
|
- ext/psd_native/image_mode_rgb.h
|
147
149
|
- ext/psd_native/psd_native_ext.c
|