oily_png 1.2.0 → 1.2.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: 8ac04ee8bba389a3335e3c2bab7d541669e007ca
4
- data.tar.gz: 82a58ceea811af07716f47806b6e3470ade19016
3
+ metadata.gz: 91d031f0616d1aab2345f42cb9823d8e2d970e6f
4
+ data.tar.gz: a3b0af56b18138df6252ae227e8f78684ca7c0c7
5
5
  SHA512:
6
- metadata.gz: 3758ec87e787a7990bccb674241ef46eb4678226bfb745e08926c25227bc3d5254faaf7502b2ec067e3ba9052770cdcca8272f01abc2d96aa499474c91fa388e
7
- data.tar.gz: 6468851a2871e1309457b51288fe8b33f35f52296f2a528d10574fc8758f01ae7b91c2ab685157b557e603014c89301a2c6351d5c1950fedc4f0adf9827dc60c
6
+ metadata.gz: 665227b2e51072eba7b41055c5e8598daea2710bf4d7cdac3086bc6849a44d4c56e4285c89d832ae5f65493637ed2bb438ca3c5fc105453663b76c9a773e9a64
7
+ data.tar.gz: 6a58cdb43eae6eeca6faee9f47ae5354a64c55fecf4bce8fcdbcd133f4022c1e9dd5b62a7a9c41ff12a5cddd3dc9fb0767ae5129b1ca9d3146bd317cfaffb261
@@ -1,16 +1,15 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  script: bundle exec rake
4
+
3
5
  rvm:
4
- - 1.8.7
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1.1
8
- - ree
9
- - ruby-head
10
- - rbx-18mode
11
- - rbx-19mode
6
+ - "2.0"
7
+ - "2.1"
8
+ - "2.2"
9
+ - ruby-head
10
+ - rbx-19mode
11
+
12
12
  matrix:
13
13
  allow_failures:
14
- - rvm: rbx-18mode
15
- - rvm: rbx-19mode
16
- - rvm: ruby-head
14
+ - rvm: rbx-19mode
15
+ - rvm: ruby-head
@@ -11,7 +11,7 @@ void Init_oily_png() {
11
11
 
12
12
  // Setup decoding module
13
13
  VALUE OilyPNG_PNGDecoding = rb_define_module_under(OilyPNG, "PNGDecoding");
14
- rb_define_method(OilyPNG_PNGDecoding, "decode_png_image_pass", oily_png_decode_png_image_pass, 6);
14
+ rb_define_method(OilyPNG_PNGDecoding, "decode_png_image_pass", oily_png_decode_png_image_pass, 7);
15
15
 
16
16
  // Setup encoding module
17
17
  VALUE OilyPNG_PNGEncoding = rb_define_module_under(OilyPNG, "PNGEncoding");
@@ -98,9 +98,9 @@ void oily_png_decode_scanline_grayscale_1bit(VALUE pixels, BYTE* bytes, long sta
98
98
  long x;
99
99
  for (x = 0; x < width; x++) {
100
100
  ADD_PIXEL_FROM_RGBA(pixels,
101
- oily_png_resample_1bit_element(bytes, start, x),
102
- oily_png_resample_1bit_element(bytes, start, x),
103
- oily_png_resample_1bit_element(bytes, start, x),
101
+ oily_png_resample_1bit_element(bytes, start, x),
102
+ oily_png_resample_1bit_element(bytes, start, x),
103
+ oily_png_resample_1bit_element(bytes, start, x),
104
104
  0xff);
105
105
  }
106
106
  }
@@ -110,9 +110,9 @@ void oily_png_decode_scanline_grayscale_2bit(VALUE pixels, BYTE* bytes, long sta
110
110
  long x;
111
111
  for (x = 0; x < width; x++) {
112
112
  ADD_PIXEL_FROM_RGBA(pixels,
113
- oily_png_resample_2bit_element(bytes, start, x),
114
- oily_png_resample_2bit_element(bytes, start, x),
115
- oily_png_resample_2bit_element(bytes, start, x),
113
+ oily_png_resample_2bit_element(bytes, start, x),
114
+ oily_png_resample_2bit_element(bytes, start, x),
115
+ oily_png_resample_2bit_element(bytes, start, x),
116
116
  0xff);
117
117
  }
118
118
  }
@@ -122,9 +122,9 @@ void oily_png_decode_scanline_grayscale_4bit(VALUE pixels, BYTE* bytes, long sta
122
122
  long x;
123
123
  for (x = 0; x < width; x++) {
124
124
  ADD_PIXEL_FROM_RGBA(pixels,
125
- oily_png_resample_4bit_element(bytes, start, x),
126
- oily_png_resample_4bit_element(bytes, start, x),
127
- oily_png_resample_4bit_element(bytes, start, x),
125
+ oily_png_resample_4bit_element(bytes, start, x),
126
+ oily_png_resample_4bit_element(bytes, start, x),
127
+ oily_png_resample_4bit_element(bytes, start, x),
128
128
  0xff);
129
129
  }
130
130
  }
@@ -134,9 +134,9 @@ void oily_png_decode_scanline_grayscale_8bit(VALUE pixels, BYTE* bytes, long sta
134
134
  long x;
135
135
  for (x = 0; x < width; x++) {
136
136
  ADD_PIXEL_FROM_RGBA(pixels,
137
- bytes[start + 1 + x],
138
- bytes[start + 1 + x],
139
- bytes[start + 1 + x],
137
+ bytes[start + 1 + x],
138
+ bytes[start + 1 + x],
139
+ bytes[start + 1 + x],
140
140
  0xff);
141
141
  }
142
142
  }
@@ -146,9 +146,9 @@ void oily_png_decode_scanline_grayscale_16bit(VALUE pixels, BYTE* bytes, long st
146
146
  long x;
147
147
  for (x = 0; x < width; x++) {
148
148
  ADD_PIXEL_FROM_RGBA(pixels,
149
- bytes[start + 1 + (x * 2)],
150
- bytes[start + 1 + (x * 2)],
151
- bytes[start + 1 + (x * 2)],
149
+ bytes[start + 1 + (x * 2)],
150
+ bytes[start + 1 + (x * 2)],
151
+ bytes[start + 1 + (x * 2)],
152
152
  0xff);
153
153
  }
154
154
  }
@@ -158,9 +158,9 @@ void oily_png_decode_scanline_grayscale_alpha_8bit(VALUE pixels, BYTE* bytes, lo
158
158
  long x;
159
159
  for (x = 0; x < width; x++) {
160
160
  ADD_PIXEL_FROM_RGBA(pixels,
161
- bytes[start + 1 + (x * 2) + 0],
162
- bytes[start + 1 + (x * 2) + 0],
163
- bytes[start + 1 + (x * 2) + 0],
161
+ bytes[start + 1 + (x * 2) + 0],
162
+ bytes[start + 1 + (x * 2) + 0],
163
+ bytes[start + 1 + (x * 2) + 0],
164
164
  bytes[start + 1 + (x * 2) + 1]);
165
165
  }
166
166
  }
@@ -170,9 +170,9 @@ void oily_png_decode_scanline_grayscale_alpha_16bit(VALUE pixels, BYTE* bytes, l
170
170
  long x;
171
171
  for (x = 0; x < width; x++) {
172
172
  ADD_PIXEL_FROM_RGBA(pixels,
173
- bytes[start + 1 + (x * 4) + 0],
174
- bytes[start + 1 + (x * 4) + 0],
175
- bytes[start + 1 + (x * 4) + 0],
173
+ bytes[start + 1 + (x * 4) + 0],
174
+ bytes[start + 1 + (x * 4) + 0],
175
+ bytes[start + 1 + (x * 4) + 0],
176
176
  bytes[start + 1 + (x * 4) + 2]);
177
177
  }
178
178
  }
@@ -210,9 +210,9 @@ void oily_png_decode_scanline_truecolor_8bit(VALUE pixels, BYTE* bytes, long sta
210
210
  long x;
211
211
  for (x = 0; x < width; x++) {
212
212
  ADD_PIXEL_FROM_RGBA(pixels,
213
- bytes[start + 1 + (x * 3) + 0],
214
- bytes[start + 1 + (x * 3) + 1],
215
- bytes[start + 1 + (x * 3) + 2],
213
+ bytes[start + 1 + (x * 3) + 0],
214
+ bytes[start + 1 + (x * 3) + 1],
215
+ bytes[start + 1 + (x * 3) + 2],
216
216
  0xff);
217
217
  }
218
218
  }
@@ -222,9 +222,9 @@ void oily_png_decode_scanline_truecolor_16bit(VALUE pixels, BYTE* bytes, long st
222
222
  long x;
223
223
  for (x = 0; x < width; x++) {
224
224
  ADD_PIXEL_FROM_RGBA(pixels,
225
- bytes[start + 1 + (x * 6) + 0],
226
- bytes[start + 1 + (x * 6) + 2],
227
- bytes[start + 1 + (x * 6) + 4],
225
+ bytes[start + 1 + (x * 6) + 0],
226
+ bytes[start + 1 + (x * 6) + 2],
227
+ bytes[start + 1 + (x * 6) + 4],
228
228
  0xff);
229
229
  }
230
230
  }
@@ -234,10 +234,10 @@ void oily_png_decode_scanline_truecolor_alpha_8bit(VALUE pixels, BYTE* bytes, lo
234
234
  long x;
235
235
  for (x = 0; x < width; x++) {
236
236
  ADD_PIXEL_FROM_RGBA(pixels,
237
- bytes[start + 1 + (x * 4) + 0],
238
- bytes[start + 1 + (x * 4) + 1],
239
- bytes[start + 1 + (x * 4) + 2],
240
- bytes[start + 1 + (x * 4) + 3]);
237
+ bytes[start + 1 + (x * 4) + 0],
238
+ bytes[start + 1 + (x * 4) + 1],
239
+ bytes[start + 1 + (x * 4) + 2],
240
+ bytes[start + 1 + (x * 4) + 3]);
241
241
  }
242
242
  }
243
243
 
@@ -245,10 +245,10 @@ void oily_png_decode_scanline_truecolor_alpha_16bit(VALUE pixels, BYTE* bytes, l
245
245
  UNUSED_PARAMETER(decoding_palette);
246
246
  long x;
247
247
  for (x = 0; x < width; x++) {
248
- ADD_PIXEL_FROM_RGBA(pixels,
249
- bytes[start + 1 + (x * 8) + 0],
250
- bytes[start + 1 + (x * 8) + 2],
251
- bytes[start + 1 + (x * 8) + 4],
248
+ ADD_PIXEL_FROM_RGBA(pixels,
249
+ bytes[start + 1 + (x * 8) + 0],
250
+ bytes[start + 1 + (x * 8) + 2],
251
+ bytes[start + 1 + (x * 8) + 4],
252
252
  bytes[start + 1 + (x * 8) + 6]);
253
253
  }
254
254
  }
@@ -271,7 +271,7 @@ scanline_decoder_func oily_png_decode_scanline_func(int color_mode, int bit_dept
271
271
  case 16: return &oily_png_decode_scanline_truecolor_16bit;
272
272
  default: return NULL;
273
273
  }
274
-
274
+
275
275
  case OILY_PNG_COLOR_INDEXED:
276
276
  switch (bit_depth) {
277
277
  case 1: return &oily_png_decode_scanline_indexed_1bit;
@@ -280,7 +280,7 @@ scanline_decoder_func oily_png_decode_scanline_func(int color_mode, int bit_dept
280
280
  case 8: return &oily_png_decode_scanline_indexed_8bit;
281
281
  default: return NULL;
282
282
  }
283
-
283
+
284
284
  case OILY_PNG_COLOR_GRAYSCALE_ALPHA:
285
285
  switch (bit_depth) {
286
286
  case 8: return &oily_png_decode_scanline_grayscale_alpha_8bit;
@@ -294,7 +294,7 @@ scanline_decoder_func oily_png_decode_scanline_func(int color_mode, int bit_dept
294
294
  case 16: return &oily_png_decode_scanline_truecolor_alpha_16bit;
295
295
  default: return NULL;
296
296
  }
297
-
297
+
298
298
  default: return NULL;
299
299
  }
300
300
  }
@@ -303,29 +303,28 @@ scanline_decoder_func oily_png_decode_scanline_func(int color_mode, int bit_dept
303
303
  // DECODING AN IMAGE PASS
304
304
  /////////////////////////////////////////////////////////////////////
305
305
 
306
- VALUE oily_png_decode_palette(VALUE self) {
307
- VALUE palette_instance = rb_funcall(self, rb_intern("decoding_palette"), 0);
308
- if (palette_instance != Qnil) {
309
- VALUE decoding_map = rb_iv_get(palette_instance, "@decoding_map");
310
- if (rb_funcall(decoding_map, rb_intern("kind_of?"), 1, rb_cArray) == Qtrue) {
306
+ VALUE oily_png_decode_palette(VALUE decoding_palette) {
307
+ if (decoding_palette != Qnil) {
308
+ VALUE decoding_map = rb_iv_get(decoding_palette, "@decoding_map");
309
+ if (rb_funcall(decoding_map, rb_intern("kind_of?"), 1, rb_cArray) == Qtrue) {
311
310
  return decoding_map;
312
311
  }
313
312
  }
314
- rb_raise(rb_eRuntimeError, "Could not retrieve a decoding palette for this image!");
313
+ rb_raise(rb_eRuntimeError, "Could not retrieve a decoding palette for this image!");
315
314
  return Qnil;
316
315
  }
317
316
 
318
317
 
319
- VALUE oily_png_decode_png_image_pass(VALUE self, VALUE stream, VALUE width, VALUE height, VALUE color_mode, VALUE depth, VALUE start_pos) {
320
-
318
+ VALUE oily_png_decode_png_image_pass(VALUE self, VALUE stream, VALUE width, VALUE height, VALUE color_mode, VALUE depth, VALUE start_pos, VALUE decoding_palette) {
319
+
321
320
  VALUE pixels = rb_ary_new();
322
-
321
+
323
322
  if ((FIX2LONG(height) > 0) && (FIX2LONG(width) > 0)) {
324
323
 
325
324
  char pixel_size = oily_png_pixel_bytesize(FIX2INT(color_mode), FIX2INT(depth));
326
325
  long line_size = oily_png_scanline_bytesize(FIX2INT(color_mode), FIX2INT(depth), FIX2LONG(width));
327
326
  long pass_size = oily_png_pass_bytesize(FIX2INT(color_mode), FIX2INT(depth), FIX2LONG(width), FIX2LONG(height));
328
-
327
+
329
328
  // Make sure that the stream is large enough to contain our pass.
330
329
  if (RSTRING_LEN(stream) < pass_size + FIX2LONG(start_pos)) {
331
330
  rb_raise(rb_eRuntimeError, "The length of the stream is too short to contain the image!");
@@ -337,9 +336,9 @@ VALUE oily_png_decode_png_image_pass(VALUE self, VALUE stream, VALUE width, VALU
337
336
  memcpy(bytes, RSTRING_PTR(stream) + FIX2LONG(start_pos), pass_size);
338
337
 
339
338
  // Get the decoding palette for indexed images.
340
- VALUE decoding_palette = Qnil;
339
+ VALUE decoding_map = Qnil;
341
340
  if (FIX2INT(color_mode) == OILY_PNG_COLOR_INDEXED) {
342
- decoding_palette = oily_png_decode_palette(self);
341
+ decoding_map = oily_png_decode_palette(decoding_palette);
343
342
  }
344
343
 
345
344
  // Select the scanline decoder function for this color mode and bit depth.
@@ -347,11 +346,11 @@ VALUE oily_png_decode_png_image_pass(VALUE self, VALUE stream, VALUE width, VALU
347
346
  if (scanline_decoder == NULL) {
348
347
  rb_raise(rb_eRuntimeError, "No decoder for color mode %d and bit depth %d", FIX2INT(color_mode), FIX2INT(depth));
349
348
  }
350
-
349
+
351
350
  long y, line_start;
352
351
  for (y = 0; y < FIX2LONG(height); y++) {
353
352
  line_start = y * line_size;
354
-
353
+
355
354
  // Apply filering to the line
356
355
  switch (bytes[line_start]) {
357
356
  case OILY_PNG_FILTER_NONE: break;
@@ -361,12 +360,12 @@ VALUE oily_png_decode_png_image_pass(VALUE self, VALUE stream, VALUE width, VALU
361
360
  case OILY_PNG_FILTER_PAETH: oily_png_decode_filter_paeth( bytes, line_start, line_size, pixel_size); break;
362
361
  default: rb_raise(rb_eRuntimeError, "Filter type not supported: %d", bytes[line_start]);
363
362
  }
364
-
363
+
365
364
  // Set the filter byte to 0 because the bytearray is now unfiltered.
366
365
  bytes[line_start] = OILY_PNG_FILTER_NONE;
367
- scanline_decoder(pixels, bytes, line_start, FIX2LONG(width), decoding_palette);
366
+ scanline_decoder(pixels, bytes, line_start, FIX2LONG(width), decoding_map);
368
367
  }
369
-
368
+
370
369
  xfree(bytes);
371
370
  }
372
371
 
@@ -9,7 +9,7 @@
9
9
  } else { \
10
10
  rb_raise(rb_eRuntimeError, "The decoding palette does not have %d entries!", (palette_entry)); \
11
11
  }
12
-
12
+
13
13
  #define ADD_PIXEL_FROM_RGBA(pixels, r, g, b, a) rb_ary_push(pixels, UINT2NUM(BUILD_PIXEL(r,g,b,a)));
14
14
 
15
15
 
@@ -19,9 +19,9 @@ typedef void(*scanline_decoder_func)(VALUE, BYTE*, long, long, VALUE);
19
19
  Decodes an image pass from the given byte stream at the given position.
20
20
  A normal PNG will only have one pass that consumes the entire stream, while an
21
21
  interlaced image requires 7 passes which are loaded from different starting positions.
22
-
22
+
23
23
  This function shouild replace ChunkyPNG::Canvas::PNGDecoding.decode_png_image_pass
24
24
  */
25
- VALUE oily_png_decode_png_image_pass(VALUE self, VALUE stream, VALUE width, VALUE height, VALUE color_mode, VALUE depth, VALUE start_pos);
25
+ VALUE oily_png_decode_png_image_pass(VALUE self, VALUE stream, VALUE width, VALUE height, VALUE color_mode, VALUE depth, VALUE start_pos, VALUE decoding_palette);
26
26
 
27
27
  #endif
@@ -1,3 +1,3 @@
1
1
  module OilyPNG
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.extensions = ["ext/oily_png/extconf.rb"]
26
26
  s.require_paths = ["lib", "ext"]
27
27
 
28
- s.add_runtime_dependency('chunky_png', '~> 1.3.1')
28
+ s.add_runtime_dependency('chunky_png', '~> 1.3.7')
29
29
 
30
30
  s.add_development_dependency('rake')
31
31
  s.add_development_dependency('rake-compiler')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oily_png
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-28 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.1
19
+ version: 1.3.7
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.1
26
+ version: 1.3.7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
220
  version: '0'
221
221
  requirements: []
222
222
  rubyforge_project: oily_png
223
- rubygems_version: 2.0.14
223
+ rubygems_version: 2.0.14.1
224
224
  signing_key:
225
225
  specification_version: 4
226
226
  summary: Native mixin to speed up ChunkyPNG