chunky_png 1.3.12 → 1.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +35 -0
- data/Gemfile +2 -0
- data/Rakefile +2 -0
- data/chunky_png.gemspec +2 -0
- data/lib/chunky_png.rb +3 -7
- data/lib/chunky_png/canvas.rb +2 -0
- data/lib/chunky_png/canvas/adam7_interlacing.rb +2 -0
- data/lib/chunky_png/canvas/data_url_exporting.rb +2 -0
- data/lib/chunky_png/canvas/data_url_importing.rb +2 -0
- data/lib/chunky_png/canvas/drawing.rb +2 -0
- data/lib/chunky_png/canvas/masking.rb +2 -0
- data/lib/chunky_png/canvas/operations.rb +2 -0
- data/lib/chunky_png/canvas/png_decoding.rb +3 -1
- data/lib/chunky_png/canvas/png_encoding.rb +4 -2
- data/lib/chunky_png/canvas/resampling.rb +2 -0
- data/lib/chunky_png/canvas/stream_exporting.rb +2 -0
- data/lib/chunky_png/canvas/stream_importing.rb +3 -1
- data/lib/chunky_png/chunk.rb +3 -1
- data/lib/chunky_png/color.rb +2 -0
- data/lib/chunky_png/datastream.rb +4 -8
- data/lib/chunky_png/dimension.rb +2 -0
- data/lib/chunky_png/image.rb +2 -0
- data/lib/chunky_png/palette.rb +2 -0
- data/lib/chunky_png/point.rb +2 -0
- data/lib/chunky_png/rmagick.rb +2 -0
- data/lib/chunky_png/vector.rb +2 -0
- data/lib/chunky_png/version.rb +3 -1
- metadata +3 -3
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3700be7193fc5c0b3d545244b775b347ab31a3d87b41833eb9130bfb333350e3
|
4
|
+
data.tar.gz: 910e7069e1a5a5d55df088a27d65a88abb04d0f631641f96665e46eb9c6af633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e1779c275eb27fdbf03ffdd94859ab3a781206e16ad71638aa43d7912e520ca34385e815117801752038bd6027fec87660931b8ed596685c41ee65993276b19
|
7
|
+
data.tar.gz: 75ea37b5c3995bf899ee17bfca07983366a8311e64da2261aa6a67573ddf6d21270e2b3a5b9051c79a8c08ee4220ab184722ee32fd4215adbe30cd39e3fb8709
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: ["master"]
|
13
|
+
pull_request:
|
14
|
+
branches: ["master"]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
strategy:
|
20
|
+
matrix:
|
21
|
+
ruby: [ '2.5', '2.6', '2.7' ]
|
22
|
+
|
23
|
+
steps:
|
24
|
+
- uses: actions/checkout@v2
|
25
|
+
- name: Set up Ruby
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: ${{ matrix.ruby }}
|
29
|
+
- name: Install dependencies
|
30
|
+
run: bundle install
|
31
|
+
- name: Run tests
|
32
|
+
run: bin/rake
|
33
|
+
# Skip the linter for now.
|
34
|
+
# - name: Lint Ruby code
|
35
|
+
# run: bin/standardrb
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/chunky_png.gemspec
CHANGED
data/lib/chunky_png.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
# Basic requirements from standard library
|
2
4
|
require "set"
|
3
5
|
require "zlib"
|
@@ -138,16 +140,10 @@ module ChunkyPNG
|
|
138
140
|
class UnitsUnknown < ChunkyPNG::Exception
|
139
141
|
end
|
140
142
|
|
141
|
-
# Empty byte array. This basically is an empty string, but with the encoding
|
142
|
-
# set correctly to ASCII-8BIT (binary) in Ruby 1.9.
|
143
|
-
# @return [String] An empty string, with encoding set to binary in Ruby 1.9
|
144
|
-
# @private
|
145
|
-
EMPTY_BYTEARRAY = "".force_encoding(Encoding::BINARY).freeze
|
146
|
-
|
147
143
|
# Null-byte, with the encoding set correctly to ASCII-8BIT (binary) in Ruby 1.9.
|
148
144
|
# @return [String] A binary string, consisting of one NULL-byte.
|
149
145
|
# @private
|
150
|
-
EXTRA_BYTE = "\0".
|
146
|
+
EXTRA_BYTE = "\0".b
|
151
147
|
end
|
152
148
|
|
153
149
|
require "chunky_png/version"
|
data/lib/chunky_png/canvas.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
module ChunkyPNG
|
2
4
|
class Canvas
|
3
5
|
# The PNGDecoding contains methods for decoding PNG datastreams to create a
|
@@ -270,7 +272,7 @@ module ChunkyPNG
|
|
270
272
|
# @params (see #decode_png_pixels_from_scanline_indexed_1bit)
|
271
273
|
# @return (see #decode_png_pixels_from_scanline_indexed_1bit)
|
272
274
|
def decode_png_pixels_from_scanline_truecolor_8bit(stream, pos, width, _decoding_palette)
|
273
|
-
stream.unpack("@#{pos + 1}"
|
275
|
+
stream.unpack("@#{pos + 1}#{"NX" * width}").map { |c| c | 0x000000ff }
|
274
276
|
end
|
275
277
|
|
276
278
|
# Decodes a scanline of a 16-bit, true color image into a row of pixels.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
module ChunkyPNG
|
2
4
|
class Canvas
|
3
5
|
# Methods for encoding a Canvas instance into a PNG datastream.
|
@@ -171,7 +173,7 @@ module ChunkyPNG
|
|
171
173
|
# @param [Integer] filtering The filtering method to use.
|
172
174
|
# @return [String] The PNG encoded canvas as string.
|
173
175
|
def encode_png_image_without_interlacing(color_mode, bit_depth = 8, filtering = ChunkyPNG::FILTER_NONE)
|
174
|
-
stream =
|
176
|
+
stream = "".b
|
175
177
|
encode_png_image_pass_to_stream(stream, color_mode, bit_depth, filtering)
|
176
178
|
stream
|
177
179
|
end
|
@@ -187,7 +189,7 @@ module ChunkyPNG
|
|
187
189
|
# @param [Integer] filtering The filtering method to use.
|
188
190
|
# @return [String] The PNG encoded canvas as string.
|
189
191
|
def encode_png_image_with_interlacing(color_mode, bit_depth = 8, filtering = ChunkyPNG::FILTER_NONE)
|
190
|
-
stream =
|
192
|
+
stream = "".b
|
191
193
|
0.upto(6) do |pass|
|
192
194
|
subcanvas = self.class.adam7_extract_pass(pass, self)
|
193
195
|
subcanvas.encoding_palette = encoding_palette
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
module ChunkyPNG
|
2
4
|
class Canvas
|
3
5
|
# Methods to quickly load a canvas from a stream, encoded in RGB, RGBA, BGR or ABGR format.
|
@@ -51,7 +53,7 @@ module ChunkyPNG
|
|
51
53
|
def from_bgr_stream(width, height, stream)
|
52
54
|
string = ChunkyPNG::EXTRA_BYTE.dup # Add a first byte to the first BGR triple.
|
53
55
|
string << (stream.respond_to?(:read) ? stream.read(3 * width * height) : stream.to_s[0, 3 * width * height])
|
54
|
-
pixels = string.unpack("@1"
|
56
|
+
pixels = string.unpack("@1#{"XV" * (width * height)}").map { |color| color | 0x000000ff }
|
55
57
|
new(width, height, pixels)
|
56
58
|
end
|
57
59
|
|
data/lib/chunky_png/chunk.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
module ChunkyPNG
|
2
4
|
# A PNG datastream consists of multiple chunks. This module, and the classes
|
3
5
|
# contained within, help with handling these chunks. It supports both reading
|
@@ -186,7 +188,7 @@ module ChunkyPNG
|
|
186
188
|
# Returns an empty string, because this chunk should always be empty.
|
187
189
|
# @return [""] An empty string.
|
188
190
|
def content
|
189
|
-
|
191
|
+
"".b
|
190
192
|
end
|
191
193
|
end
|
192
194
|
|
data/lib/chunky_png/color.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
module ChunkyPNG
|
2
4
|
# The Datastream class represents a PNG formatted datastream. It supports
|
3
5
|
# both reading from and writing to strings, streams and files.
|
@@ -9,7 +11,7 @@ module ChunkyPNG
|
|
9
11
|
# @see ChunkyPNG::Chunk
|
10
12
|
class Datastream
|
11
13
|
# The signature that each PNG file or stream should begin with.
|
12
|
-
SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10].pack("C8").force_encoding(Encoding::BINARY).freeze
|
14
|
+
SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10].pack("C8").force_encoding(::Encoding::BINARY).freeze
|
13
15
|
|
14
16
|
# The header chunk of this datastream.
|
15
17
|
# @return [ChunkyPNG::Chunk::Header]
|
@@ -72,7 +74,7 @@ module ChunkyPNG
|
|
72
74
|
# @param [IO] io The stream to read from.
|
73
75
|
# @return [ChunkyPNG::Datastream] The loaded datastream instance.
|
74
76
|
def from_io(io)
|
75
|
-
io.set_encoding(Encoding::BINARY)
|
77
|
+
io.set_encoding(::Encoding::BINARY)
|
76
78
|
verify_signature!(io)
|
77
79
|
|
78
80
|
ds = new
|
@@ -156,12 +158,6 @@ module ChunkyPNG
|
|
156
158
|
# WRITING DATASTREAMS
|
157
159
|
##################################################################################
|
158
160
|
|
159
|
-
# Returns an empty stream using binary encoding that can be used as stream to encode to.
|
160
|
-
# @return [String] An empty, binary string.
|
161
|
-
def self.empty_bytearray
|
162
|
-
ChunkyPNG::EMPTY_BYTEARRAY.dup
|
163
|
-
end
|
164
|
-
|
165
161
|
# Writes the datastream to the given output stream.
|
166
162
|
# @param [IO] io The output stream to write to.
|
167
163
|
def write(io)
|
data/lib/chunky_png/dimension.rb
CHANGED
data/lib/chunky_png/image.rb
CHANGED
data/lib/chunky_png/palette.rb
CHANGED
data/lib/chunky_png/point.rb
CHANGED
data/lib/chunky_png/rmagick.rb
CHANGED
data/lib/chunky_png/vector.rb
CHANGED
data/lib/chunky_png/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chunky_png
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.13
|
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: 2020-
|
11
|
+
date: 2020-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -93,9 +93,9 @@ extra_rdoc_files:
|
|
93
93
|
- CONTRIBUTING.rdoc
|
94
94
|
- CHANGELOG.rdoc
|
95
95
|
files:
|
96
|
+
- ".github/workflows/ruby.yml"
|
96
97
|
- ".gitignore"
|
97
98
|
- ".standard.yml"
|
98
|
-
- ".travis.yml"
|
99
99
|
- ".yardopts"
|
100
100
|
- BENCHMARKING.rdoc
|
101
101
|
- CHANGELOG.rdoc
|