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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a097861634857452e319eac2dc9b273f5152995
4
- data.tar.gz: cdaa91f6470f0403cf4c551fbc6d7bae936604e7
3
+ metadata.gz: 4bc8f941614e4d6e7a4f3262d95a6d46b81a226f
4
+ data.tar.gz: b8085ead0d1a7977ba66806109c31b8e57fa836c
5
5
  SHA512:
6
- metadata.gz: 9aeb904cc861e840673e1ce5e5a47d55e1dbcf50a3af58d05ae827fef0a7f5681489fe234e100644c1aa33a39dd208f5e2c6b1627f85f5179882c1ea5296c242
7
- data.tar.gz: 05ad35fb96d4b7a85a113e2927ee948fb33e75fa1d5c9699f93a1a8aeecf518c06a575ee922aa2ea17c88d2826504b5d2eeaf8710242c0b834e24e6347205d3b
6
+ metadata.gz: 039e4149c2182f105ab85cd8a67442e099edb4bc48f230aa7f9e54021439bdafbef60f7b9d848c074ec0fd2c98b5bab9732c4de60199ce34576ac445ce584382
7
+ data.tar.gz: a1910ddae6d3cb053e7c4acafa12cff2125427e8f43832ffb90b79fc34c576960641e3b65f84524aa1996da7b3716eacb0e6e9c90211c791c02dee9907ca22b5
data/README.md CHANGED
@@ -8,6 +8,7 @@ Currently, PSDNative replaces these sections of PSD.rb with native code:
8
8
 
9
9
  * RGB processing
10
10
  * CMYK processing
11
+ * Greyscale processing
11
12
  * RLE decoding
12
13
  * Some color conversions
13
14
 
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
- if (channel_count == 5) {
20
- a = channel_data[i];
21
- c = channel_data[i + channel_length];
22
- m = channel_data[i + channel_length * 2];
23
- y = channel_data[i + channel_length * 3];
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,
@@ -1,5 +1,5 @@
1
- #ifndef PSD_NATIVE_CMYK
2
- #define PSD_NATIVE_CMYK
1
+ #ifndef PSD_NATIVE_IMAGE_MODE_CMYK
2
+ #define PSD_NATIVE_IMAGE_MODE_CMYK
3
3
 
4
4
  VALUE psd_native_combine_cmyk_channel(VALUE self);
5
5
 
@@ -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
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef PSD_NATIVE_IMAGE_MODE_GREYSCALE
2
+ #define PSD_NATIVE_IMAGE_MODE_GREYSCALE
3
+
4
+ VALUE psd_native_combine_greyscale_channel(VALUE self);
5
+
6
+ #endif
@@ -1,5 +1,5 @@
1
- #ifndef PSD_NATIVE_RGB
2
- #define PSD_NATIVE_RGB
1
+ #ifndef PSD_NATIVE_IMAGE_MODE_RGB
2
+ #define PSD_NATIVE_IMAGE_MODE_RGB
3
3
 
4
4
  VALUE psd_native_combine_rgb_channel(VALUE self);
5
5
 
@@ -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");
@@ -13,6 +13,7 @@ typedef uint32_t PIXEL;
13
13
  // Our native mixins
14
14
  #include "image_mode_rgb.h"
15
15
  #include "image_mode_cmyk.h"
16
+ #include "image_mode_greyscale.h"
16
17
  #include "rle_decoding.h"
17
18
  #include "color.h"
18
19
 
@@ -1,3 +1,3 @@
1
1
  module PSDNative
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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.0
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-09-23 00:00:00.000000000 Z
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