apple_png 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/ext/apple_png/apple_png.c +30 -4
  3. metadata +8 -10
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ee347d852329d08bb54a22f38a656b74f8abffac
4
+ data.tar.gz: 2a70ad73f16d77366845d179df821116cac8f3ed
5
+ SHA512:
6
+ metadata.gz: eaff6ca90ba20fb20dc3d779fa3f0d941c933f7f774cbd36e2a18c6b4c682b18e470825e31b532fa8e2dde89ba4758227ea8e60213097f840261ef927a9f2053
7
+ data.tar.gz: e42c0562ef5a25d983c07cd12dc7876e7e5c4440ec514f6cfc93cb605cc9f7cc1be1c0a616a76c70f89aaa4643590a132a72955b2fbef740e4adbc1d1e3b83be
@@ -14,6 +14,24 @@
14
14
  #define APPLE_PNG_ZLIB_VERSION_ERROR Z_VERSION_ERROR
15
15
  #define APPLE_PNG_NO_MEM_ERROR Z_MEM_ERROR
16
16
 
17
+ #define N_VALID_CHUNK_NAMES 14
18
+ static const char *VALID_CHUNK_NAMES[] = {
19
+ "IHDR",
20
+ "PLTE",
21
+ "IDAT",
22
+ "IEND",
23
+ "cHRM",
24
+ "gAMA",
25
+ "sBIT",
26
+ "bKGD",
27
+ "hIST",
28
+ "tRNS",
29
+ "pHYs",
30
+ "tIME",
31
+ "tEXt",
32
+ "zTXt"
33
+ };
34
+
17
35
  /* calculate how many scanlines an adam7 interlaced png will result in */
18
36
  static uint32_t interlaced_count_scanlines(uint32_t width, uint32_t height) {
19
37
  uint32_t pass[7];
@@ -238,7 +256,18 @@ static int readPngChunks(VALUE self, const char *oldPNG, size_t oldPngLength, dy
238
256
  const char *chunkCRC_raw = &oldPNG[cursor + 8 + chunkLength];
239
257
  cursor += chunkLength + 12;
240
258
 
241
- if (strncmp(chunkType, "IHDR", 4) == 0) {
259
+ int isValidChunkName = 0;
260
+ for (unsigned int i = 0; i < N_VALID_CHUNK_NAMES; i++) {
261
+ if (strncmp(chunkType, VALID_CHUNK_NAMES[i], 4) == 0) {
262
+ isValidChunkName = 1;
263
+ break;
264
+ }
265
+ }
266
+
267
+ if (!isValidChunkName) {
268
+ /* filter out Apple-specific chunks such as CgBI and iDOT */
269
+ continue;
270
+ } else if (strncmp(chunkType, "IHDR", 4) == 0) {
242
271
  /* extract dimensions from header */
243
272
  width = PNG_BYTES2UINT(&chunkData[0]);
244
273
  height = PNG_BYTES2UINT(&chunkData[4]);
@@ -249,9 +278,6 @@ static int readPngChunks(VALUE self, const char *oldPNG, size_t oldPngLength, dy
249
278
  /* collect pixel data to process it once an IEND chunk appears */
250
279
  dyn_arr_append(applePngCompressedPixelData, chunkData, chunkLength);
251
280
  continue;
252
- } else if (strncmp(chunkType, "CgBI", 4) == 0) {
253
- /* don't write CgBI chunks to the output png */
254
- continue;
255
281
  } else if (strncmp(chunkType, "IEND", 4) == 0) {
256
282
  /* all png data has been procssed, now flip the color bytes */
257
283
  unsigned char *decompressedPixelData, *standardPngCompressedPixelData;
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_png
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Marvin Killing
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-17 00:00:00.000000000 Z
11
+ date: 2015-12-23 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Converts the Apple PNG format used in iOS packages to standard PNG
15
14
  email: marvinkilling@gmail.com
@@ -18,33 +17,32 @@ extensions:
18
17
  - ext/apple_png/extconf.rb
19
18
  extra_rdoc_files: []
20
19
  files:
21
- - lib/apple_png.rb
22
20
  - ext/apple_png/apple_png.c
23
21
  - ext/apple_png/dyn_arr.h
24
22
  - ext/apple_png/extconf.rb
23
+ - lib/apple_png.rb
25
24
  homepage: http://rubygems.org/gems/apple_png
26
25
  licenses: []
26
+ metadata: {}
27
27
  post_install_message:
28
28
  rdoc_options: []
29
29
  require_paths:
30
30
  - lib
31
31
  required_ruby_version: !ruby/object:Gem::Requirement
32
- none: false
33
32
  requirements:
34
- - - ! '>='
33
+ - - ">="
35
34
  - !ruby/object:Gem::Version
36
35
  version: '0'
37
36
  required_rubygems_version: !ruby/object:Gem::Requirement
38
- none: false
39
37
  requirements:
40
- - - ! '>='
38
+ - - ">="
41
39
  - !ruby/object:Gem::Version
42
40
  version: '0'
43
41
  requirements: []
44
42
  rubyforge_project:
45
- rubygems_version: 1.8.25
43
+ rubygems_version: 2.4.6
46
44
  signing_key:
47
- specification_version: 3
45
+ specification_version: 4
48
46
  summary: Converts the Apple PNG format to standard PNG
49
47
  test_files: []
50
48
  has_rdoc: