paperback 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/tests.yml +46 -0
  3. data/.rubocop-disables.yml +26 -9
  4. data/CHANGELOG.md +7 -0
  5. data/README.md +4 -1
  6. data/lib/paperback/cli.rb +17 -0
  7. data/lib/paperback/document.rb +74 -11
  8. data/lib/paperback/preparer.rb +76 -21
  9. data/lib/paperback/version.rb +2 -1
  10. data/lib/paperback.rb +12 -0
  11. data/paperback.gemspec +10 -7
  12. data/sorbet/config +3 -0
  13. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  14. data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
  15. data/sorbet/rbi/gems/chunky_png@1.4.0.rbi +4498 -0
  16. data/sorbet/rbi/gems/coderay@1.1.3.rbi +3426 -0
  17. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1083 -0
  18. data/sorbet/rbi/gems/method_source@1.0.0.rbi +272 -0
  19. data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
  20. data/sorbet/rbi/gems/parallel@1.22.1.rbi +277 -0
  21. data/sorbet/rbi/gems/parser@3.2.0.0.rbi +6963 -0
  22. data/sorbet/rbi/gems/pdf-core@0.4.0.rbi +1682 -0
  23. data/sorbet/rbi/gems/prawn@1.3.0.rbi +5567 -0
  24. data/sorbet/rbi/gems/pry@0.14.1.rbi +9990 -0
  25. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +408 -0
  26. data/sorbet/rbi/gems/rake@13.0.6.rbi +3023 -0
  27. data/sorbet/rbi/gems/rbi@0.0.16.rbi +3008 -0
  28. data/sorbet/rbi/gems/regexp_parser@2.6.1.rbi +3481 -0
  29. data/sorbet/rbi/gems/rexml@3.2.5.rbi +4717 -0
  30. data/sorbet/rbi/gems/rqrcode@0.10.1.rbi +617 -0
  31. data/sorbet/rbi/gems/rspec-core@3.12.0.rbi +10791 -0
  32. data/sorbet/rbi/gems/rspec-expectations@3.12.1.rbi +8106 -0
  33. data/sorbet/rbi/gems/rspec-mocks@3.12.1.rbi +5305 -0
  34. data/sorbet/rbi/gems/rspec-support@3.12.0.rbi +1617 -0
  35. data/sorbet/rbi/gems/rspec@3.12.0.rbi +88 -0
  36. data/sorbet/rbi/gems/rubocop-ast@1.24.1.rbi +6617 -0
  37. data/sorbet/rbi/gems/rubocop@0.93.1.rbi +40848 -0
  38. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +1234 -0
  39. data/sorbet/rbi/gems/sixword@0.4.0.rbi +536 -0
  40. data/sorbet/rbi/gems/spoom@1.1.15.rbi +2383 -0
  41. data/sorbet/rbi/gems/subprocess@1.5.6.rbi +391 -0
  42. data/sorbet/rbi/gems/tapioca@0.10.5.rbi +3207 -0
  43. data/sorbet/rbi/gems/thor@1.2.1.rbi +3956 -0
  44. data/sorbet/rbi/gems/ttfunk@1.4.0.rbi +1951 -0
  45. data/sorbet/rbi/gems/unicode-display_width@1.8.0.rbi +40 -0
  46. data/sorbet/rbi/gems/unparser@0.6.7.rbi +4524 -0
  47. data/sorbet/rbi/gems/webrick@1.7.0.rbi +2555 -0
  48. data/sorbet/rbi/gems/yard-sorbet@0.8.0.rbi +441 -0
  49. data/sorbet/rbi/gems/yard@0.9.28.rbi +17816 -0
  50. data/sorbet/tapioca/config.yml +13 -0
  51. data/sorbet/tapioca/require.rb +4 -0
  52. data/spec/functional/paperback/cli_spec.rb +54 -25
  53. data/spec/spec_helper.rb +1 -0
  54. data/spec/unit/paperback_spec.rb +1 -0
  55. metadata +89 -13
  56. data/sample/aes.key +0 -1
  57. data/sample/aes.pdf +0 -14413
  58. data/sample/aes.pdf.passphrase.txt +0 -1
  59. data/sample/rsa2048.pdf +0 -106803
  60. data/sample/rsa2048.pdf.passphrase.txt +0 -1
  61. data/sample/rsa2048.pem +0 -27
@@ -0,0 +1,4498 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `chunky_png` gem.
5
+ # Please instead update this file by running `bin/tapioca gem chunky_png`.
6
+
7
+ # ChunkyPNG - the pure ruby library to access PNG files.
8
+ #
9
+ # The ChunkyPNG module defines some constants that are used in the
10
+ # PNG specification, specifies some exception classes, and serves as
11
+ # a namespace for all the other modules and classes in this library.
12
+ #
13
+ # {ChunkyPNG::Image}:: class to represent PNG images, including metadata.
14
+ # {ChunkyPNG::Canvas}:: class to represent the image's canvas.
15
+ # {ChunkyPNG::Color}:: module to work with color values.
16
+ # {ChunkyPNG::Palette}:: represents the palette of colors used on a {ChunkyPNG::Canvas}.
17
+ # {ChunkyPNG::Datastream}:: represents the internal structure of a PNG {ChunkyPNG::Image}.
18
+ # {ChunkyPNG::Color}:: represents one chunk of data within a {ChunkyPNG::Datastream}.
19
+ # {ChunkyPNG::Point}:: geometry helper class representing a 2-dimensional point.
20
+ # {ChunkyPNG::Dimension}:: geometry helper class representing a dimension (i.e. width x height).
21
+ # {ChunkyPNG::Vector}:: geometry helper class representing a series of points.
22
+ #
23
+ # @author Willem van Bergen
24
+ #
25
+ # source://chunky_png//lib/chunky_png.rb#25
26
+ module ChunkyPNG
27
+ class << self
28
+ # Factory method to return a color value, based on the arguments given.
29
+ #
30
+ # @overload Color
31
+ # @overload Color
32
+ # @overload Color
33
+ # @overload Color
34
+ # @overload Color
35
+ # @raise [ArgumentError] if the arguments weren't understood as a color.
36
+ # @return [Integer] The determined color value as RGBA integer.
37
+ # @see ChunkyPNG::Color
38
+ # @see ChunkyPNG::Color.parse
39
+ #
40
+ # source://chunky_png//lib/chunky_png/color.rb#33
41
+ def Color(*args); end
42
+
43
+ # Creates a {ChunkyPNG::Dimension} instance using arguments that can be interpreted
44
+ # as width and height.
45
+ #
46
+ # @overload Dimension
47
+ # @overload Dimension
48
+ # @overload Dimension
49
+ # @overload Dimension
50
+ # @raise [ArgumentError] If the argument(s) given where not understood as a dimension.
51
+ # @return [ChunkyPNG::Dimension] The dimension created by this factory method.
52
+ # @see ChunkyPNG::Dimension
53
+ #
54
+ # source://chunky_png//lib/chunky_png/dimension.rb#31
55
+ def Dimension(*args); end
56
+
57
+ # Factory method to create {ChunkyPNG::Point} instances.
58
+ #
59
+ # This method tries to be as flexible as possible with regards to the given input: besides
60
+ # explicit coordinates, this method also accepts arrays, hashes, strings, {ChunkyPNG::Dimension}
61
+ # instances and anything that responds to <tt>:x</tt> and <tt>:y</tt>.
62
+ #
63
+ # @overload Point
64
+ # @overload Point
65
+ # @overload Point
66
+ # @overload Point
67
+ # @raise [ArgumentError] if the arguments weren't understood.
68
+ # @return [ChunkyPNG::Point]
69
+ # @see ChunkyPNG::Point
70
+ #
71
+ # source://chunky_png//lib/chunky_png/point.rb#32
72
+ def Point(*args); end
73
+
74
+ # Factory method for {ChunkyPNG::Vector} instances.
75
+ #
76
+ # @overload Vector
77
+ # @overload Vector
78
+ # @overload Vector
79
+ # @raise [ArgumentError] If the given arguments could not be understood as a vector.
80
+ # @return [ChunkyPNG::Vector] The vector created by this factory method.
81
+ # @see ChunkyPNG::Vector
82
+ #
83
+ # source://chunky_png//lib/chunky_png/vector.rb#20
84
+ def Vector(*args); end
85
+
86
+ private
87
+
88
+ # source://chunky_png//lib/chunky_png/dimension.rb#40
89
+ def build_dimension_from_object(source); end
90
+
91
+ # source://chunky_png//lib/chunky_png/point.rb#41
92
+ def build_point_from_object(source); end
93
+ end
94
+ end
95
+
96
+ # Indicates that the PNG image uses grayscale colors, i.e. only a
97
+ # single teint channel.
98
+ #
99
+ # @private
100
+ #
101
+ # source://chunky_png//lib/chunky_png.rb#33
102
+ ChunkyPNG::COLOR_GRAYSCALE = T.let(T.unsafe(nil), Integer)
103
+
104
+ # Indicates that the PNG image uses grayscale colors with opacity, i.e.
105
+ # a teint channel with an alpha channel.
106
+ #
107
+ # @private
108
+ #
109
+ # source://chunky_png//lib/chunky_png.rb#48
110
+ ChunkyPNG::COLOR_GRAYSCALE_ALPHA = T.let(T.unsafe(nil), Integer)
111
+
112
+ # Indicates that the PNG image uses indexed colors, where the values
113
+ # point to colors defined on a palette.
114
+ #
115
+ # @private
116
+ #
117
+ # source://chunky_png//lib/chunky_png.rb#43
118
+ ChunkyPNG::COLOR_INDEXED = T.let(T.unsafe(nil), Integer)
119
+
120
+ # Indicates that the PNG image uses true color, composed of a red
121
+ # green and blue channel.
122
+ #
123
+ # @private
124
+ #
125
+ # source://chunky_png//lib/chunky_png.rb#38
126
+ ChunkyPNG::COLOR_TRUECOLOR = T.let(T.unsafe(nil), Integer)
127
+
128
+ # Indicates that the PNG image uses true color with opacity, composed of
129
+ # a red, green and blue channel, and an alpha value.
130
+ #
131
+ # @private
132
+ #
133
+ # source://chunky_png//lib/chunky_png.rb#53
134
+ ChunkyPNG::COLOR_TRUECOLOR_ALPHA = T.let(T.unsafe(nil), Integer)
135
+
136
+ # Indicates that the PNG chunk content is compressed
137
+ # flag used in iTXt chunk
138
+ #
139
+ # @private
140
+ #
141
+ # source://chunky_png//lib/chunky_png.rb#68
142
+ ChunkyPNG::COMPRESSED_CONTENT = T.let(T.unsafe(nil), Integer)
143
+
144
+ # Indicates that the PNG specification's default compression
145
+ # method is used (Zlib/Deflate)
146
+ #
147
+ # @private
148
+ #
149
+ # source://chunky_png//lib/chunky_png.rb#58
150
+ ChunkyPNG::COMPRESSION_DEFAULT = T.let(T.unsafe(nil), Integer)
151
+
152
+ # Exception that is raised if the CRC check for a block fails
153
+ #
154
+ # source://chunky_png//lib/chunky_png.rb#123
155
+ class ChunkyPNG::CRCMismatch < ::ChunkyPNG::Exception; end
156
+
157
+ # The ChunkyPNG::Canvas class represents a raster image as a matrix of
158
+ # pixels.
159
+ #
160
+ # This class supports loading a Canvas from a PNG datastream, and creating a
161
+ # {ChunkyPNG::Datastream PNG datastream} based on this matrix. ChunkyPNG
162
+ # only supports 8-bit color depth, otherwise all of the PNG format's
163
+ # variations are supported for both reading and writing.
164
+ #
165
+ # This class offers per-pixel access to the matrix by using x,y coordinates.
166
+ # It uses a palette (see {ChunkyPNG::Palette}) to keep track of the
167
+ # different colors used in this matrix.
168
+ #
169
+ # The pixels in the canvas are stored as 4-byte fixnum, representing 32-bit
170
+ # RGBA colors (8 bit per channel). The module {ChunkyPNG::Color} is provided
171
+ # to work more easily with these number as color values.
172
+ #
173
+ # The module {ChunkyPNG::Canvas::Operations} is imported for operations on
174
+ # the whole canvas, like cropping and alpha compositing. Simple drawing
175
+ # functions are imported from the {ChunkyPNG::Canvas::Drawing} module.
176
+ #
177
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#4
178
+ class ChunkyPNG::Canvas
179
+ include ::ChunkyPNG::Canvas::PNGEncoding
180
+ include ::ChunkyPNG::Canvas::StreamExporting
181
+ include ::ChunkyPNG::Canvas::DataUrlExporting
182
+ include ::ChunkyPNG::Canvas::Operations
183
+ include ::ChunkyPNG::Canvas::Drawing
184
+ include ::ChunkyPNG::Canvas::Resampling
185
+ include ::ChunkyPNG::Canvas::Masking
186
+ extend ::ChunkyPNG::Canvas::PNGDecoding
187
+ extend ::ChunkyPNG::Canvas::Adam7Interlacing
188
+ extend ::ChunkyPNG::Canvas::StreamImporting
189
+ extend ::ChunkyPNG::Canvas::DataUrlImporting
190
+
191
+ # Initializes a new Canvas instance.
192
+ #
193
+ # @overload initialize
194
+ # @overload initialize
195
+ # @return [Canvas] a new instance of Canvas
196
+ #
197
+ # source://chunky_png//lib/chunky_png/canvas.rb#79
198
+ def initialize(width, height, initial = T.unsafe(nil)); end
199
+
200
+ # Equality check to compare this canvas with other matrices.
201
+ #
202
+ # @param other The object to compare this Matrix to.
203
+ # @return [true, false] True if the size and pixel values of the other
204
+ # canvas are exactly the same as this canvas's size and pixel values.
205
+ #
206
+ # source://chunky_png//lib/chunky_png/canvas.rb#277
207
+ def ==(other); end
208
+
209
+ # Returns a single pixel's color value from this canvas.
210
+ #
211
+ # @param x [Integer] The x-coordinate of the pixel (column)
212
+ # @param y [Integer] The y-coordinate of the pixel (row)
213
+ # @raise [ChunkyPNG::OutOfBounds] when the coordinates are outside of the
214
+ # image's dimensions.
215
+ # @return [Integer] The current color value at the provided coordinates.
216
+ # @see #get_pixel
217
+ #
218
+ # source://chunky_png//lib/chunky_png/canvas.rb#174
219
+ def [](x, y); end
220
+
221
+ # Replaces a single pixel in this canvas.
222
+ #
223
+ # @param x [Integer] The x-coordinate of the pixel (column)
224
+ # @param y [Integer] The y-coordinate of the pixel (row)
225
+ # @param color [Integer] The new color for the provided coordinates.
226
+ # @raise [ChunkyPNG::OutOfBounds] when the coordinates are outside of the
227
+ # image's dimensions.
228
+ # @return [Integer] The new color value for this pixel, i.e.
229
+ # <tt>color</tt>.
230
+ # @see #set_pixel
231
+ #
232
+ # source://chunky_png//lib/chunky_png/canvas.rb#135
233
+ def []=(x, y, color); end
234
+
235
+ # Returns the area of this canvas in number of pixels.
236
+ #
237
+ # @return [Integer] The number of pixels in this canvas
238
+ #
239
+ # source://chunky_png//lib/chunky_png/canvas.rb#122
240
+ def area; end
241
+
242
+ # Returns an extracted column as vector of pixels.
243
+ #
244
+ # @param x [Integer] The 0-based column index.
245
+ # @return [Array<Integer>] The vector of pixels in the requested column.
246
+ #
247
+ # source://chunky_png//lib/chunky_png/canvas.rb#200
248
+ def column(x); end
249
+
250
+ # Returns the dimension (width x height) for this canvas.
251
+ #
252
+ # @return [ChunkyPNG::Dimension] A dimension instance with the width and
253
+ # height set for this canvas.
254
+ #
255
+ # source://chunky_png//lib/chunky_png/canvas.rb#116
256
+ def dimension; end
257
+
258
+ # Equality check to compare this canvas with other matrices.
259
+ #
260
+ # @param other The object to compare this Matrix to.
261
+ # @return [true, false] True if the size and pixel values of the other
262
+ # canvas are exactly the same as this canvas's size and pixel values.
263
+ #
264
+ # source://chunky_png//lib/chunky_png/canvas.rb#277
265
+ def eql?(other); end
266
+
267
+ # Returns a single pixel from this canvas, without checking bounds. The
268
+ # return value for this method is undefined if the coordinates are out of
269
+ # bounds.
270
+ #
271
+ # @param x [Integer] The x-coordinate of the pixel (column)
272
+ # @param y [Integer] The y-coordinate of the pixel (row)
273
+ # @return [Integer] The current pixel at the provided coordinates.
274
+ #
275
+ # source://chunky_png//lib/chunky_png/canvas.rb#185
276
+ def get_pixel(x, y); end
277
+
278
+ # @return [Integer] The number of rows in this canvas
279
+ #
280
+ # source://chunky_png//lib/chunky_png/canvas.rb#55
281
+ def height; end
282
+
283
+ # Checks whether the given coordinates are in the range of the canvas
284
+ #
285
+ # @param point_like [ChunkyPNG::Point, Array, Hash, String] The point to
286
+ # check.
287
+ # @return [true, false] True if the x and y coordinates of the point are
288
+ # within the limits of this canvas.
289
+ # @see ChunkyPNG.Point
290
+ #
291
+ # source://chunky_png//lib/chunky_png/canvas.rb#233
292
+ def include?(*point_like); end
293
+
294
+ # Checks whether the given coordinates are in the range of the canvas
295
+ #
296
+ # @param point_like [ChunkyPNG::Point, Array, Hash, String] The point to
297
+ # check.
298
+ # @return [true, false] True if the x and y coordinates of the point are
299
+ # within the limits of this canvas.
300
+ # @see ChunkyPNG.Point
301
+ #
302
+ # source://chunky_png//lib/chunky_png/canvas.rb#233
303
+ def include_point?(*point_like); end
304
+
305
+ # Checks whether the given x-coordinate is in the range of the canvas
306
+ #
307
+ # @param x [Integer] The y-coordinate of the pixel (column)
308
+ # @return [true, false] True if the x-coordinate is in the range of this
309
+ # canvas.
310
+ #
311
+ # source://chunky_png//lib/chunky_png/canvas.rb#262
312
+ def include_x?(x); end
313
+
314
+ # Checks whether the given x- and y-coordinate are in the range of the
315
+ # canvas
316
+ #
317
+ # @param x [Integer] The x-coordinate of the pixel (column)
318
+ # @param y [Integer] The y-coordinate of the pixel (row)
319
+ # @return [true, false] True if the x- and y-coordinate is in the range of
320
+ # this canvas.
321
+ #
322
+ # source://chunky_png//lib/chunky_png/canvas.rb#246
323
+ def include_xy?(x, y); end
324
+
325
+ # Checks whether the given y-coordinate is in the range of the canvas
326
+ #
327
+ # @param y [Integer] The y-coordinate of the pixel (row)
328
+ # @return [true, false] True if the y-coordinate is in the range of this
329
+ # canvas.
330
+ #
331
+ # source://chunky_png//lib/chunky_png/canvas.rb#254
332
+ def include_y?(y); end
333
+
334
+ # Alternative implementation of the inspect method.
335
+ #
336
+ # @private
337
+ # @return [String] A nicely formatted string representation of this canvas.
338
+ #
339
+ # source://chunky_png//lib/chunky_png/canvas.rb#299
340
+ def inspect; end
341
+
342
+ # Returns the palette used for this canvas.
343
+ #
344
+ # @return [ChunkyPNG::Palette] A palette which contains all the colors that
345
+ # are being used for this image.
346
+ #
347
+ # source://chunky_png//lib/chunky_png/canvas.rb#269
348
+ def palette; end
349
+
350
+ # @return [Array<ChunkyPNG::Color>] The list of pixels in this canvas.
351
+ # This array always should have +width * height+ elements.
352
+ #
353
+ # source://chunky_png//lib/chunky_png/canvas.rb#59
354
+ def pixels; end
355
+
356
+ # Replaces a column of pixels on this canvas.
357
+ #
358
+ # @param x [Integer] The 0-based column index.
359
+ # @param vector [Array<Integer>] The vector of pixels to replace the column
360
+ # with.
361
+ # @return [void]
362
+ #
363
+ # source://chunky_png//lib/chunky_png/canvas.rb#220
364
+ def replace_column!(x, vector); end
365
+
366
+ # Replaces a row of pixels on this canvas.
367
+ #
368
+ # @param y [Integer] The 0-based row index.
369
+ # @param vector [Array<Integer>] The vector of pixels to replace the row
370
+ # with.
371
+ # @return [void]
372
+ #
373
+ # source://chunky_png//lib/chunky_png/canvas.rb#210
374
+ def replace_row!(y, vector); end
375
+
376
+ # Returns an extracted row as vector of pixels
377
+ #
378
+ # @param y [Integer] The 0-based row index
379
+ # @return [Array<Integer>] The vector of pixels in the requested row
380
+ #
381
+ # source://chunky_png//lib/chunky_png/canvas.rb#192
382
+ def row(y); end
383
+
384
+ # Replaces a single pixel in this canvas, without bounds checking.
385
+ #
386
+ # This method return value and effects are undefined for coordinates
387
+ # out of bounds of the canvas.
388
+ #
389
+ # @param x [Integer] The x-coordinate of the pixel (column)
390
+ # @param y [Integer] The y-coordinate of the pixel (row)
391
+ # @param color [Integer] The new color for the provided coordinates.
392
+ # @return [Integer] The new color value for this pixel, i.e.
393
+ # <tt>color</tt>.
394
+ #
395
+ # source://chunky_png//lib/chunky_png/canvas.rb#150
396
+ def set_pixel(x, y, color); end
397
+
398
+ # Replaces a single pixel in this canvas, with bounds checking. It will do
399
+ # noting if the provided coordinates are out of bounds.
400
+ #
401
+ # @param x [Integer] The x-coordinate of the pixel (column)
402
+ # @param y [Integer] The y-coordinate of the pixel (row)
403
+ # @param color [Integer] The new color value for the provided coordinates.
404
+ # @return [Integer] The new color value for this pixel, i.e.
405
+ # <tt>color</tt>, or <tt>nil</tt> if the coordinates are out of bounds.
406
+ #
407
+ # source://chunky_png//lib/chunky_png/canvas.rb#162
408
+ def set_pixel_if_within_bounds(x, y, color); end
409
+
410
+ # Creates an ChunkyPNG::Image object from this canvas.
411
+ #
412
+ # @return [ChunkyPNG::Image] This canvas wrapped in an Image instance.
413
+ #
414
+ # source://chunky_png//lib/chunky_png/canvas.rb#292
415
+ def to_image; end
416
+
417
+ # @return [Integer] The number of columns in this canvas
418
+ #
419
+ # source://chunky_png//lib/chunky_png/canvas.rb#52
420
+ def width; end
421
+
422
+ protected
423
+
424
+ # Throws an exception if the vector_length does not match this canvas'
425
+ # height.
426
+ #
427
+ # source://chunky_png//lib/chunky_png/canvas.rb#344
428
+ def assert_height!(vector_length); end
429
+
430
+ # Throws an exception if the matrix width and height does not match this canvas' dimensions.
431
+ #
432
+ # source://chunky_png//lib/chunky_png/canvas.rb#363
433
+ def assert_size!(matrix_width, matrix_height); end
434
+
435
+ # Throws an exception if the vector_length does not match this canvas'
436
+ # width.
437
+ #
438
+ # source://chunky_png//lib/chunky_png/canvas.rb#354
439
+ def assert_width!(vector_length); end
440
+
441
+ # Throws an exception if the x-coordinate is out of bounds.
442
+ #
443
+ # source://chunky_png//lib/chunky_png/canvas.rb#319
444
+ def assert_x!(x); end
445
+
446
+ # Throws an exception if the x- or y-coordinate is out of bounds.
447
+ #
448
+ # source://chunky_png//lib/chunky_png/canvas.rb#335
449
+ def assert_xy!(x, y); end
450
+
451
+ # Throws an exception if the y-coordinate is out of bounds.
452
+ #
453
+ # source://chunky_png//lib/chunky_png/canvas.rb#327
454
+ def assert_y!(y); end
455
+
456
+ # Replaces the image, given a new width, new height, and a new pixel array.
457
+ #
458
+ # source://chunky_png//lib/chunky_png/canvas.rb#310
459
+ def replace_canvas!(new_width, new_height, new_pixels); end
460
+
461
+ private
462
+
463
+ # Initializes a new Canvas instances when being cloned.
464
+ #
465
+ # @param other [ChunkyPNG::Canvas] The canvas to duplicate
466
+ # @private
467
+ # @return [void]
468
+ #
469
+ # source://chunky_png//lib/chunky_png/canvas.rb#97
470
+ def initialize_copy(other); end
471
+
472
+ class << self
473
+ # Creates a new canvas instance by duplicating another instance.
474
+ #
475
+ # @param canvas [ChunkyPNG::Canvas] The canvas to duplicate
476
+ # @return [ChunkyPNG::Canvas] The newly constructed canvas instance.
477
+ #
478
+ # source://chunky_png//lib/chunky_png/canvas.rb#105
479
+ def from_canvas(canvas); end
480
+ end
481
+ end
482
+
483
+ # Methods for decoding and encoding Adam7 interlacing.
484
+ #
485
+ # Adam7 interlacing extracts 7 pass images out of a single image, that can be encoded to a
486
+ # stream separately so the image can be built up progressively. The module is included into
487
+ # ChunkyPNG canvas and is used to extract the pass images from the original image, or to
488
+ # reconstruct an original image from separate pass images.
489
+ #
490
+ # source://chunky_png//lib/chunky_png/canvas/adam7_interlacing.rb#11
491
+ module ChunkyPNG::Canvas::Adam7Interlacing
492
+ # Extracts a pass from a complete image
493
+ #
494
+ # @param pass [Integer] The pass number, should be in 0..6.
495
+ # @param canvas [ChunkyPNG::Canvas] The image that is being deconstructed.
496
+ # @return [ChunkyPNG::Canvas] The extracted pass image.
497
+ #
498
+ # source://chunky_png//lib/chunky_png/canvas/adam7_interlacing.rb#63
499
+ def adam7_extract_pass(pass, canvas); end
500
+
501
+ # Merges a pass image into a total image that is being constructed.
502
+ #
503
+ # @param pass [Integer] The pass number, should be in 0..6.
504
+ # @param canvas [ChunkyPNG::Canvas] The image that is being constructed.
505
+ # @param subcanvas [ChunkyPNG::Canvas] The pass image that should be merged
506
+ #
507
+ # source://chunky_png//lib/chunky_png/canvas/adam7_interlacing.rb#48
508
+ def adam7_merge_pass(pass, canvas, subcanvas); end
509
+
510
+ # Returns an array with the x-shift, x-offset, y-shift and y-offset for the requested pass.
511
+ #
512
+ # @param pass [Integer] The pass number, should be in 0..6.
513
+ #
514
+ # source://chunky_png//lib/chunky_png/canvas/adam7_interlacing.rb#14
515
+ def adam7_multiplier_offset(pass); end
516
+
517
+ # Returns the pixel dimensions of the requested pass.
518
+ #
519
+ # @param pass [Integer] The pass number, should be in 0..6.
520
+ # @param original_width [Integer] The width of the original image.
521
+ # @param original_height [Integer] The height of the original image.
522
+ #
523
+ # source://chunky_png//lib/chunky_png/canvas/adam7_interlacing.rb#27
524
+ def adam7_pass_size(pass, original_width, original_height); end
525
+
526
+ # Returns an array of the dimension of all the pass images.
527
+ #
528
+ # @param original_width [Integer] The width of the original image.
529
+ # @param original_height [Integer] The height of the original image.
530
+ # @return [Array<Array<Integer>>] Returns an array with 7 pairs of dimensions.
531
+ # @see #adam7_pass_size
532
+ #
533
+ # source://chunky_png//lib/chunky_png/canvas/adam7_interlacing.rb#40
534
+ def adam7_pass_sizes(original_width, original_height); end
535
+ end
536
+
537
+ # Methods to export a canvas to a PNG data URL.
538
+ #
539
+ # source://chunky_png//lib/chunky_png/canvas/data_url_exporting.rb#6
540
+ module ChunkyPNG::Canvas::DataUrlExporting
541
+ # Exports the canvas as a data url (e.g. data:image/png;base64,<data>) that can
542
+ # easily be used inline in CSS or HTML.
543
+ #
544
+ # @return [String] The canvas formatted as a data URL string.
545
+ #
546
+ # source://chunky_png//lib/chunky_png/canvas/data_url_exporting.rb#10
547
+ def to_data_url; end
548
+ end
549
+
550
+ # Methods to import a canvas from a PNG data URL.
551
+ #
552
+ # source://chunky_png//lib/chunky_png/canvas/data_url_importing.rb#6
553
+ module ChunkyPNG::Canvas::DataUrlImporting
554
+ # Imports a canvas from a PNG data URL.
555
+ #
556
+ # @param string [String] The data URL string to load from.
557
+ # @raise ChunkyPNG::SignatureMismatch if the provides string is not a properly
558
+ # formatted PNG data URL (i.e. it should start with "data:image/png;base64,")
559
+ # @return [Canvas] The imported canvas.
560
+ #
561
+ # source://chunky_png//lib/chunky_png/canvas/data_url_importing.rb#12
562
+ def from_data_url(string); end
563
+ end
564
+
565
+ # Module that adds some primitive drawing methods to {ChunkyPNG::Canvas}.
566
+ #
567
+ # All of these methods change the current canvas instance and do not create
568
+ # a new one, even though the method names do not end with a bang.
569
+ #
570
+ # @note Drawing operations will not fail when something is drawn outside of
571
+ # the bounds of the canvas; these pixels will simply be ignored.
572
+ # @see ChunkyPNG::Canvas
573
+ #
574
+ # source://chunky_png//lib/chunky_png/canvas/drawing.rb#13
575
+ module ChunkyPNG::Canvas::Drawing
576
+ # Draws a Bezier curve
577
+ #
578
+ # @param points [Array, Point] A collection of control points
579
+ # @param stroke_color [Integer]
580
+ # @return [Chunky:PNG::Canvas] Itself, with the curve drawn
581
+ #
582
+ # source://chunky_png//lib/chunky_png/canvas/drawing.rb#39
583
+ def bezier_curve(points, stroke_color = T.unsafe(nil)); end
584
+
585
+ # Draws a circle on the canvas.
586
+ #
587
+ # @param x0 [Integer] The x-coordinate of the center of the circle.
588
+ # @param y0 [Integer] The y-coordinate of the center of the circle.
589
+ # @param radius [Integer] The radius of the circle from the center point.
590
+ # @param stroke_color [Integer] The color to use for the line.
591
+ # @param fill_color [Integer] The color to use that fills the circle.
592
+ # @return [ChunkyPNG::Canvas] Itself, with the circle drawn.
593
+ #
594
+ # source://chunky_png//lib/chunky_png/canvas/drawing.rb#241
595
+ def circle(x0, y0, radius, stroke_color = T.unsafe(nil), fill_color = T.unsafe(nil)); end
596
+
597
+ # Composes a pixel on the canvas by alpha blending a color with its
598
+ # background color.
599
+ #
600
+ # @param x [Integer] The x-coordinate of the pixel to blend.
601
+ # @param y [Integer] The y-coordinate of the pixel to blend.
602
+ # @param color [Integer] The foreground color to blend with
603
+ # @return [Integer] The composed color.
604
+ #
605
+ # source://chunky_png//lib/chunky_png/canvas/drawing.rb#21
606
+ def compose_pixel(x, y, color); end
607
+
608
+ # Composes a pixel on the canvas by alpha blending a color with its
609
+ # background color, without bounds checking.
610
+ #
611
+ # @param x [Integer] The x-coordinate of the pixel to blend.
612
+ # @param y [Integer] The y-coordinate of the pixel to blend.
613
+ # @param color [Integer] The foreground color to blend with
614
+ # @return [Integer] The composed color.
615
+ #
616
+ # source://chunky_png//lib/chunky_png/canvas/drawing.rb#31
617
+ def compose_pixel_unsafe(x, y, color); end
618
+
619
+ # Draws an anti-aliased line using Xiaolin Wu's algorithm.
620
+ #
621
+ # @param x0 [Integer] The x-coordinate of the first control point.
622
+ # @param y0 [Integer] The y-coordinate of the first control point.
623
+ # @param x1 [Integer] The x-coordinate of the second control point.
624
+ # @param y1 [Integer] The y-coordinate of the second control point.
625
+ # @param stroke_color [Integer] The color to use for this line.
626
+ # @param inclusive [true, false] Whether to draw the last pixel. Set to
627
+ # false when drawing multiple lines in a path.
628
+ # @return [ChunkyPNG::Canvas] Itself, with the line drawn.
629
+ #
630
+ # source://chunky_png//lib/chunky_png/canvas/drawing.rb#94
631
+ def line(x0, y0, x1, y1, stroke_color, inclusive = T.unsafe(nil)); end
632
+
633
+ # Draws an anti-aliased line using Xiaolin Wu's algorithm.
634
+ #
635
+ # @param x0 [Integer] The x-coordinate of the first control point.
636
+ # @param y0 [Integer] The y-coordinate of the first control point.
637
+ # @param x1 [Integer] The x-coordinate of the second control point.
638
+ # @param y1 [Integer] The y-coordinate of the second control point.
639
+ # @param stroke_color [Integer] The color to use for this line.
640
+ # @param inclusive [true, false] Whether to draw the last pixel. Set to
641
+ # false when drawing multiple lines in a path.
642
+ # @return [ChunkyPNG::Canvas] Itself, with the line drawn.
643
+ #
644
+ # source://chunky_png//lib/chunky_png/canvas/drawing.rb#94
645
+ def line_xiaolin_wu(x0, y0, x1, y1, stroke_color, inclusive = T.unsafe(nil)); end
646
+
647
+ # Draws a polygon on the canvas using the stroke_color, filled using the
648
+ # fill_color if any.
649
+ #
650
+ # @param path [Array, String] The control point vector. Accepts everything
651
+ # {ChunkyPNG.Vector} accepts.
652
+ # @param stroke_color [Integer] The stroke color to use for this polygon.
653
+ # @param fill_color [Integer] The fill color to use for this polygon.
654
+ # @return [ChunkyPNG::Canvas] Itself, with the polygon drawn.
655
+ #
656
+ # source://chunky_png//lib/chunky_png/canvas/drawing.rb#166
657
+ def polygon(path, stroke_color = T.unsafe(nil), fill_color = T.unsafe(nil)); end
658
+
659
+ # Draws a rectangle on the canvas, using two control points.
660
+ #
661
+ # @param x0 [Integer] The x-coordinate of the first control point.
662
+ # @param y0 [Integer] The y-coordinate of the first control point.
663
+ # @param x1 [Integer] The x-coordinate of the second control point.
664
+ # @param y1 [Integer] The y-coordinate of the second control point.
665
+ # @param stroke_color [Integer] The line color to use for this rectangle.
666
+ # @param fill_color [Integer] The fill color to use for this rectangle.
667
+ # @return [ChunkyPNG::Canvas] Itself, with the rectangle drawn.
668
+ #
669
+ # source://chunky_png//lib/chunky_png/canvas/drawing.rb#211
670
+ def rect(x0, y0, x1, y1, stroke_color = T.unsafe(nil), fill_color = T.unsafe(nil)); end
671
+
672
+ private
673
+
674
+ # Calculates the binomial coefficient for n over k.
675
+ #
676
+ # @param n [Integer] first parameter in coeffient (the number on top when
677
+ # looking at the mathematic formula)
678
+ # @param k [Integer] k-element, second parameter in coeffient (the number
679
+ # on the bottom when looking at the mathematic formula)
680
+ # @return [Integer] The binomial coeffcient of (n,k)
681
+ #
682
+ # source://chunky_png//lib/chunky_png/canvas/drawing.rb#311
683
+ def binomial_coefficient(n, k); end
684
+ end
685
+
686
+ # The ChunkyPNG::Canvas::Masking module defines methods to perform masking
687
+ # and theming operations on a {ChunkyPNG::Canvas}. The module is included into the Canvas class so all
688
+ # these methods are available on every canvas.
689
+ #
690
+ # @see ChunkyPNG::Canvas
691
+ #
692
+ # source://chunky_png//lib/chunky_png/canvas/masking.rb#10
693
+ module ChunkyPNG::Canvas::Masking
694
+ # Changes the color of a mask image.
695
+ #
696
+ # This method works on a canvas extracted out of another image using the {#extract_mask} method.
697
+ # It can then be applied on the extracted base image. See {#change_theme_color!} to perform
698
+ # these operations in one go.
699
+ #
700
+ # @param new_color [Integer] The color to replace the original mask color with.
701
+ # @raise [ChunkyPNG::ExpectationFailed] when this canvas is not a mask image, i.e. its palette
702
+ # has more than once color, disregarding transparency.
703
+ # @see #change_theme_color!
704
+ # @see #extract_mask
705
+ #
706
+ # source://chunky_png//lib/chunky_png/canvas/masking.rb#84
707
+ def change_mask_color!(new_color); end
708
+
709
+ # Creates a new image, based on the current image but with a new theme color.
710
+ #
711
+ # This method will replace one color in an image with another image. This is done by
712
+ # first extracting the pixels with a color close to the original theme color as a mask
713
+ # image, changing the color of this mask image and then apply it on the original image.
714
+ #
715
+ # Mask extraction works best when the theme colored pixels are clearly distinguishable
716
+ # from a background color (preferably white). You can set a tolerance level to influence
717
+ # the extraction process.
718
+ #
719
+ # @param old_theme_color [Integer] The original theme color in this image.
720
+ # @param new_theme_color [Integer] The color to replace the old theme color with.
721
+ # @param bg_color [Integer] The background color on which the theme colored pixels are placed.
722
+ # @param tolerance [Integer] The tolerance level to use when extracting the mask image. Five is
723
+ # the default; increase this if the masked image does not extract all the required pixels,
724
+ # decrease it if too many pixels get extracted.
725
+ # @return [ChunkyPNG::Canvas] Returns itself, but with the theme colored pixels changed.
726
+ # @see #change_theme_color!
727
+ # @see #change_mask_color!
728
+ #
729
+ # source://chunky_png//lib/chunky_png/canvas/masking.rb#30
730
+ def change_theme_color!(old_theme_color, new_theme_color, bg_color = T.unsafe(nil), tolerance = T.unsafe(nil)); end
731
+
732
+ # Creates a base image and a mask image from an original image that has a particular theme color.
733
+ # This can be used to easily change a theme color in an image.
734
+ #
735
+ # It will extract all the pixels that look like the theme color (with a tolerance level) and put
736
+ # these in a mask image. All the other pixels will be stored in a base image. Both images will be
737
+ # of the exact same size as the original image. The original image will be left untouched.
738
+ #
739
+ # The color of the mask image can be changed with {#change_mask_color!}. This new mask image can
740
+ # then be composed upon the base image to create an image with a new theme color. A call to
741
+ # {#change_theme_color!} will perform this in one go.
742
+ #
743
+ # @param mask_color [Integer] The current theme color.
744
+ # @param bg_color [Integer] The background color on which the theme colored pixels are applied.
745
+ # @param tolerance [Integer] The tolerance level to use when extracting the mask image. Five is
746
+ # the default; increase this if the masked image does not extract all the required pixels,
747
+ # decrease it if too many pixels get extracted.
748
+ # @return [Array<ChunkyPNG::Canvas, ChunkyPNG::Canvas>] An array with the base canvas and the mask
749
+ # canvas as elements.
750
+ # @see #change_theme_color!
751
+ # @see #change_mask_color!
752
+ #
753
+ # source://chunky_png//lib/chunky_png/canvas/masking.rb#56
754
+ def extract_mask(mask_color, bg_color = T.unsafe(nil), tolerance = T.unsafe(nil)); end
755
+ end
756
+
757
+ # The ChunkyPNG::Canvas::Operations module defines methods to perform
758
+ # operations on a {ChunkyPNG::Canvas}. The module is included into the
759
+ # Canvas class so all these methods are available on every canvas.
760
+ #
761
+ # Note that some of these operations modify the canvas, while some
762
+ # operations return a new canvas and leave the original intact.
763
+ #
764
+ # @see ChunkyPNG::Canvas
765
+ #
766
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#13
767
+ module ChunkyPNG::Canvas::Operations
768
+ # Draws a border around the image.
769
+ #
770
+ # @param size [Integer] The size of the border.
771
+ # @param color [Integer] The color of the border.
772
+ # @return [ChunkyPNG::Canvas] Returns a bordered version of the image.
773
+ # @see #border!
774
+ #
775
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#366
776
+ def border(size, color = T.unsafe(nil)); end
777
+
778
+ # Draws a border around the image in place.
779
+ #
780
+ # @param size [Integer] The size of the border.
781
+ # @param color [Integer] The color of the border.
782
+ # @return [ChunkyPNG::Canvas] Returns itself with the border added.
783
+ # @see #border
784
+ #
785
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#376
786
+ def border!(size, color = T.unsafe(nil)); end
787
+
788
+ # Composes another image onto this image using alpha blending. This will
789
+ # return a new canvas and leave the original intact.
790
+ #
791
+ # If you simply want to replace pixels or when the other image does not
792
+ # have transparency, it is faster to use {#replace}.
793
+ #
794
+ # @note API changed since 1.0 - This method now no longer is in place,
795
+ # but returns a new canvas and leaves the original intact. Use
796
+ # {#compose!} if you want to compose on the canvas in place.
797
+ # @param other [ChunkyPNG::Canvas] The foreground canvas to compose on
798
+ # the current canvas, using alpha compositing.
799
+ # @param offset_x [Integer] The x-offset to apply the new foreground on.
800
+ # @param offset_y [Integer] The y-offset to apply the new foreground on.
801
+ # @raise [ChunkyPNG::OutOfBounds] when the other canvas doesn't fit on
802
+ # this one, given the offset and size of the other canvas.
803
+ # @return [ChunkyPNG::Canvas] Returns the new canvas, composed of the
804
+ # other 2.
805
+ # @see #replace
806
+ #
807
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#90
808
+ def compose(other, offset_x = T.unsafe(nil), offset_y = T.unsafe(nil)); end
809
+
810
+ # Composes another image onto this image using alpha blending. This will
811
+ # modify the current canvas.
812
+ #
813
+ # If you simply want to replace pixels or when the other image does not
814
+ # have transparency, it is faster to use {#replace!}.
815
+ #
816
+ # @param other [ChunkyPNG::Canvas] The foreground canvas to compose on
817
+ # the current canvas, using alpha compositing.
818
+ # @param offset_x [Integer] The x-offset to apply the new foreground on.
819
+ # @param offset_y [Integer] The y-offset to apply the new foreground on.
820
+ # @raise [ChunkyPNG::OutOfBounds] when the other canvas doesn't fit on
821
+ # this one, given the offset and size of the other canvas.
822
+ # @return [ChunkyPNG::Canvas] Returns itself, but with the other canvas
823
+ # composed onto it.
824
+ # @see #replace!
825
+ # @see #compose
826
+ #
827
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#56
828
+ def compose!(other, offset_x = T.unsafe(nil), offset_y = T.unsafe(nil)); end
829
+
830
+ # Crops an image, given the coordinates and size of the image that needs
831
+ # to be cut out. This will leave the original image intact and return a
832
+ # new, cropped image with pixels copied from the original image.
833
+ #
834
+ # @param x [Integer] The x-coordinate of the top left corner of the image
835
+ # to be cropped.
836
+ # @param y [Integer] The y-coordinate of the top left corner of the image
837
+ # to be cropped.
838
+ # @param crop_width [Integer] The width of the image to be cropped.
839
+ # @param crop_height [Integer] The height of the image to be cropped.
840
+ # @raise [ChunkyPNG::OutOfBounds] when the crop dimensions plus the given
841
+ # coordinates are bigger then the original image.
842
+ # @return [ChunkyPNG::Canvas] Returns the newly created cropped image.
843
+ #
844
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#155
845
+ def crop(x, y, crop_width, crop_height); end
846
+
847
+ # Crops an image, given the coordinates and size of the image that needs
848
+ # to be cut out.
849
+ #
850
+ # This will change the size and content of the current canvas. Use
851
+ # {#crop} if you want to have a new canvas returned instead, leaving the
852
+ # current canvas intact.
853
+ #
854
+ # @param x [Integer] The x-coordinate of the top left corner of the image
855
+ # to be cropped.
856
+ # @param y [Integer] The y-coordinate of the top left corner of the image
857
+ # to be cropped.
858
+ # @param crop_width [Integer] The width of the image to be cropped.
859
+ # @param crop_height [Integer] The height of the image to be cropped.
860
+ # @raise [ChunkyPNG::OutOfBounds] when the crop dimensions plus the given
861
+ # coordinates are bigger then the original image.
862
+ # @return [ChunkyPNG::Canvas] Returns itself, but cropped.
863
+ #
864
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#175
865
+ def crop!(x, y, crop_width, crop_height); end
866
+
867
+ # Flips the image horizontally, leaving the original intact.
868
+ #
869
+ # This will flip the image on its horizontal axis, e.g. pixels on the top
870
+ # will now be pixels on the bottom. Chaining this method twice will
871
+ # return the original canvas. This method will leave the original object
872
+ # intact and return a new canvas.
873
+ #
874
+ # @return [ChunkyPNG::Canvas] The flipped image
875
+ # @see #flip_horizontally!
876
+ #
877
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#205
878
+ def flip; end
879
+
880
+ # Flips the image horizontally in place.
881
+ #
882
+ # This will flip the image on its horizontal axis, e.g. pixels on the top
883
+ # will now be pixels on the bottom. Chaining this method twice will
884
+ # return the original canvas. This method will leave the original object
885
+ # intact and return a new canvas.
886
+ #
887
+ # @return [ChunkyPNG::Canvas] Itself, but flipped
888
+ # @see #flip_horizontally
889
+ #
890
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#218
891
+ def flip!; end
892
+
893
+ # Flips the image horizontally, leaving the original intact.
894
+ #
895
+ # This will flip the image on its horizontal axis, e.g. pixels on the top
896
+ # will now be pixels on the bottom. Chaining this method twice will
897
+ # return the original canvas. This method will leave the original object
898
+ # intact and return a new canvas.
899
+ #
900
+ # @return [ChunkyPNG::Canvas] The flipped image
901
+ # @see #flip_horizontally!
902
+ #
903
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#205
904
+ def flip_horizontally; end
905
+
906
+ # Flips the image horizontally in place.
907
+ #
908
+ # This will flip the image on its horizontal axis, e.g. pixels on the top
909
+ # will now be pixels on the bottom. Chaining this method twice will
910
+ # return the original canvas. This method will leave the original object
911
+ # intact and return a new canvas.
912
+ #
913
+ # @return [ChunkyPNG::Canvas] Itself, but flipped
914
+ # @see #flip_horizontally
915
+ #
916
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#218
917
+ def flip_horizontally!; end
918
+
919
+ # Flips the image vertically, leaving the original intact.
920
+ #
921
+ # This will flip the image on its vertical axis, e.g. pixels on the left
922
+ # will now be pixels on the right. Chaining this method twice will return
923
+ # the original canvas. This method will leave the original object intact
924
+ # and return a new canvas.
925
+ #
926
+ # @return [ChunkyPNG::Canvas] The flipped image
927
+ # @see #flip_vertically!
928
+ #
929
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#240
930
+ def flip_vertically; end
931
+
932
+ # Flips the image vertically in place.
933
+ #
934
+ # This will flip the image on its vertical axis, e.g. pixels on the left
935
+ # will now be pixels on the right. Chaining this method twice will return
936
+ # the original canvas. This method will leave the original object intact
937
+ # and return a new canvas.
938
+ #
939
+ # @return [ChunkyPNG::Canvas] Itself, but flipped
940
+ # @see #flip_vertically
941
+ #
942
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#253
943
+ def flip_vertically!; end
944
+
945
+ # Converts the canvas to grayscale, returning a new canvas.
946
+ #
947
+ # This method will not modify the canvas. To modift the current canvas,
948
+ # use {#grayscale!} instead.
949
+ #
950
+ # @return [ChunkyPNG::Canvas] A copy of the canvas, converted to
951
+ # grayscale.
952
+ # @see #grayscale!
953
+ # @see ChunkyPNG::Color#to_grayscale
954
+ #
955
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#36
956
+ def grayscale; end
957
+
958
+ # Converts the canvas to grayscale.
959
+ #
960
+ # This method will modify the canvas. The obtain a new canvas and leave
961
+ # the current instance intact, use {#grayscale} instead.
962
+ #
963
+ # @return [ChunkyPNG::Canvas] Returns itself, converted to grayscale.
964
+ # @see #grayscale
965
+ # @see ChunkyPNG::Color#to_grayscale
966
+ #
967
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#22
968
+ def grayscale!; end
969
+
970
+ # Flips the image vertically, leaving the original intact.
971
+ #
972
+ # This will flip the image on its vertical axis, e.g. pixels on the left
973
+ # will now be pixels on the right. Chaining this method twice will return
974
+ # the original canvas. This method will leave the original object intact
975
+ # and return a new canvas.
976
+ #
977
+ # @return [ChunkyPNG::Canvas] The flipped image
978
+ # @see #flip_vertically!
979
+ #
980
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#240
981
+ def mirror; end
982
+
983
+ # Flips the image vertically in place.
984
+ #
985
+ # This will flip the image on its vertical axis, e.g. pixels on the left
986
+ # will now be pixels on the right. Chaining this method twice will return
987
+ # the original canvas. This method will leave the original object intact
988
+ # and return a new canvas.
989
+ #
990
+ # @return [ChunkyPNG::Canvas] Itself, but flipped
991
+ # @see #flip_vertically
992
+ #
993
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#253
994
+ def mirror!; end
995
+
996
+ # Replaces pixels on this image by pixels from another pixels, on a given
997
+ # offset. This method will modify the current canvas.
998
+ #
999
+ # This will completely replace the pixels of the background image. If you
1000
+ # want to blend them with semi-transparent pixels from the foreground
1001
+ # image, see {#compose!}.
1002
+ #
1003
+ # @note API changed since 1.0 - This method now no longer is in place,
1004
+ # but returns a new canvas and leaves the original intact. Use
1005
+ # {#replace!} if you want to replace pixels on the canvas in place.
1006
+ # @param other [ChunkyPNG::Canvas] The foreground canvas to get the
1007
+ # pixels from.
1008
+ # @param offset_x [Integer] The x-offset to apply the new foreground on.
1009
+ # @param offset_y [Integer] The y-offset to apply the new foreground on.
1010
+ # @raise [ChunkyPNG::OutOfBounds] when the other canvas doesn't fit on
1011
+ # this one, given the offset and size of the other canvas.
1012
+ # @return [ChunkyPNG::Canvas] Returns a new, combined canvas.
1013
+ # @see #compose
1014
+ #
1015
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#138
1016
+ def replace(other, offset_x = T.unsafe(nil), offset_y = T.unsafe(nil)); end
1017
+
1018
+ # Replaces pixels on this image by pixels from another pixels, on a given
1019
+ # offset. This method will modify the current canvas.
1020
+ #
1021
+ # This will completely replace the pixels of the background image. If you
1022
+ # want to blend them with semi-transparent pixels from the foreground
1023
+ # image, see {#compose!}.
1024
+ #
1025
+ # @param other [ChunkyPNG::Canvas] The foreground canvas to get the
1026
+ # pixels from.
1027
+ # @param offset_x [Integer] The x-offset to apply the new foreground on.
1028
+ # @param offset_y [Integer] The y-offset to apply the new foreground on.
1029
+ # @raise [ChunkyPNG::OutOfBounds] when the other canvas doesn't fit on
1030
+ # this one, given the offset and size of the other canvas.
1031
+ # @return [ChunkyPNG::Canvas] Returns itself, but with the other canvas
1032
+ # placed onto it.
1033
+ # @see #compose!
1034
+ # @see #replace
1035
+ #
1036
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#111
1037
+ def replace!(other, offset_x = T.unsafe(nil), offset_y = T.unsafe(nil)); end
1038
+
1039
+ # Rotates the image 180 degrees.
1040
+ #
1041
+ # This method will leave the original object intact and return a new
1042
+ # canvas.
1043
+ #
1044
+ # @return [ChunkyPNG::Canvas] The rotated image.
1045
+ # @see #rotate_180!
1046
+ #
1047
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#322
1048
+ def rotate_180; end
1049
+
1050
+ # Rotates the image 180 degrees in place.
1051
+ #
1052
+ # @return [ChunkyPNG::Canvas] Itself, but rotated 180 degrees.
1053
+ # @see #rotate_180
1054
+ #
1055
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#330
1056
+ def rotate_180!; end
1057
+
1058
+ # Returns a new canvas instance that is rotated 90 degrees clockwise.
1059
+ #
1060
+ # This method will return a new canvas and leaves the original intact.
1061
+ #
1062
+ # @return [ChunkyPNG::Canvas] A clockwise-rotated copy.
1063
+ # @see #rotate_right! for the in place version.
1064
+ #
1065
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#269
1066
+ def rotate_clockwise; end
1067
+
1068
+ # Rotates the image 90 degrees clockwise in place.
1069
+ #
1070
+ # This method will change the current canvas.
1071
+ #
1072
+ # @return [ChunkyPNG::Canvas] Itself, but rotated clockwise.
1073
+ # @see #rotate_right for a version that leaves the current canvas intact
1074
+ #
1075
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#279
1076
+ def rotate_clockwise!; end
1077
+
1078
+ # Returns an image that is rotated 90 degrees counter-clockwise.
1079
+ #
1080
+ # This method will leave the original object intact and return a new
1081
+ # canvas.
1082
+ #
1083
+ # @return [ChunkyPNG::Canvas] A rotated copy of itself.
1084
+ # @see #rotate_left! for the in-place version.
1085
+ #
1086
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#295
1087
+ def rotate_counter_clockwise; end
1088
+
1089
+ # Rotates the image 90 degrees counter-clockwise in place.
1090
+ #
1091
+ # This method will change the original canvas. See {#rotate_left} for a
1092
+ # version that leaves the canvas intact and returns a new rotated canvas
1093
+ # instead.
1094
+ #
1095
+ # @return [ChunkyPNG::Canvas] Itself, but rotated.
1096
+ #
1097
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#306
1098
+ def rotate_counter_clockwise!; end
1099
+
1100
+ # Returns an image that is rotated 90 degrees counter-clockwise.
1101
+ #
1102
+ # This method will leave the original object intact and return a new
1103
+ # canvas.
1104
+ #
1105
+ # @return [ChunkyPNG::Canvas] A rotated copy of itself.
1106
+ # @see #rotate_left! for the in-place version.
1107
+ #
1108
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#295
1109
+ def rotate_left; end
1110
+
1111
+ # Rotates the image 90 degrees counter-clockwise in place.
1112
+ #
1113
+ # This method will change the original canvas. See {#rotate_left} for a
1114
+ # version that leaves the canvas intact and returns a new rotated canvas
1115
+ # instead.
1116
+ #
1117
+ # @return [ChunkyPNG::Canvas] Itself, but rotated.
1118
+ #
1119
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#306
1120
+ def rotate_left!; end
1121
+
1122
+ # Returns a new canvas instance that is rotated 90 degrees clockwise.
1123
+ #
1124
+ # This method will return a new canvas and leaves the original intact.
1125
+ #
1126
+ # @return [ChunkyPNG::Canvas] A clockwise-rotated copy.
1127
+ # @see #rotate_right! for the in place version.
1128
+ #
1129
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#269
1130
+ def rotate_right; end
1131
+
1132
+ # Rotates the image 90 degrees clockwise in place.
1133
+ #
1134
+ # This method will change the current canvas.
1135
+ #
1136
+ # @return [ChunkyPNG::Canvas] Itself, but rotated clockwise.
1137
+ # @see #rotate_right for a version that leaves the current canvas intact
1138
+ #
1139
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#279
1140
+ def rotate_right!; end
1141
+
1142
+ # Trims the border around the image, presumed to be the color of the
1143
+ # first pixel.
1144
+ #
1145
+ # @param border [Integer] The color to attempt to trim.
1146
+ # @return [ChunkyPNG::Canvas] The trimmed image.
1147
+ # @see #trim!
1148
+ #
1149
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#341
1150
+ def trim(border = T.unsafe(nil)); end
1151
+
1152
+ # Trims the border around the image in place.
1153
+ #
1154
+ # @param border [Integer] The color to attempt to trim.
1155
+ # @return [ChunkyPNG::Canvas] Returns itself, but with the border
1156
+ # trimmed.
1157
+ # @see #trim
1158
+ #
1159
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#351
1160
+ def trim!(border = T.unsafe(nil)); end
1161
+
1162
+ protected
1163
+
1164
+ # Checks whether another image has the correct dimension to be used for
1165
+ # an operation on the current image, given an offset coordinate to work
1166
+ # with.
1167
+ #
1168
+ # @param other [ChunkyPNG::Canvas] The other canvas
1169
+ # @param offset_x [Integer] The x offset on which the other image will be
1170
+ # applied.
1171
+ # @param offset_y [Integer] The y offset on which the other image will be
1172
+ # applied.
1173
+ # @raise [ChunkyPNG::OutOfBounds] when the other image doesn't fit.
1174
+ #
1175
+ # source://chunky_png//lib/chunky_png/canvas/operations.rb#395
1176
+ def check_size_constraints!(other, offset_x, offset_y); end
1177
+ end
1178
+
1179
+ # The PNGDecoding contains methods for decoding PNG datastreams to create a
1180
+ # Canvas object. The datastream can be provided as filename, string or IO
1181
+ # stream.
1182
+ #
1183
+ # Overview of the decoding process:
1184
+ #
1185
+ # * The optional PLTE and tRNS chunk are decoded for the color palette of
1186
+ # the original image.
1187
+ # * The contents of the IDAT chunks is combined, and uncompressed using
1188
+ # Inflate decompression to the image pixelstream.
1189
+ # * Based on the color mode, width and height of the original image, which
1190
+ # is read from the PNG header (IHDR chunk), the amount of bytes
1191
+ # per line is determined.
1192
+ # * For every line of pixels in the encoded image, the original byte values
1193
+ # are restored by unapplying the milter method for that line.
1194
+ # * The read bytes are unfiltered given by the filter function specified by
1195
+ # the first byte of the line.
1196
+ # * The unfiltered pixelstream are is into colored pixels, using the color mode.
1197
+ # * All lines combined to form the original image.
1198
+ #
1199
+ # For interlaced images, the original image was split into 7 subimages.
1200
+ # These images get decoded just like the process above (from step 3), and get
1201
+ # combined to form the original images.
1202
+ #
1203
+ # @see ChunkyPNG::Canvas::PNGEncoding
1204
+ # @see https://www.w3.org/TR/PNG/ The W3C PNG format specification
1205
+ #
1206
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#31
1207
+ module ChunkyPNG::Canvas::PNGDecoding
1208
+ # Decodes a canvas from a PNG encoded pixelstream, using a given width, height,
1209
+ # color mode and interlacing mode.
1210
+ #
1211
+ # @param stream [String] The pixelstream to read from.
1212
+ # @param width [Integer] The width of the image.
1213
+ # @param height [Integer] The height of the image.
1214
+ # @param color_mode [Integer] The color mode of the encoded pixelstream.
1215
+ # @param depth [Integer] The bit depth of the pixel samples.
1216
+ # @param interlace [Integer] The interlace method of the encoded pixelstream.
1217
+ # @param decoding_palette [ChunkyPNG::Palette] The palette to use to decode colors.
1218
+ # @param transparent_color [Integer] The color that should be considered fully transparent.
1219
+ # @raise [ChunkyPNG::ExpectationFailed]
1220
+ # @return [ChunkyPNG::Canvas] The decoded Canvas instance.
1221
+ #
1222
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#95
1223
+ def decode_png_pixelstream(stream, width, height, color_mode, depth, interlace, decoding_palette, transparent_color); end
1224
+
1225
+ # Decodes a Canvas from a PNG encoded string.
1226
+ #
1227
+ # @param str [String] The string to read from.
1228
+ # @return [ChunkyPNG::Canvas] The canvas decoded from the PNG encoded string.
1229
+ #
1230
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#35
1231
+ def from_blob(str); end
1232
+
1233
+ # Decodes the Canvas from a PNG datastream instance.
1234
+ #
1235
+ # @param ds [ChunkyPNG::Datastream] The datastream to decode.
1236
+ # @return [ChunkyPNG::Canvas] The canvas decoded from the PNG datastream.
1237
+ #
1238
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#60
1239
+ def from_datastream(ds); end
1240
+
1241
+ # Decodes a Canvas from a PNG encoded file.
1242
+ #
1243
+ # @param filename [String] The file to read from.
1244
+ # @return [ChunkyPNG::Canvas] The canvas decoded from the PNG file.
1245
+ #
1246
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#44
1247
+ def from_file(filename); end
1248
+
1249
+ # Decodes a Canvas from a PNG encoded stream.
1250
+ #
1251
+ # @param io [IO, #read] The stream to read from.
1252
+ # @return [ChunkyPNG::Canvas] The canvas decoded from the PNG stream.
1253
+ #
1254
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#51
1255
+ def from_io(io); end
1256
+
1257
+ # Decodes a Canvas from a PNG encoded stream.
1258
+ #
1259
+ # @param io [IO, #read] The stream to read from.
1260
+ # @return [ChunkyPNG::Canvas] The canvas decoded from the PNG stream.
1261
+ #
1262
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#51
1263
+ def from_stream(io); end
1264
+
1265
+ # Decodes a Canvas from a PNG encoded string.
1266
+ #
1267
+ # @param str [String] The string to read from.
1268
+ # @return [ChunkyPNG::Canvas] The canvas decoded from the PNG encoded string.
1269
+ #
1270
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#35
1271
+ def from_string(str); end
1272
+
1273
+ protected
1274
+
1275
+ # Extract a bit from a byte on a given index.
1276
+ #
1277
+ # @param byte [Integer] The byte (0..255) value to extract a bit from.
1278
+ # @param index [Integer] The index within the byte. This should be 0..7;
1279
+ # the value will be modded by 8 to enforce this.
1280
+ # @return [Integer] Either 1 or 0.
1281
+ #
1282
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#168
1283
+ def decode_png_extract_1bit_value(byte, index); end
1284
+
1285
+ # Extract 2 consecutive bits from a byte.
1286
+ #
1287
+ # @param byte [Integer] The byte (0..255) value to extract a 2 bit value from.
1288
+ # @param index [Integer] The index within the byte. This should be either 0, 1, 2, or 3;
1289
+ # the value will be modded by 4 to enforce this.
1290
+ # @return [Integer] The extracted 2 bit value (0..3)
1291
+ #
1292
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#158
1293
+ def decode_png_extract_2bit_value(byte, index); end
1294
+
1295
+ # Extract 4 consecutive bits from a byte.
1296
+ #
1297
+ # @param byte [Integer] The byte (0..255) value to extract a 4 bit value from.
1298
+ # @param index [Integer] The index within the byte. This should be either 0 or 2;
1299
+ # the value will be modded by 2 to enforce this.
1300
+ # @return [Integer] The extracted 4bit value (0..15)
1301
+ #
1302
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#149
1303
+ def decode_png_extract_4bit_value(byte, index); end
1304
+
1305
+ # Decodes a single PNG image pass width a given width, height and color
1306
+ # mode, to a Canvas, starting at the given position in the stream.
1307
+ #
1308
+ # A non-interlaced image only consists of one pass, while an Adam7
1309
+ # image consists of 7 passes that must be combined after decoding.
1310
+ #
1311
+ # @param start_pos [Integer] The position in the pixel stream to start reading.
1312
+ # @param decoding_palette [ChunkyPNG::Palette] The palette to use to decode colors.
1313
+ # @param stream [String] The pixelstream to read from.
1314
+ # @param width [Integer] The width of the image.
1315
+ # @param height [Integer] The height of the image.
1316
+ # @param color_mode [Integer] The color mode of the encoded pixelstream.
1317
+ # @return [ChunkyPNG::Canvas] The decoded Canvas instance.
1318
+ #
1319
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#383
1320
+ def decode_png_image_pass(stream, width, height, color_mode, depth, start_pos, decoding_palette); end
1321
+
1322
+ # Decodes a scanline of a 16-bit, grayscale image into a row of pixels.
1323
+ #
1324
+ # @return [Array<Integer>] An array of decoded pixels.
1325
+ #
1326
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#347
1327
+ def decode_png_pixels_from_scanline_grayscale_16bit(stream, pos, width, _decoding_palette); end
1328
+
1329
+ # Decodes a scanline of a 1-bit, grayscale image into a row of pixels.
1330
+ #
1331
+ # @return [Array<Integer>] An array of decoded pixels.
1332
+ #
1333
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#310
1334
+ def decode_png_pixels_from_scanline_grayscale_1bit(stream, pos, width, _decoding_palette); end
1335
+
1336
+ # Decodes a scanline of a 2-bit, grayscale image into a row of pixels.
1337
+ #
1338
+ # @return [Array<Integer>] An array of decoded pixels.
1339
+ #
1340
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#320
1341
+ def decode_png_pixels_from_scanline_grayscale_2bit(stream, pos, width, _decoding_palette); end
1342
+
1343
+ # Decodes a scanline of a 4-bit, grayscale image into a row of pixels.
1344
+ #
1345
+ # @return [Array<Integer>] An array of decoded pixels.
1346
+ #
1347
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#330
1348
+ def decode_png_pixels_from_scanline_grayscale_4bit(stream, pos, width, _decoding_palette); end
1349
+
1350
+ # Decodes a scanline of an 8-bit, grayscale image into a row of pixels.
1351
+ #
1352
+ # @return [Array<Integer>] An array of decoded pixels.
1353
+ #
1354
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#340
1355
+ def decode_png_pixels_from_scanline_grayscale_8bit(stream, pos, width, _decoding_palette); end
1356
+
1357
+ # Decodes a scanline of a 16-bit, grayscale image with transparency into a row of pixels.
1358
+ #
1359
+ # @return [Array<Integer>] An array of decoded pixels.
1360
+ #
1361
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#299
1362
+ def decode_png_pixels_from_scanline_grayscale_alpha_16bit(stream, pos, width, _decoding_palette); end
1363
+
1364
+ # Decodes a scanline of an 8-bit, grayscale image with transparency into a row of pixels.
1365
+ #
1366
+ # @return [Array<Integer>] An array of decoded pixels.
1367
+ #
1368
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#292
1369
+ def decode_png_pixels_from_scanline_grayscale_alpha_8bit(stream, pos, width, _decoding_palette); end
1370
+
1371
+ # Decodes a scanline of a 1-bit, indexed image into a row of pixels.
1372
+ #
1373
+ # @param stream [String] The stream to decode from.
1374
+ # @param pos [Integer] The position in the stream on which the scanline starts (including the filter byte).
1375
+ # @param width [Integer] The width in pixels of the scanline.
1376
+ # @param decoding_palette [ChunkyPNG::Palette] The palette to use to decode colors.
1377
+ # @return [Array<Integer>] An array of decoded pixels.
1378
+ #
1379
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#214
1380
+ def decode_png_pixels_from_scanline_indexed_1bit(stream, pos, width, decoding_palette); end
1381
+
1382
+ # Decodes a scanline of a 2-bit, indexed image into a row of pixels.
1383
+ #
1384
+ # @return [Array<Integer>] An array of decoded pixels.
1385
+ #
1386
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#224
1387
+ def decode_png_pixels_from_scanline_indexed_2bit(stream, pos, width, decoding_palette); end
1388
+
1389
+ # Decodes a scanline of a 4-bit, indexed image into a row of pixels.
1390
+ #
1391
+ # @return [Array<Integer>] An array of decoded pixels.
1392
+ #
1393
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#234
1394
+ def decode_png_pixels_from_scanline_indexed_4bit(stream, pos, width, decoding_palette); end
1395
+
1396
+ # Decodes a scanline of a 8-bit, indexed image into a row of pixels.
1397
+ #
1398
+ # @return [Array<Integer>] An array of decoded pixels.
1399
+ #
1400
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#244
1401
+ def decode_png_pixels_from_scanline_indexed_8bit(stream, pos, width, decoding_palette); end
1402
+
1403
+ # Returns the method name to use to decode scanlines into pixels.
1404
+ #
1405
+ # @param color_mode [Integer] The color mode of the image.
1406
+ # @param depth [Integer] The bit depth of the image.
1407
+ # @raise [ChunkyPNG::NotSupported] when the color_mode and/or bit depth is not supported.
1408
+ # @return [Symbol] The method name to use for decoding, to be called on the canvas class.
1409
+ #
1410
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#357
1411
+ def decode_png_pixels_from_scanline_method(color_mode, depth); end
1412
+
1413
+ # Decodes a scanline of a 16-bit, true color image into a row of pixels.
1414
+ #
1415
+ # @return [Array<Integer>] An array of decoded pixels.
1416
+ #
1417
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#281
1418
+ def decode_png_pixels_from_scanline_truecolor_16bit(stream, pos, width, _decoding_palette); end
1419
+
1420
+ # Decodes a scanline of an 8-bit, true color image into a row of pixels.
1421
+ #
1422
+ # @return [Array<Integer>] An array of decoded pixels.
1423
+ #
1424
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#274
1425
+ def decode_png_pixels_from_scanline_truecolor_8bit(stream, pos, width, _decoding_palette); end
1426
+
1427
+ # Decodes a scanline of a 16-bit, true color image with transparency into a row of pixels.
1428
+ #
1429
+ # @return [Array<Integer>] An array of decoded pixels.
1430
+ #
1431
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#258
1432
+ def decode_png_pixels_from_scanline_truecolor_alpha_16bit(stream, pos, width, _decoding_palette); end
1433
+
1434
+ # Decodes a scanline of an 8-bit, true color image with transparency into a row of pixels.
1435
+ #
1436
+ # @return [Array<Integer>] An array of decoded pixels.
1437
+ #
1438
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#251
1439
+ def decode_png_pixels_from_scanline_truecolor_alpha_8bit(stream, pos, width, _decoding_palette); end
1440
+
1441
+ # Resamples a 16 bit value to an 8 bit value. This will discard some color information.
1442
+ #
1443
+ # @param value [Integer] The 16 bit value to resample.
1444
+ # @return [Integer] The 8 bit resampled value
1445
+ #
1446
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#176
1447
+ def decode_png_resample_16bit_value(value); end
1448
+
1449
+ # Resamples a 1 bit value to an 8 bit value.
1450
+ #
1451
+ # @param value [Integer] The 1 bit value to resample.
1452
+ # @return [Integer] The 8 bit resampled value
1453
+ #
1454
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#204
1455
+ def decode_png_resample_1bit_value(value); end
1456
+
1457
+ # Resamples a 2 bit value to an 8 bit value.
1458
+ #
1459
+ # @param value [Integer] The 2 bit value to resample.
1460
+ # @return [Integer] The 8 bit resampled value.
1461
+ #
1462
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#197
1463
+ def decode_png_resample_2bit_value(value); end
1464
+
1465
+ # Resamples a 4 bit value to an 8 bit value.
1466
+ #
1467
+ # @param value [Integer] The 4 bit value to resample.
1468
+ # @return [Integer] The 8 bit resampled value.
1469
+ #
1470
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#190
1471
+ def decode_png_resample_4bit_value(value); end
1472
+
1473
+ # No-op - available for completeness sake only
1474
+ #
1475
+ # @param value [Integer] The 8 bit value to resample.
1476
+ # @return [Integer] The 8 bit resampled value
1477
+ #
1478
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#183
1479
+ def decode_png_resample_8bit_value(value); end
1480
+
1481
+ # Decodes a scanline if it was encoded using filtering.
1482
+ #
1483
+ # It will extract the filtering method from the first byte of the scanline, and uses the
1484
+ # method to change the subsequent bytes to unfiltered values. This will modify the pixelstream.
1485
+ #
1486
+ # The bytes of the scanline can then be used to construct pixels, based on the color mode..
1487
+ #
1488
+ # @param stream [String] The pixelstream to undo the filtering in.
1489
+ # @param pos [Integer] The starting position of the scanline to decode.
1490
+ # @param prev_pos [Integer, nil] The starting position of the previously decoded scanline, or <tt>nil</tt>
1491
+ # if this is the first scanline of the image.
1492
+ # @param line_length [Integer] The number of bytes in the scanline, discounting the filter method byte.
1493
+ # @param pixel_size [Integer] The number of bytes used per pixel, based on the color mode.
1494
+ # @return [void]
1495
+ #
1496
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#421
1497
+ def decode_png_str_scanline(stream, pos, prev_pos, line_length, pixel_size); end
1498
+
1499
+ # Decodes a scanline in a pixelstream that was encoded using AVERAGE filtering.
1500
+ # This will change the pixelstream to have unfiltered values.
1501
+ #
1502
+ # @return [void]
1503
+ #
1504
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#464
1505
+ def decode_png_str_scanline_average(stream, pos, prev_pos, line_length, pixel_size); end
1506
+
1507
+ # Decodes a scanline in a pixelstream that was encoded using PAETH filtering.
1508
+ # This will change the pixelstream to have unfiltered values.
1509
+ #
1510
+ # @return [void]
1511
+ #
1512
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#476
1513
+ def decode_png_str_scanline_paeth(stream, pos, prev_pos, line_length, pixel_size); end
1514
+
1515
+ # Decodes a scanline in a pixelstream that was encoded using SUB filtering.
1516
+ # This will change the pixelstream to have unfiltered values.
1517
+ #
1518
+ # @return [void]
1519
+ #
1520
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#443
1521
+ def decode_png_str_scanline_sub(stream, pos, prev_pos, line_length, pixel_size); end
1522
+
1523
+ # Decodes a scanline that wasn't encoded using filtering. This is a no-op.
1524
+ #
1525
+ # @return [void]
1526
+ #
1527
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#435
1528
+ def decode_png_str_scanline_sub_none(stream, pos, prev_pos, line_length, pixel_size); end
1529
+
1530
+ # Decodes a scanline in a pixelstream that was encoded using UP filtering.
1531
+ # This will change the pixelstream to have unfiltered values.
1532
+ #
1533
+ # @return [void]
1534
+ #
1535
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#453
1536
+ def decode_png_str_scanline_up(stream, pos, prev_pos, line_length, pixel_size); end
1537
+
1538
+ # Decodes a canvas from a Adam 7 interlaced PNG encoded pixelstream, using a
1539
+ # given width, height and color mode.
1540
+ #
1541
+ # @param decoding_palette [ChunkyPNG::Palette] The palette to use to decode colors.
1542
+ # @param stream [String] The pixelstream to read from.
1543
+ # @param width [Integer] The width of the image.
1544
+ # @param height [Integer] The height of the image.
1545
+ # @param color_mode [Integer] The color mode of the encoded pixelstream.
1546
+ # @param depth [Integer] The bit depth of the pixel samples.
1547
+ # @return [ChunkyPNG::Canvas] The decoded Canvas instance.
1548
+ #
1549
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#132
1550
+ def decode_png_with_adam7_interlacing(stream, width, height, color_mode, depth, decoding_palette); end
1551
+
1552
+ # Decodes a canvas from a non-interlaced PNG encoded pixelstream, using a
1553
+ # given width, height and color mode.
1554
+ #
1555
+ # @param decoding_palette [ChunkyPNG::Palette] The palette to use to decode colors.
1556
+ # @param stream [String] The pixelstream to read from.
1557
+ # @param width [Integer] The width of the image.
1558
+ # @param height [Integer] The height of the image.
1559
+ # @param color_mode [Integer] The color mode of the encoded pixelstream.
1560
+ # @param depth [Integer] The bit depth of the pixel samples.
1561
+ # @return [ChunkyPNG::Canvas] The decoded Canvas instance.
1562
+ #
1563
+ # source://chunky_png//lib/chunky_png/canvas/png_decoding.rb#119
1564
+ def decode_png_without_interlacing(stream, width, height, color_mode, depth, decoding_palette); end
1565
+ end
1566
+
1567
+ # Methods for encoding a Canvas instance into a PNG datastream.
1568
+ #
1569
+ # Overview of the encoding process:
1570
+ #
1571
+ # * The image is split up in scanlines (i.e. rows of pixels);
1572
+ # * All pixels are encoded as a pixelstream, based on the color mode.
1573
+ # * All the pixel bytes in the pixelstream are adjusted using a filtering
1574
+ # method if one is specified.
1575
+ # * Compress the resulting string using deflate compression.
1576
+ # * Split compressed data over one or more PNG chunks.
1577
+ # * These chunks should be embedded in a datastream with at least a IHDR and
1578
+ # IEND chunk and possibly a PLTE chunk.
1579
+ #
1580
+ # For interlaced images, the initial image is first split into 7 subimages.
1581
+ # These images get encoded exactly as above, and the result gets combined
1582
+ # before the compression step.
1583
+ #
1584
+ # @see ChunkyPNG::Canvas::PNGDecoding
1585
+ # @see https://www.w3.org/TR/PNG/ The W3C PNG format specification
1586
+ #
1587
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#24
1588
+ module ChunkyPNG::Canvas::PNGEncoding
1589
+ # The palette used for encoding the image.This is only in used for images
1590
+ # that get encoded using indexed colors.
1591
+ #
1592
+ # @return [ChunkyPNG::Palette]
1593
+ #
1594
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#28
1595
+ def encoding_palette; end
1596
+
1597
+ # The palette used for encoding the image.This is only in used for images
1598
+ # that get encoded using indexed colors.
1599
+ #
1600
+ # @return [ChunkyPNG::Palette]
1601
+ #
1602
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#28
1603
+ def encoding_palette=(_arg0); end
1604
+
1605
+ # Writes the canvas to a file, encoded as a PNG image.
1606
+ #
1607
+ # @param filename [String] The file to save the PNG image to.
1608
+ # @param constraints [Hash, Symbol] The constraints to use when encoding the canvas.
1609
+ # This can either be a hash with different constraints, or a symbol which acts as a
1610
+ # preset for some constraints. If no constraints are given, ChunkyPNG will decide
1611
+ # for itself how to best create the PNG datastream.
1612
+ # Supported presets are <tt>:fast_rgba</tt> for quickly saving images with transparency,
1613
+ # <tt>:fast_rgb</tt> for quickly saving opaque images, and <tt>:best_compression</tt> to
1614
+ # obtain the smallest possible filesize.
1615
+ # @return [void]
1616
+ #
1617
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#42
1618
+ def save(filename, constraints = T.unsafe(nil)); end
1619
+
1620
+ # Encoded the canvas to a PNG formatted string.
1621
+ #
1622
+ # @param constraints [Hash, Symbol] The constraints to use when encoding the canvas.
1623
+ # This can either be a hash with different constraints, or a symbol which acts as a
1624
+ # preset for some constraints. If no constraints are given, ChunkyPNG will decide
1625
+ # for itself how to best create the PNG datastream.
1626
+ # Supported presets are <tt>:fast_rgba</tt> for quickly saving images with transparency,
1627
+ # <tt>:fast_rgb</tt> for quickly saving opaque images, and <tt>:best_compression</tt> to
1628
+ # obtain the smallest possible filesize.
1629
+ # @return [String] The PNG encoded canvas as string.
1630
+ #
1631
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#49
1632
+ def to_blob(constraints = T.unsafe(nil)); end
1633
+
1634
+ # Converts this Canvas to a datastream, so that it can be saved as a PNG image.
1635
+ #
1636
+ # @option constraints
1637
+ # @option constraints
1638
+ # @option constraints
1639
+ # @option constraints
1640
+ # @param constraints [Hash, Symbol] The constraints to use when encoding the canvas.
1641
+ # This can either be a hash with different constraints, or a symbol which acts as a
1642
+ # preset for some constraints. If no constraints are given, ChunkyPNG will decide
1643
+ # for itself how to best create the PNG datastream.
1644
+ # Supported presets are <tt>:fast_rgba</tt> for quickly saving images with transparency,
1645
+ # <tt>:fast_rgb</tt> for quickly saving opaque images, and <tt>:best_compression</tt> to
1646
+ # obtain the smallest possible filesize.
1647
+ # @return [ChunkyPNG::Datastream] The PNG datastream containing the encoded canvas.
1648
+ # @see ChunkyPNG::Canvas::PNGEncoding#determine_png_encoding
1649
+ #
1650
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#74
1651
+ def to_datastream(constraints = T.unsafe(nil)); end
1652
+
1653
+ # Encoded the canvas to a PNG formatted string.
1654
+ #
1655
+ # @return [String] The PNG encoded canvas as string.
1656
+ #
1657
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#49
1658
+ def to_s(constraints = T.unsafe(nil)); end
1659
+
1660
+ # Encoded the canvas to a PNG formatted string.
1661
+ #
1662
+ # @return [String] The PNG encoded canvas as string.
1663
+ #
1664
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#49
1665
+ def to_string(constraints = T.unsafe(nil)); end
1666
+
1667
+ # Writes the canvas to an IO stream, encoded as a PNG image.
1668
+ #
1669
+ # @param io [IO] The output stream to write to.
1670
+ # @param constraints [Hash, Symbol] The constraints to use when encoding the canvas.
1671
+ # This can either be a hash with different constraints, or a symbol which acts as a
1672
+ # preset for some constraints. If no constraints are given, ChunkyPNG will decide
1673
+ # for itself how to best create the PNG datastream.
1674
+ # Supported presets are <tt>:fast_rgba</tt> for quickly saving images with transparency,
1675
+ # <tt>:fast_rgb</tt> for quickly saving opaque images, and <tt>:best_compression</tt> to
1676
+ # obtain the smallest possible filesize.
1677
+ # @return [void]
1678
+ #
1679
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#34
1680
+ def write(io, constraints = T.unsafe(nil)); end
1681
+
1682
+ protected
1683
+
1684
+ # Determines the best possible PNG encoding variables for this image, by analyzing
1685
+ # the colors used for the image.
1686
+ #
1687
+ # You can provide constraints for the encoding variables by passing a hash with
1688
+ # encoding variables to this method.
1689
+ #
1690
+ # @param constraints [Hash, Symbol] The constraints for the encoding. This can be a
1691
+ # Hash or a preset symbol.
1692
+ # @return [Hash] A hash with encoding options for {ChunkyPNG::Canvas::PNGEncoding#to_datastream}
1693
+ #
1694
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#107
1695
+ def determine_png_encoding(constraints = T.unsafe(nil)); end
1696
+
1697
+ # Encodes the canvas to a stream, in a given color mode.
1698
+ #
1699
+ # @param stream [String] The stream to write to.
1700
+ # @param color_mode [Integer] The color mode to use for encoding.
1701
+ # @param bit_depth [Integer] The bit depth of the image.
1702
+ # @param filtering [Integer] The filtering method to use.
1703
+ #
1704
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#206
1705
+ def encode_png_image_pass_to_stream(stream, color_mode, bit_depth, filtering); end
1706
+
1707
+ # Encodes the canvas according to the PNG format specification with a given color
1708
+ # mode and Adam7 interlacing.
1709
+ #
1710
+ # This method will split the original canvas in 7 smaller canvases and encode them
1711
+ # one by one, concatenating the resulting strings.
1712
+ #
1713
+ # @param color_mode [Integer] The color mode to use for encoding.
1714
+ # @param bit_depth [Integer] The bit depth of the image.
1715
+ # @param filtering [Integer] The filtering method to use.
1716
+ # @return [String] The PNG encoded canvas as string.
1717
+ #
1718
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#191
1719
+ def encode_png_image_with_interlacing(color_mode, bit_depth = T.unsafe(nil), filtering = T.unsafe(nil)); end
1720
+
1721
+ # Encodes the canvas according to the PNG format specification with a given color mode.
1722
+ #
1723
+ # @param color_mode [Integer] The color mode to use for encoding.
1724
+ # @param bit_depth [Integer] The bit depth of the image.
1725
+ # @param filtering [Integer] The filtering method to use.
1726
+ # @return [String] The PNG encoded canvas as string.
1727
+ #
1728
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#175
1729
+ def encode_png_image_without_interlacing(color_mode, bit_depth = T.unsafe(nil), filtering = T.unsafe(nil)); end
1730
+
1731
+ # Encodes a line of pixels using 1-bit grayscale mode.
1732
+ #
1733
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1734
+ # @return [String] The encoded scanline as binary string
1735
+ #
1736
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#307
1737
+ def encode_png_pixels_to_scanline_grayscale_1bit(pixels); end
1738
+
1739
+ # Encodes a line of pixels using 2-bit grayscale mode.
1740
+ #
1741
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1742
+ # @return [String] The encoded scanline as binary string
1743
+ #
1744
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#325
1745
+ def encode_png_pixels_to_scanline_grayscale_2bit(pixels); end
1746
+
1747
+ # Encodes a line of pixels using 2-bit grayscale mode.
1748
+ #
1749
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1750
+ # @return [String] The encoded scanline as binary string
1751
+ #
1752
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#339
1753
+ def encode_png_pixels_to_scanline_grayscale_4bit(pixels); end
1754
+
1755
+ # Encodes a line of pixels using 8-bit grayscale mode.
1756
+ #
1757
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1758
+ # @return [String] The encoded scanline as binary string
1759
+ #
1760
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#350
1761
+ def encode_png_pixels_to_scanline_grayscale_8bit(pixels); end
1762
+
1763
+ # Encodes a line of pixels using 8-bit grayscale alpha mode.
1764
+ #
1765
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1766
+ # @return [String] The encoded scanline as binary string
1767
+ #
1768
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#357
1769
+ def encode_png_pixels_to_scanline_grayscale_alpha_8bit(pixels); end
1770
+
1771
+ # Encodes a line of pixels using 1-bit indexed mode.
1772
+ #
1773
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1774
+ # @return [String] The encoded scanline as binary string
1775
+ #
1776
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#253
1777
+ def encode_png_pixels_to_scanline_indexed_1bit(pixels); end
1778
+
1779
+ # Encodes a line of pixels using 2-bit indexed mode.
1780
+ #
1781
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1782
+ # @return [String] The encoded scanline as binary string
1783
+ #
1784
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#273
1785
+ def encode_png_pixels_to_scanline_indexed_2bit(pixels); end
1786
+
1787
+ # Encodes a line of pixels using 4-bit indexed mode.
1788
+ #
1789
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1790
+ # @return [String] The encoded scanline as binary string
1791
+ #
1792
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#289
1793
+ def encode_png_pixels_to_scanline_indexed_4bit(pixels); end
1794
+
1795
+ # Encodes a line of pixels using 8-bit indexed mode.
1796
+ #
1797
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1798
+ # @return [String] The encoded scanline as binary string
1799
+ #
1800
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#300
1801
+ def encode_png_pixels_to_scanline_indexed_8bit(pixels); end
1802
+
1803
+ # Returns the method name to use to decode scanlines into pixels.
1804
+ #
1805
+ # @param color_mode [Integer] The color mode of the image.
1806
+ # @param depth [Integer] The bit depth of the image.
1807
+ # @raise [ChunkyPNG::NotSupported] when the color_mode and/or bit depth is not supported.
1808
+ # @return [Symbol] The method name to use for decoding, to be called on the canvas class.
1809
+ #
1810
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#366
1811
+ def encode_png_pixels_to_scanline_method(color_mode, depth); end
1812
+
1813
+ # Encodes a line of pixels using 8-bit truecolor mode.
1814
+ #
1815
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1816
+ # @return [String] The encoded scanline as binary string
1817
+ #
1818
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#239
1819
+ def encode_png_pixels_to_scanline_truecolor_8bit(pixels); end
1820
+
1821
+ # Encodes a line of pixels using 8-bit truecolor alpha mode.
1822
+ #
1823
+ # @param pixels [Array<Integer>] A row of pixels of the original image.
1824
+ # @return [String] The encoded scanline as binary string
1825
+ #
1826
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#246
1827
+ def encode_png_pixels_to_scanline_truecolor_alpha_8bit(pixels); end
1828
+
1829
+ # Encodes the canvas according to the PNG format specification with a given color
1830
+ # mode, possibly with interlacing.
1831
+ #
1832
+ # @param color_mode [Integer] The color mode to use for encoding.
1833
+ # @param bit_depth [Integer] The bit depth of the image.
1834
+ # @param interlace [Integer] The interlacing method to use.
1835
+ # @return [String] The PNG encoded canvas as string.
1836
+ #
1837
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#157
1838
+ def encode_png_pixelstream(color_mode = T.unsafe(nil), bit_depth = T.unsafe(nil), interlace = T.unsafe(nil), filtering = T.unsafe(nil)); end
1839
+
1840
+ # Encodes a scanline of a pixelstream using AVERAGE filtering. This will modify the stream.
1841
+ #
1842
+ # @param stream [String] The pixelstream to work on. This string will be modified.
1843
+ # @param pos [Integer] The starting position of the scanline.
1844
+ # @param prev_pos [Integer, nil] The starting position of the previous scanline. <tt>nil</tt> if
1845
+ # this is the first line.
1846
+ # @param line_width [Integer] The number of bytes in this scanline, without counting the filtering
1847
+ # method byte.
1848
+ # @param pixel_size [Integer] The number of bytes used per pixel.
1849
+ # @return [void]
1850
+ #
1851
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#417
1852
+ def encode_png_str_scanline_average(stream, pos, prev_pos, line_width, pixel_size); end
1853
+
1854
+ # Encodes a scanline of a pixelstream without filtering. This is a no-op.
1855
+ #
1856
+ # @param stream [String] The pixelstream to work on. This string will be modified.
1857
+ # @param pos [Integer] The starting position of the scanline.
1858
+ # @param prev_pos [Integer, nil] The starting position of the previous scanline. <tt>nil</tt> if
1859
+ # this is the first line.
1860
+ # @param line_width [Integer] The number of bytes in this scanline, without counting the filtering
1861
+ # method byte.
1862
+ # @param pixel_size [Integer] The number of bytes used per pixel.
1863
+ # @return [void]
1864
+ #
1865
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#388
1866
+ def encode_png_str_scanline_none(stream, pos, prev_pos, line_width, pixel_size); end
1867
+
1868
+ # Encodes a scanline of a pixelstream using PAETH filtering. This will modify the stream.
1869
+ #
1870
+ # @param stream [String] The pixelstream to work on. This string will be modified.
1871
+ # @param pos [Integer] The starting position of the scanline.
1872
+ # @param prev_pos [Integer, nil] The starting position of the previous scanline. <tt>nil</tt> if
1873
+ # this is the first line.
1874
+ # @param line_width [Integer] The number of bytes in this scanline, without counting the filtering
1875
+ # method byte.
1876
+ # @param pixel_size [Integer] The number of bytes used per pixel.
1877
+ # @return [void]
1878
+ #
1879
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#429
1880
+ def encode_png_str_scanline_paeth(stream, pos, prev_pos, line_width, pixel_size); end
1881
+
1882
+ # Encodes a scanline of a pixelstream using SUB filtering. This will modify the stream.
1883
+ #
1884
+ # @param stream [String] The pixelstream to work on. This string will be modified.
1885
+ # @param pos [Integer] The starting position of the scanline.
1886
+ # @param prev_pos [Integer, nil] The starting position of the previous scanline. <tt>nil</tt> if
1887
+ # this is the first line.
1888
+ # @param line_width [Integer] The number of bytes in this scanline, without counting the filtering
1889
+ # method byte.
1890
+ # @param pixel_size [Integer] The number of bytes used per pixel.
1891
+ # @return [void]
1892
+ #
1893
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#395
1894
+ def encode_png_str_scanline_sub(stream, pos, prev_pos, line_width, pixel_size); end
1895
+
1896
+ # Encodes a scanline of a pixelstream using UP filtering. This will modify the stream.
1897
+ #
1898
+ # @param stream [String] The pixelstream to work on. This string will be modified.
1899
+ # @param pos [Integer] The starting position of the scanline.
1900
+ # @param prev_pos [Integer, nil] The starting position of the previous scanline. <tt>nil</tt> if
1901
+ # this is the first line.
1902
+ # @param line_width [Integer] The number of bytes in this scanline, without counting the filtering
1903
+ # method byte.
1904
+ # @param pixel_size [Integer] The number of bytes used per pixel.
1905
+ # @return [void]
1906
+ #
1907
+ # source://chunky_png//lib/chunky_png/canvas/png_encoding.rb#406
1908
+ def encode_png_str_scanline_up(stream, pos, prev_pos, line_width, pixel_size); end
1909
+ end
1910
+
1911
+ # The ChunkyPNG::Canvas::Resampling module defines methods to perform image resampling to
1912
+ # a {ChunkyPNG::Canvas}.
1913
+ #
1914
+ # Currently, only the nearest neighbor algorithm is implemented. Bilinear and cubic
1915
+ # algorithms may be added later on.
1916
+ #
1917
+ # @see ChunkyPNG::Canvas
1918
+ #
1919
+ # source://chunky_png//lib/chunky_png/canvas/resampling.rb#12
1920
+ module ChunkyPNG::Canvas::Resampling
1921
+ # source://chunky_png//lib/chunky_png/canvas/resampling.rb#90
1922
+ def resample(new_width, new_height); end
1923
+
1924
+ # source://chunky_png//lib/chunky_png/canvas/resampling.rb#134
1925
+ def resample_bilinear(new_width, new_height); end
1926
+
1927
+ # Resamples the canvas with bilinear interpolation.
1928
+ #
1929
+ # @param new_width [Integer] The width of the resampled canvas.
1930
+ # @param new_height [Integer] The height of the resampled canvas.
1931
+ # @return [ChunkyPNG::Canvas] A new canvas instance with the resampled pixels.
1932
+ #
1933
+ # source://chunky_png//lib/chunky_png/canvas/resampling.rb#98
1934
+ def resample_bilinear!(new_width, new_height); end
1935
+
1936
+ # source://chunky_png//lib/chunky_png/canvas/resampling.rb#90
1937
+ def resample_nearest_neighbor(new_width, new_height); end
1938
+
1939
+ # Resamples the canvas using nearest neighbor interpolation.
1940
+ #
1941
+ # @param new_width [Integer] The width of the resampled canvas.
1942
+ # @param new_height [Integer] The height of the resampled canvas.
1943
+ # @return [ChunkyPNG::Canvas] A new canvas instance with the resampled pixels.
1944
+ #
1945
+ # source://chunky_png//lib/chunky_png/canvas/resampling.rb#74
1946
+ def resample_nearest_neighbor!(new_width, new_height); end
1947
+
1948
+ # source://chunky_png//lib/chunky_png/canvas/resampling.rb#90
1949
+ def resize(new_width, new_height); end
1950
+
1951
+ # Integer Interpolation between two values
1952
+ #
1953
+ # Used for generating indicies for interpolation (eg, nearest
1954
+ # neighbour).
1955
+ #
1956
+ # @param width [Integer] The width of the source
1957
+ # @param new_width [Integer] The width of the destination
1958
+ # @return [Array<Integer>] An Array of Integer indicies
1959
+ #
1960
+ # source://chunky_png//lib/chunky_png/canvas/resampling.rb#21
1961
+ def steps(width, new_width); end
1962
+
1963
+ # Fractional Interpolation between two values
1964
+ #
1965
+ # Used for generating values for interpolation (eg, bilinear).
1966
+ # Produces both the indices and the interpolation factors (residues).
1967
+ #
1968
+ # @param width [Integer] The width of the source
1969
+ # @param new_width [Integer] The width of the destination
1970
+ # @return [Array<Integer>, Array<Integer>] Two arrays of indicies and residues
1971
+ #
1972
+ # source://chunky_png//lib/chunky_png/canvas/resampling.rb#38
1973
+ def steps_residues(width, new_width); end
1974
+ end
1975
+
1976
+ # Methods to save load a canvas from to stream, encoded in RGB, RGBA, BGR or ABGR format.
1977
+ #
1978
+ # source://chunky_png//lib/chunky_png/canvas/stream_exporting.rb#6
1979
+ module ChunkyPNG::Canvas::StreamExporting
1980
+ # Creates an ABGR-formatted pixelstream with the pixel data from this canvas.
1981
+ #
1982
+ # Note that this format is fast but bloated, because no compression is used
1983
+ # and the internal representation is left intact. To reconstruct the
1984
+ # canvas, the width and height should be known.
1985
+ #
1986
+ # @return [String] The RGBA-formatted pixel data.
1987
+ #
1988
+ # source://chunky_png//lib/chunky_png/canvas/stream_exporting.rb#53
1989
+ def to_abgr_stream; end
1990
+
1991
+ # Creates a stream of the alpha channel of this canvas.
1992
+ #
1993
+ # @return [String] The 0-255 alpha values of all pixels packed as string
1994
+ #
1995
+ # source://chunky_png//lib/chunky_png/canvas/stream_exporting.rb#32
1996
+ def to_alpha_channel_stream; end
1997
+
1998
+ # Creates a grayscale stream of this canvas.
1999
+ #
2000
+ # This method assume sthat this image is fully grayscale, i.e. R = G = B for
2001
+ # every pixel. The alpha channel will not be included in the stream.
2002
+ #
2003
+ # @return [String] The 0-255 grayscale values of all pixels packed as string.
2004
+ #
2005
+ # source://chunky_png//lib/chunky_png/canvas/stream_exporting.rb#42
2006
+ def to_grayscale_stream; end
2007
+
2008
+ # Creates an RGB-formatted pixelstream with the pixel data from this canvas.
2009
+ #
2010
+ # Note that this format is fast but bloated, because no compression is used
2011
+ # and the internal representation is almost left intact. To reconstruct
2012
+ # the canvas, the width and height should be known.
2013
+ #
2014
+ # @return [String] The RGB-formatted pixel data.
2015
+ #
2016
+ # source://chunky_png//lib/chunky_png/canvas/stream_exporting.rb#25
2017
+ def to_rgb_stream; end
2018
+
2019
+ # Creates an RGB-formatted pixelstream with the pixel data from this canvas.
2020
+ #
2021
+ # Note that this format is fast but bloated, because no compression is used
2022
+ # and the internal representation is left intact. To reconstruct the
2023
+ # canvas, the width and height should be known.
2024
+ #
2025
+ # @return [String] The RGBA-formatted pixel data.
2026
+ #
2027
+ # source://chunky_png//lib/chunky_png/canvas/stream_exporting.rb#14
2028
+ def to_rgba_stream; end
2029
+ end
2030
+
2031
+ # Methods to quickly load a canvas from a stream, encoded in RGB, RGBA, BGR or ABGR format.
2032
+ #
2033
+ # source://chunky_png//lib/chunky_png/canvas/stream_importing.rb#6
2034
+ module ChunkyPNG::Canvas::StreamImporting
2035
+ # Creates a canvas by reading pixels from an ARGB formatted stream with a
2036
+ # provided with and height.
2037
+ #
2038
+ # Every pixel should be represented by 4 bytes in the stream, in the correct
2039
+ # ARGB order. This format is almost like the internal representation of a
2040
+ # canvas object, so this kind of stream can be read extremely quickly.
2041
+ #
2042
+ # @param width [Integer] The width of the new canvas.
2043
+ # @param height [Integer] The height of the new canvas.
2044
+ # @param stream [#read, String] The stream to read the pixel data from.
2045
+ # @return [ChunkyPNG::Canvas] The newly constructed canvas instance.
2046
+ #
2047
+ # source://chunky_png//lib/chunky_png/canvas/stream_importing.rb#71
2048
+ def from_abgr_stream(width, height, stream); end
2049
+
2050
+ # Creates a canvas by reading pixels from an BGR formatted stream with a
2051
+ # provided with and height.
2052
+ #
2053
+ # Every pixel should be represented by 3 bytes in the stream, in the correct
2054
+ # BGR order. This format closely resembles the internal representation of a
2055
+ # canvas object, so this kind of stream can be read extremely quickly.
2056
+ #
2057
+ # @param width [Integer] The width of the new canvas.
2058
+ # @param height [Integer] The height of the new canvas.
2059
+ # @param stream [#read, String] The stream to read the pixel data from.
2060
+ # @return [ChunkyPNG::Canvas] The newly constructed canvas instance.
2061
+ #
2062
+ # source://chunky_png//lib/chunky_png/canvas/stream_importing.rb#53
2063
+ def from_bgr_stream(width, height, stream); end
2064
+
2065
+ # Creates a canvas by reading pixels from an RGB formatted stream with a
2066
+ # provided with and height.
2067
+ #
2068
+ # Every pixel should be represented by 3 bytes in the stream, in the correct
2069
+ # RGB order. This format closely resembles the internal representation of a
2070
+ # canvas object, so this kind of stream can be read extremely quickly.
2071
+ #
2072
+ # @param width [Integer] The width of the new canvas.
2073
+ # @param height [Integer] The height of the new canvas.
2074
+ # @param stream [#read, String] The stream to read the pixel data from.
2075
+ # @return [ChunkyPNG::Canvas] The newly constructed canvas instance.
2076
+ #
2077
+ # source://chunky_png//lib/chunky_png/canvas/stream_importing.rb#18
2078
+ def from_rgb_stream(width, height, stream); end
2079
+
2080
+ # Creates a canvas by reading pixels from an RGBA formatted stream with a
2081
+ # provided with and height.
2082
+ #
2083
+ # Every pixel should be represented by 4 bytes in the stream, in the correct
2084
+ # RGBA order. This format is exactly like the internal representation of a
2085
+ # canvas object, so this kind of stream can be read extremely quickly.
2086
+ #
2087
+ # @param width [Integer] The width of the new canvas.
2088
+ # @param height [Integer] The height of the new canvas.
2089
+ # @param stream [#read, String] The stream to read the pixel data from.
2090
+ # @return [ChunkyPNG::Canvas] The newly constructed canvas instance.
2091
+ #
2092
+ # source://chunky_png//lib/chunky_png/canvas/stream_importing.rb#37
2093
+ def from_rgba_stream(width, height, stream); end
2094
+ end
2095
+
2096
+ # A PNG datastream consists of multiple chunks. This module, and the classes
2097
+ # contained within, help with handling these chunks. It supports both reading
2098
+ # and writing chunks.
2099
+ #
2100
+ # All chunk types are instances of the {ChunkyPNG::Chunk::Base} class. For
2101
+ # some chunk types a specialized class is available, e.g. the IHDR chunk is
2102
+ # represented by the {ChunkyPNG::Chunk::Header} class. These specialized
2103
+ # classes help accessing the content of the chunk. All other chunks are
2104
+ # represented by the {ChunkyPNG::Chunk::Generic} class.
2105
+ #
2106
+ # @see ChunkyPNG::Datastream
2107
+ #
2108
+ # source://chunky_png//lib/chunky_png/chunk.rb#15
2109
+ module ChunkyPNG::Chunk
2110
+ class << self
2111
+ # Reads a chunk from an IO stream.
2112
+ #
2113
+ # @param io [IO, #read] The IO stream to read from.
2114
+ # @return [ChunkyPNG::Chung::Base] The loaded chunk instance.
2115
+ #
2116
+ # source://chunky_png//lib/chunky_png/chunk.rb#20
2117
+ def read(io); end
2118
+
2119
+ # Reads an exact number of bytes from an IO stream.
2120
+ #
2121
+ # @param io [IO, #read] The IO stream to read from.
2122
+ # @param length [Integer] The IO exact number of bytes to read.
2123
+ # @raise [ChunkyPNG::ExpectationFailed] If not exactly length
2124
+ # bytes could be read from the IO stream.
2125
+ # @return [String] A binary string of exactly length bytes.
2126
+ #
2127
+ # source://chunky_png//lib/chunky_png/chunk.rb#36
2128
+ def read_bytes(io, length); end
2129
+
2130
+ # Verifies the CRC of a chunk.
2131
+ #
2132
+ # @param type [String] The chunk's type.
2133
+ # @param content [String] The chunk's content.
2134
+ # @param found_crc [Integer] The chunk's found CRC value.
2135
+ # @raise [ChunkyPNG::CRCMismatch] An exception is raised if
2136
+ # the found CRC value is not equal to the expected CRC value.
2137
+ #
2138
+ # source://chunky_png//lib/chunky_png/chunk.rb#48
2139
+ def verify_crc!(type, content, found_crc); end
2140
+ end
2141
+ end
2142
+
2143
+ # The base chunk class is the superclass for every chunk type. It contains
2144
+ # methods to write the chunk to an output stream.
2145
+ #
2146
+ # A subclass should implement the +content+ method, which gets called when
2147
+ # the chunk gets written to a PNG datastream
2148
+ #
2149
+ # @abstract
2150
+ #
2151
+ # source://chunky_png//lib/chunky_png/chunk.rb#60
2152
+ class ChunkyPNG::Chunk::Base
2153
+ # Initializes the chunk instance.
2154
+ #
2155
+ # @param type [String] The four character chunk type indicator.
2156
+ # @param attributes [Hash] A hash of attributes to set on this chunk.
2157
+ # @return [Base] a new instance of Base
2158
+ #
2159
+ # source://chunky_png//lib/chunky_png/chunk.rb#69
2160
+ def initialize(type, attributes = T.unsafe(nil)); end
2161
+
2162
+ # The four-character type indicator for the chunk. This field is used to
2163
+ # find the correct class for a chunk when it is loaded from a PNG stream.
2164
+ #
2165
+ # @return [String]
2166
+ #
2167
+ # source://chunky_png//lib/chunky_png/chunk.rb#64
2168
+ def type; end
2169
+
2170
+ # The four-character type indicator for the chunk. This field is used to
2171
+ # find the correct class for a chunk when it is loaded from a PNG stream.
2172
+ #
2173
+ # @return [String]
2174
+ #
2175
+ # source://chunky_png//lib/chunky_png/chunk.rb#64
2176
+ def type=(_arg0); end
2177
+
2178
+ # Writes the chunk to the IO stream.
2179
+ #
2180
+ # It will call the +content+ method to get the content for this chunk,
2181
+ # and will calculate and append the checksum automatically.
2182
+ #
2183
+ # @param io [IO] The IO stream to write to.
2184
+ #
2185
+ # source://chunky_png//lib/chunky_png/chunk.rb#88
2186
+ def write(io); end
2187
+
2188
+ # Writes the chunk to the IO stream, using the provided content.
2189
+ # The checksum will be calculated and appended to the stream.
2190
+ #
2191
+ # @param io [IO] The IO stream to write to.
2192
+ # @param content [String] The content for this chunk.
2193
+ #
2194
+ # source://chunky_png//lib/chunky_png/chunk.rb#78
2195
+ def write_with_crc(io, content); end
2196
+ end
2197
+
2198
+ # Maps chunk types to classes, based on the four byte chunk type indicator
2199
+ # at the beginning of a chunk.
2200
+ #
2201
+ # If a chunk type is not specified in this hash, the Generic chunk type
2202
+ # will be used.
2203
+ #
2204
+ # @see ChunkyPNG::Chunk.read
2205
+ #
2206
+ # source://chunky_png//lib/chunky_png/chunk.rb#460
2207
+ ChunkyPNG::Chunk::CHUNK_TYPES = T.let(T.unsafe(nil), Hash)
2208
+
2209
+ # The CompressedText (zTXt) chunk contains keyword/value metadata about the
2210
+ # PNG stream. In this chunk, the value is compressed using Deflate
2211
+ # compression.
2212
+ #
2213
+ # @see https://www.w3.org/TR/PNG/#11zTXt
2214
+ # @see ChunkyPNG::Chunk::CompressedText
2215
+ # @see ChunkyPNG::Chunk::InternationalText
2216
+ #
2217
+ # source://chunky_png//lib/chunky_png/chunk.rb#331
2218
+ class ChunkyPNG::Chunk::CompressedText < ::ChunkyPNG::Chunk::Base
2219
+ # @return [CompressedText] a new instance of CompressedText
2220
+ #
2221
+ # source://chunky_png//lib/chunky_png/chunk.rb#334
2222
+ def initialize(keyword, value); end
2223
+
2224
+ # Creates the content to write to the stream, by concatenating the
2225
+ # keyword with the deflated value, joined by a null character.
2226
+ #
2227
+ # @return The content that should be written to the datastream.
2228
+ #
2229
+ # source://chunky_png//lib/chunky_png/chunk.rb#349
2230
+ def content; end
2231
+
2232
+ # Returns the value of attribute keyword.
2233
+ #
2234
+ # source://chunky_png//lib/chunky_png/chunk.rb#332
2235
+ def keyword; end
2236
+
2237
+ # Sets the attribute keyword
2238
+ #
2239
+ # @param value the value to set the attribute keyword to.
2240
+ #
2241
+ # source://chunky_png//lib/chunky_png/chunk.rb#332
2242
+ def keyword=(_arg0); end
2243
+
2244
+ # Returns the value of attribute value.
2245
+ #
2246
+ # source://chunky_png//lib/chunky_png/chunk.rb#332
2247
+ def value; end
2248
+
2249
+ # Sets the attribute value
2250
+ #
2251
+ # @param value the value to set the attribute value to.
2252
+ #
2253
+ # source://chunky_png//lib/chunky_png/chunk.rb#332
2254
+ def value=(_arg0); end
2255
+
2256
+ class << self
2257
+ # @raise [ChunkyPNG::NotSupported]
2258
+ #
2259
+ # source://chunky_png//lib/chunky_png/chunk.rb#339
2260
+ def read(type, content); end
2261
+ end
2262
+ end
2263
+
2264
+ # The End (IEND) chunk indicates the last chunk of a PNG stream. It does
2265
+ # not contain any data.
2266
+ #
2267
+ # @see https://www.w3.org/TR/PNG/#11IEND
2268
+ #
2269
+ # source://chunky_png//lib/chunky_png/chunk.rb#175
2270
+ class ChunkyPNG::Chunk::End < ::ChunkyPNG::Chunk::Base
2271
+ # @return [End] a new instance of End
2272
+ #
2273
+ # source://chunky_png//lib/chunky_png/chunk.rb#176
2274
+ def initialize; end
2275
+
2276
+ # Returns an empty string, because this chunk should always be empty.
2277
+ #
2278
+ # @return [""] An empty string.
2279
+ #
2280
+ # source://chunky_png//lib/chunky_png/chunk.rb#194
2281
+ def content; end
2282
+
2283
+ class << self
2284
+ # Reads the END chunk. It will check if the content is empty.
2285
+ #
2286
+ # @param type [String] The four character chunk type indicator (=
2287
+ # "IEND").
2288
+ # @param content [String] The content read from the chunk. Should be
2289
+ # empty.
2290
+ # @raise [ChunkyPNG::ExpectationFailed] Raises an exception if the content was not empty.
2291
+ # @return [ChunkyPNG::Chunk::End] The new End chunk instance.
2292
+ #
2293
+ # source://chunky_png//lib/chunky_png/chunk.rb#187
2294
+ def read(type, content); end
2295
+ end
2296
+ end
2297
+
2298
+ # The Generic chunk type will read the content from the chunk as it,
2299
+ # and will write it back as it was read.
2300
+ #
2301
+ # source://chunky_png//lib/chunky_png/chunk.rb#97
2302
+ class ChunkyPNG::Chunk::Generic < ::ChunkyPNG::Chunk::Base
2303
+ # @return [Generic] a new instance of Generic
2304
+ #
2305
+ # source://chunky_png//lib/chunky_png/chunk.rb#100
2306
+ def initialize(type, content = T.unsafe(nil)); end
2307
+
2308
+ # The attribute to store the content from the chunk, which gets
2309
+ # written by the +write+ method.
2310
+ #
2311
+ # source://chunky_png//lib/chunky_png/chunk.rb#98
2312
+ def content; end
2313
+
2314
+ # The attribute to store the content from the chunk, which gets
2315
+ # written by the +write+ method.
2316
+ #
2317
+ # source://chunky_png//lib/chunky_png/chunk.rb#98
2318
+ def content=(_arg0); end
2319
+
2320
+ class << self
2321
+ # Creates an instance, given the chunk's type and content.
2322
+ #
2323
+ # @param type [String] The four character chunk type indicator.
2324
+ # @param content [String] The content read from the chunk.
2325
+ # @return [ChunkyPNG::Chunk::Generic] The new chunk instance.
2326
+ #
2327
+ # source://chunky_png//lib/chunky_png/chunk.rb#108
2328
+ def read(type, content); end
2329
+ end
2330
+ end
2331
+
2332
+ # The header (IHDR) chunk is the first chunk of every PNG image, and
2333
+ # contains information about the image: i.e. its width, height, color
2334
+ # depth, color mode, compression method, filtering method and interlace
2335
+ # method.
2336
+ #
2337
+ # ChunkyPNG supports all values for these variables that are defined in the
2338
+ # PNG spec, except for color depth: Only 8-bit depth images are supported.
2339
+ # Note that it is still possible to access the chunk for such an image, but
2340
+ # ChunkyPNG will raise an exception if you try to access the pixel data.
2341
+ #
2342
+ # @see https://www.w3.org/TR/PNG/#11IHDR
2343
+ #
2344
+ # source://chunky_png//lib/chunky_png/chunk.rb#124
2345
+ class ChunkyPNG::Chunk::Header < ::ChunkyPNG::Chunk::Base
2346
+ # @return [Header] a new instance of Header
2347
+ #
2348
+ # source://chunky_png//lib/chunky_png/chunk.rb#127
2349
+ def initialize(attrs = T.unsafe(nil)); end
2350
+
2351
+ # Returns the value of attribute color.
2352
+ #
2353
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2354
+ def color; end
2355
+
2356
+ # Sets the attribute color
2357
+ #
2358
+ # @param value the value to set the attribute color to.
2359
+ #
2360
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2361
+ def color=(_arg0); end
2362
+
2363
+ # Returns the value of attribute compression.
2364
+ #
2365
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2366
+ def compression; end
2367
+
2368
+ # Sets the attribute compression
2369
+ #
2370
+ # @param value the value to set the attribute compression to.
2371
+ #
2372
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2373
+ def compression=(_arg0); end
2374
+
2375
+ # Returns the content for this chunk when it gets written to a file, by
2376
+ # packing the image information variables into the correct format.
2377
+ #
2378
+ # @return [String] The 13-byte content for the header chunk.
2379
+ #
2380
+ # source://chunky_png//lib/chunky_png/chunk.rb#158
2381
+ def content; end
2382
+
2383
+ # Returns the value of attribute depth.
2384
+ #
2385
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2386
+ def depth; end
2387
+
2388
+ # Sets the attribute depth
2389
+ #
2390
+ # @param value the value to set the attribute depth to.
2391
+ #
2392
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2393
+ def depth=(_arg0); end
2394
+
2395
+ # Returns the value of attribute filtering.
2396
+ #
2397
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2398
+ def filtering; end
2399
+
2400
+ # Sets the attribute filtering
2401
+ #
2402
+ # @param value the value to set the attribute filtering to.
2403
+ #
2404
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2405
+ def filtering=(_arg0); end
2406
+
2407
+ # Returns the value of attribute height.
2408
+ #
2409
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2410
+ def height; end
2411
+
2412
+ # Sets the attribute height
2413
+ #
2414
+ # @param value the value to set the attribute height to.
2415
+ #
2416
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2417
+ def height=(_arg0); end
2418
+
2419
+ # Returns the value of attribute interlace.
2420
+ #
2421
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2422
+ def interlace; end
2423
+
2424
+ # Sets the attribute interlace
2425
+ #
2426
+ # @param value the value to set the attribute interlace to.
2427
+ #
2428
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2429
+ def interlace=(_arg0); end
2430
+
2431
+ # Returns the value of attribute width.
2432
+ #
2433
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2434
+ def width; end
2435
+
2436
+ # Sets the attribute width
2437
+ #
2438
+ # @param value the value to set the attribute width to.
2439
+ #
2440
+ # source://chunky_png//lib/chunky_png/chunk.rb#125
2441
+ def width=(_arg0); end
2442
+
2443
+ class << self
2444
+ # Reads the 13 bytes of content from the header chunk to set the image
2445
+ # attributes.
2446
+ #
2447
+ # @param type [String] The four character chunk type indicator (= "IHDR").
2448
+ # @param content [String] The 13 bytes of content read from the chunk.
2449
+ # @return [ChunkyPNG::Chunk::End] The new Header chunk instance with the
2450
+ # variables set to the values according to the content.
2451
+ #
2452
+ # source://chunky_png//lib/chunky_png/chunk.rb#142
2453
+ def read(type, content); end
2454
+ end
2455
+ end
2456
+
2457
+ # An image data (IDAT) chunk holds (part of) the compressed image pixel data.
2458
+ #
2459
+ # The data of an image can be split over multiple chunks, which will have to be combined
2460
+ # and inflated in order to decode an image. See {{.combine_chunks}} to combine chunks
2461
+ # to decode, and {{.split_in_chunks}} for encoding a pixeldata stream into IDAT chunks.
2462
+ #
2463
+ # @see https://www.w3.org/TR/PNG/#11IDAT
2464
+ #
2465
+ # source://chunky_png//lib/chunky_png/chunk.rb#271
2466
+ class ChunkyPNG::Chunk::ImageData < ::ChunkyPNG::Chunk::Generic
2467
+ class << self
2468
+ # Combines the list of IDAT chunks and inflates their contents to produce the
2469
+ # pixeldata stream for the image.
2470
+ #
2471
+ # @return [String] The combined, inflated pixeldata as binary string
2472
+ #
2473
+ # source://chunky_png//lib/chunky_png/chunk.rb#272
2474
+ def combine_chunks(data_chunks); end
2475
+
2476
+ # Splits and compresses a pixeldata stream into a list of IDAT chunks.
2477
+ #
2478
+ # @param data [String] The binary string of pixeldata
2479
+ # @param level [Integer] The compression level to use.
2480
+ # @param chunk_size [Integer] The maximum size of a chunk.
2481
+ #
2482
+ # source://chunky_png//lib/chunky_png/chunk.rb#286
2483
+ def split_in_chunks(data, level = T.unsafe(nil), chunk_size = T.unsafe(nil)); end
2484
+ end
2485
+ end
2486
+
2487
+ # The InternationalText (iTXt) chunk contains keyword/value metadata about the PNG
2488
+ # stream, translated to a given locale.
2489
+ #
2490
+ # The metadata in this chunk can be encoded using UTF-8 characters.
2491
+ # Moreover, it is possible to define the language of the metadata, and give
2492
+ # a translation of the keyword name. Finally, it supports bot compressed
2493
+ # and uncompressed values.
2494
+ #
2495
+ # @see https://www.w3.org/TR/PNG/#11iTXt
2496
+ # @see ChunkyPNG::Chunk::Text
2497
+ # @see ChunkyPNG::Chunk::CompressedText
2498
+ #
2499
+ # source://chunky_png//lib/chunky_png/chunk.rb#407
2500
+ class ChunkyPNG::Chunk::InternationalText < ::ChunkyPNG::Chunk::Base
2501
+ # @return [InternationalText] a new instance of InternationalText
2502
+ #
2503
+ # source://chunky_png//lib/chunky_png/chunk.rb#410
2504
+ def initialize(keyword, text, language_tag = T.unsafe(nil), translated_keyword = T.unsafe(nil), compressed = T.unsafe(nil), compression = T.unsafe(nil)); end
2505
+
2506
+ # Returns the value of attribute compressed.
2507
+ #
2508
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2509
+ def compressed; end
2510
+
2511
+ # Sets the attribute compressed
2512
+ #
2513
+ # @param value the value to set the attribute compressed to.
2514
+ #
2515
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2516
+ def compressed=(_arg0); end
2517
+
2518
+ # Returns the value of attribute compression.
2519
+ #
2520
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2521
+ def compression; end
2522
+
2523
+ # Sets the attribute compression
2524
+ #
2525
+ # @param value the value to set the attribute compression to.
2526
+ #
2527
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2528
+ def compression=(_arg0); end
2529
+
2530
+ # Assembles the content to write to the stream for this chunk.
2531
+ #
2532
+ # @return [String] The binary content that should be written to the datastream.
2533
+ #
2534
+ # source://chunky_png//lib/chunky_png/chunk.rb#445
2535
+ def content; end
2536
+
2537
+ # Returns the value of attribute keyword.
2538
+ #
2539
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2540
+ def keyword; end
2541
+
2542
+ # Sets the attribute keyword
2543
+ #
2544
+ # @param value the value to set the attribute keyword to.
2545
+ #
2546
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2547
+ def keyword=(_arg0); end
2548
+
2549
+ # Returns the value of attribute language_tag.
2550
+ #
2551
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2552
+ def language_tag; end
2553
+
2554
+ # Sets the attribute language_tag
2555
+ #
2556
+ # @param value the value to set the attribute language_tag to.
2557
+ #
2558
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2559
+ def language_tag=(_arg0); end
2560
+
2561
+ # Returns the value of attribute text.
2562
+ #
2563
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2564
+ def text; end
2565
+
2566
+ # Sets the attribute text
2567
+ #
2568
+ # @param value the value to set the attribute text to.
2569
+ #
2570
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2571
+ def text=(_arg0); end
2572
+
2573
+ # Returns the value of attribute translated_keyword.
2574
+ #
2575
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2576
+ def translated_keyword; end
2577
+
2578
+ # Sets the attribute translated_keyword
2579
+ #
2580
+ # @param value the value to set the attribute translated_keyword to.
2581
+ #
2582
+ # source://chunky_png//lib/chunky_png/chunk.rb#408
2583
+ def translated_keyword=(_arg0); end
2584
+
2585
+ class << self
2586
+ # Reads the iTXt chunk.
2587
+ #
2588
+ # @param type [String] The four character chunk type indicator (= "iTXt").
2589
+ # @param content [String] The content read from the chunk.
2590
+ # @raise [ChunkyPNG::InvalidUTF8] If the chunk contains data that is not UTF8-encoded text.
2591
+ # @raise [ChunkyPNG::NotSupported] If the chunk refers to an unsupported compression method.
2592
+ # Currently uncompressed data and deflate are supported.
2593
+ # @return [ChunkyPNG::Chunk::InternationalText] The new End chunk instance.
2594
+ #
2595
+ # source://chunky_png//lib/chunky_png/chunk.rb#427
2596
+ def read(type, content); end
2597
+ end
2598
+ end
2599
+
2600
+ # The Palette (PLTE) chunk contains the image's palette, i.e. the
2601
+ # 8-bit RGB colors this image is using.
2602
+ #
2603
+ # @see https://www.w3.org/TR/PNG/#11PLTE
2604
+ # @see ChunkyPNG::Chunk::Transparency
2605
+ # @see ChunkyPNG::Palette
2606
+ #
2607
+ # source://chunky_png//lib/chunky_png/chunk.rb#205
2608
+ class ChunkyPNG::Chunk::Palette < ::ChunkyPNG::Chunk::Generic; end
2609
+
2610
+ # The Physical (pHYs) chunk specifies the intended pixel size or aspect
2611
+ # ratio for display of the image.
2612
+ #
2613
+ # @see https://www.w3.org/TR/PNG/#11pHYs
2614
+ #
2615
+ # source://chunky_png//lib/chunky_png/chunk.rb#362
2616
+ class ChunkyPNG::Chunk::Physical < ::ChunkyPNG::Chunk::Base
2617
+ # @raise [ArgumentError]
2618
+ # @return [Physical] a new instance of Physical
2619
+ #
2620
+ # source://chunky_png//lib/chunky_png/chunk.rb#365
2621
+ def initialize(ppux, ppuy, unit = T.unsafe(nil)); end
2622
+
2623
+ # Assembles the content to write to the stream for this chunk.
2624
+ #
2625
+ # @return [String] The binary content that should be written to the datastream.
2626
+ #
2627
+ # source://chunky_png//lib/chunky_png/chunk.rb#389
2628
+ def content; end
2629
+
2630
+ # @raise [ChunkyPNG::UnitsUnknown]
2631
+ #
2632
+ # source://chunky_png//lib/chunky_png/chunk.rb#371
2633
+ def dpix; end
2634
+
2635
+ # @raise [ChunkyPNG::UnitsUnknown]
2636
+ #
2637
+ # source://chunky_png//lib/chunky_png/chunk.rb#376
2638
+ def dpiy; end
2639
+
2640
+ # Returns the value of attribute ppux.
2641
+ #
2642
+ # source://chunky_png//lib/chunky_png/chunk.rb#363
2643
+ def ppux; end
2644
+
2645
+ # Sets the attribute ppux
2646
+ #
2647
+ # @param value the value to set the attribute ppux to.
2648
+ #
2649
+ # source://chunky_png//lib/chunky_png/chunk.rb#363
2650
+ def ppux=(_arg0); end
2651
+
2652
+ # Returns the value of attribute ppuy.
2653
+ #
2654
+ # source://chunky_png//lib/chunky_png/chunk.rb#363
2655
+ def ppuy; end
2656
+
2657
+ # Sets the attribute ppuy
2658
+ #
2659
+ # @param value the value to set the attribute ppuy to.
2660
+ #
2661
+ # source://chunky_png//lib/chunky_png/chunk.rb#363
2662
+ def ppuy=(_arg0); end
2663
+
2664
+ # Returns the value of attribute unit.
2665
+ #
2666
+ # source://chunky_png//lib/chunky_png/chunk.rb#363
2667
+ def unit; end
2668
+
2669
+ # Sets the attribute unit
2670
+ #
2671
+ # @param value the value to set the attribute unit to.
2672
+ #
2673
+ # source://chunky_png//lib/chunky_png/chunk.rb#363
2674
+ def unit=(_arg0); end
2675
+
2676
+ class << self
2677
+ # source://chunky_png//lib/chunky_png/chunk.rb#381
2678
+ def read(type, content); end
2679
+ end
2680
+ end
2681
+
2682
+ # source://chunky_png//lib/chunky_png/chunk.rb#393
2683
+ ChunkyPNG::Chunk::Physical::INCHES_PER_METER = T.let(T.unsafe(nil), Float)
2684
+
2685
+ # The Text (tEXt) chunk contains keyword/value metadata about the PNG
2686
+ # stream. In this chunk, the value is stored uncompressed.
2687
+ #
2688
+ # The tEXt chunk only supports Latin-1 encoded textual data. If you need
2689
+ # UTF-8 support, check out the InternationalText chunk type.
2690
+ #
2691
+ # @see https://www.w3.org/TR/PNG/#11tEXt
2692
+ # @see ChunkyPNG::Chunk::CompressedText
2693
+ # @see ChunkyPNG::Chunk::InternationalText
2694
+ #
2695
+ # source://chunky_png//lib/chunky_png/chunk.rb#302
2696
+ class ChunkyPNG::Chunk::Text < ::ChunkyPNG::Chunk::Base
2697
+ # @return [Text] a new instance of Text
2698
+ #
2699
+ # source://chunky_png//lib/chunky_png/chunk.rb#305
2700
+ def initialize(keyword, value); end
2701
+
2702
+ # Creates the content to write to the stream, by concatenating the
2703
+ # keyword with the value, joined by a null character.
2704
+ #
2705
+ # @return The content that should be written to the datastream.
2706
+ #
2707
+ # source://chunky_png//lib/chunky_png/chunk.rb#319
2708
+ def content; end
2709
+
2710
+ # Returns the value of attribute keyword.
2711
+ #
2712
+ # source://chunky_png//lib/chunky_png/chunk.rb#303
2713
+ def keyword; end
2714
+
2715
+ # Sets the attribute keyword
2716
+ #
2717
+ # @param value the value to set the attribute keyword to.
2718
+ #
2719
+ # source://chunky_png//lib/chunky_png/chunk.rb#303
2720
+ def keyword=(_arg0); end
2721
+
2722
+ # Returns the value of attribute value.
2723
+ #
2724
+ # source://chunky_png//lib/chunky_png/chunk.rb#303
2725
+ def value; end
2726
+
2727
+ # Sets the attribute value
2728
+ #
2729
+ # @param value the value to set the attribute value to.
2730
+ #
2731
+ # source://chunky_png//lib/chunky_png/chunk.rb#303
2732
+ def value=(_arg0); end
2733
+
2734
+ class << self
2735
+ # source://chunky_png//lib/chunky_png/chunk.rb#310
2736
+ def read(type, content); end
2737
+ end
2738
+ end
2739
+
2740
+ # A transparency (tRNS) chunk defines the transparency for an image.
2741
+ #
2742
+ # * For indexed images, it contains the alpha channel for the colors
2743
+ # defined in the Palette (PLTE) chunk.
2744
+ # * For grayscale images, it contains the grayscale teint that should be
2745
+ # considered fully transparent.
2746
+ # * For truecolor images, it contains the color that should be considered
2747
+ # fully transparent.
2748
+ #
2749
+ # Images having a color mode that already includes an alpha channel, this
2750
+ # chunk should not be included.
2751
+ #
2752
+ # @see https://www.w3.org/TR/PNG/#11tRNS
2753
+ # @see ChunkyPNG::Chunk::Palette
2754
+ # @see ChunkyPNG::Palette
2755
+ #
2756
+ # source://chunky_png//lib/chunky_png/chunk.rb#230
2757
+ class ChunkyPNG::Chunk::Transparency < ::ChunkyPNG::Chunk::Generic
2758
+ # Returns the grayscale entry to be replaced by transparent pixels.
2759
+ #
2760
+ # This method should only be used for images having color mode
2761
+ # ChunkyPNG::COLOR_GRAYSCALE (0).
2762
+ #
2763
+ # @return [Integer] The (grayscale) color to replace with fully
2764
+ # transparent pixels.
2765
+ #
2766
+ # source://chunky_png//lib/chunky_png/chunk.rb#254
2767
+ def grayscale_entry(bit_depth); end
2768
+
2769
+ # Returns the alpha channel for the palette of an indexed image.
2770
+ #
2771
+ # This method should only be used for images having color mode
2772
+ # ChunkyPNG::COLOR_INDEXED (3).
2773
+ #
2774
+ # @return [Array<Integer>] Returns an array of alpha channel values
2775
+ # [0-255].
2776
+ #
2777
+ # source://chunky_png//lib/chunky_png/chunk.rb#231
2778
+ def palette_alpha_channel; end
2779
+
2780
+ # Returns the truecolor entry to be replaced by transparent pixels,
2781
+ #
2782
+ # This method should only be used for images having color mode
2783
+ # ChunkyPNG::COLOR_TRUECOLOR (2).
2784
+ #
2785
+ # @return [Integer] The color to replace with fully transparent pixels.
2786
+ #
2787
+ # source://chunky_png//lib/chunky_png/chunk.rb#241
2788
+ def truecolor_entry(bit_depth); end
2789
+ end
2790
+
2791
+ # The Color module defines methods for handling colors. Within the ChunkyPNG
2792
+ # library, the concepts of pixels and colors are both used, and they are
2793
+ # both represented by a Integer.
2794
+ #
2795
+ # Pixels/colors are represented in RGBA components. Each of the four
2796
+ # components is stored with a depth of 8 bits (maximum value = 255 =
2797
+ # {ChunkyPNG::Color::MAX}). Together, these components are stored in a 4-byte
2798
+ # Integer.
2799
+ #
2800
+ # A color will always be represented using these 4 components in memory.
2801
+ # When the image is encoded, a more suitable representation can be used
2802
+ # (e.g. rgb, grayscale, palette-based), for which several conversion methods
2803
+ # are provided in this module.
2804
+ #
2805
+ # source://chunky_png//lib/chunky_png/color.rb#57
2806
+ module ChunkyPNG::Color
2807
+ extend ::ChunkyPNG::Color
2808
+
2809
+ # Returns the alpha channel value for the color value.
2810
+ #
2811
+ # @param value [Integer] The color value.
2812
+ # @return [Integer] A value between 0 and MAX.
2813
+ #
2814
+ # source://chunky_png//lib/chunky_png/color.rb#299
2815
+ def a(value); end
2816
+
2817
+ # Checks whether an alpha channel value can successfully be composed
2818
+ # given the resulting color, the mask color and a background color,
2819
+ # all of which should be opaque.
2820
+ #
2821
+ # @param color [Integer] The color that was the result of compositing.
2822
+ # @param mask [Integer] The opaque variant of the color that was being
2823
+ # composed
2824
+ # @param bg [Integer] The background color on which the color was composed.
2825
+ # @param tolerance [Integer] The decomposition tolerance level, a value
2826
+ # between 0 and 255.
2827
+ # @return [Boolean] True if the alpha component can be decomposed
2828
+ # successfully.
2829
+ # @see #decompose_alpha
2830
+ #
2831
+ # source://chunky_png//lib/chunky_png/color.rb#503
2832
+ def alpha_decomposable?(color, mask, bg, tolerance = T.unsafe(nil)); end
2833
+
2834
+ # Returns the blue-component from the color value.
2835
+ #
2836
+ # @param value [Integer] The color value.
2837
+ # @return [Integer] A value between 0 and MAX.
2838
+ #
2839
+ # source://chunky_png//lib/chunky_png/color.rb#291
2840
+ def b(value); end
2841
+
2842
+ # Blends the foreground and background color by taking the average of
2843
+ # the components.
2844
+ #
2845
+ # @param fg [Integer] The foreground color.
2846
+ # @param bg [Integer] The foreground color.
2847
+ # @return [Integer] The blended color.
2848
+ #
2849
+ # source://chunky_png//lib/chunky_png/color.rb#406
2850
+ def blend(fg, bg); end
2851
+
2852
+ # Composes two colors with an alpha channel using integer math.
2853
+ #
2854
+ # This version is faster than the version based on floating point math, so
2855
+ # this compositing function is used by default.
2856
+ #
2857
+ # @param fg [Integer] The foreground color.
2858
+ # @param bg [Integer] The background color.
2859
+ # @return [Integer] The composited color.
2860
+ # @see ChunkyPNG::Color#compose_precise
2861
+ #
2862
+ # source://chunky_png//lib/chunky_png/color.rb#361
2863
+ def compose(fg, bg); end
2864
+
2865
+ # Composes two colors with an alpha channel using floating point math.
2866
+ #
2867
+ # This method uses more precise floating point math, but this precision is
2868
+ # lost when the result is converted back to an integer. Because it is
2869
+ # slower than the version based on integer math, that version is preferred.
2870
+ #
2871
+ # @param fg [Integer] The foreground color.
2872
+ # @param bg [Integer] The background color.
2873
+ # @return [Integer] The composited color.
2874
+ # @see ChunkyPNG::Color#compose_quick
2875
+ #
2876
+ # source://chunky_png//lib/chunky_png/color.rb#383
2877
+ def compose_precise(fg, bg); end
2878
+
2879
+ # Composes two colors with an alpha channel using integer math.
2880
+ #
2881
+ # This version is faster than the version based on floating point math, so
2882
+ # this compositing function is used by default.
2883
+ #
2884
+ # @param fg [Integer] The foreground color.
2885
+ # @param bg [Integer] The background color.
2886
+ # @return [Integer] The composited color.
2887
+ # @see ChunkyPNG::Color#compose_precise
2888
+ #
2889
+ # source://chunky_png//lib/chunky_png/color.rb#361
2890
+ def compose_quick(fg, bg); end
2891
+
2892
+ # Decomposes the alpha channel value given the resulting color, the mask
2893
+ # color and a background color, all of which should be opaque.
2894
+ #
2895
+ # Make sure to call {#alpha_decomposable?} first to see if the alpha
2896
+ # channel value can successfully decomposed with a given tolerance,
2897
+ # otherwise the return value of this method is undefined.
2898
+ #
2899
+ # @param color [Integer] The color that was the result of compositing.
2900
+ # @param mask [Integer] The opaque variant of the color that was being
2901
+ # composed
2902
+ # @param bg [Integer] The background color on which the color was composed.
2903
+ # @return [Integer] The best fitting alpha channel, a value between 0 and
2904
+ # 255.
2905
+ # @see #alpha_decomposable?
2906
+ #
2907
+ # source://chunky_png//lib/chunky_png/color.rb#524
2908
+ def decompose_alpha(color, mask, bg); end
2909
+
2910
+ # Decomposes an alpha channel for either the r, g or b color channel.
2911
+ #
2912
+ # @param channel [:r, :g, :b] The channel to decompose the alpha channel
2913
+ # from.
2914
+ # @param color [Integer] The color that was the result of compositing.
2915
+ # @param mask [Integer] The opaque variant of the color that was being
2916
+ # composed
2917
+ # @param bg [Integer] The background color on which the color was composed.
2918
+ # @return [Integer] The decomposed alpha value for the channel.
2919
+ #
2920
+ # source://chunky_png//lib/chunky_png/color.rb#537
2921
+ def decompose_alpha_component(channel, color, mask, bg); end
2922
+
2923
+ # Decomposes the alpha channels for the r, g and b color channel.
2924
+ #
2925
+ # @param color [Integer] The color that was the result of compositing.
2926
+ # @param mask [Integer] The opaque variant of the color that was being
2927
+ # composed
2928
+ # @param bg [Integer] The background color on which the color was composed.
2929
+ # @return [Array<Integer>] The decomposed alpha values for the r, g and b
2930
+ # channels.
2931
+ #
2932
+ # source://chunky_png//lib/chunky_png/color.rb#554
2933
+ def decompose_alpha_components(color, mask, bg); end
2934
+
2935
+ # Decomposes a color, given a color, a mask color and a background color.
2936
+ # The returned color will be a variant of the mask color, with the alpha
2937
+ # channel set to the best fitting value. This basically is the reverse
2938
+ # operation if alpha composition.
2939
+ #
2940
+ # If the color cannot be decomposed, this method will return the fully
2941
+ # transparent variant of the mask color.
2942
+ #
2943
+ # @param color [Integer] The color that was the result of compositing.
2944
+ # @param mask [Integer] The opaque variant of the color that was being
2945
+ # composed
2946
+ # @param bg [Integer] The background color on which the color was composed.
2947
+ # @param tolerance [Integer] The decomposition tolerance level, a value
2948
+ # between 0 and 255.
2949
+ # @return [Integer] The decomposed color, a variant of the masked color
2950
+ # with the alpha channel set to an appropriate value.
2951
+ #
2952
+ # source://chunky_png//lib/chunky_png/color.rb#482
2953
+ def decompose_color(color, mask, bg, tolerance = T.unsafe(nil)); end
2954
+
2955
+ # Compute the Euclidean distance between 2 colors in RGBA
2956
+ #
2957
+ # This method simply takes the Euclidean distance between the RGBA channels
2958
+ # of 2 colors, which gives us a measure of how different the two colors
2959
+ # are.
2960
+ #
2961
+ # Although it would be more perceptually accurate to calculate a proper
2962
+ # Delta E in Lab colorspace, this method should serve many use-cases while
2963
+ # avoiding the overhead of converting RGBA to Lab.
2964
+ #
2965
+ # @param pixel_after [Integer]
2966
+ # @param pixel_before [Integer]
2967
+ # @return [Float]
2968
+ #
2969
+ # source://chunky_png//lib/chunky_png/color.rb#722
2970
+ def euclidean_distance_rgba(pixel_after, pixel_before); end
2971
+
2972
+ # Lowers the intensity of a color, by lowering its alpha by a given factor.
2973
+ #
2974
+ # @param color [Integer] The color to adjust.
2975
+ # @param factor [Integer] Fade factor as an integer between 0 and 255.
2976
+ # @return [Integer] The faded color.
2977
+ #
2978
+ # source://chunky_png//lib/chunky_png/color.rb#461
2979
+ def fade(color, factor); end
2980
+
2981
+ # Creates a color by converting it from a string in hex notation.
2982
+ #
2983
+ # It supports colors with (#rrggbbaa) or without (#rrggbb) alpha channel
2984
+ # as well as the 3-digit short format (#rgb) for those without.
2985
+ # Color strings may include the prefix "0x" or "#".
2986
+ #
2987
+ # @param hex_value [String] The color in hex notation.
2988
+ # @param opacity [Integer] The opacity value for the color. Overrides any
2989
+ # opacity value given in the hex value if given.
2990
+ # @raise [ArgumentError] if the value given is not a hex color notation.
2991
+ # @return [Integer] The color value.
2992
+ #
2993
+ # source://chunky_png//lib/chunky_png/color.rb#167
2994
+ def from_hex(hex_value, opacity = T.unsafe(nil)); end
2995
+
2996
+ # Creates a new color from an HSV triple.
2997
+ #
2998
+ # Create a new color using an HSV (sometimes also called HSB) triple. The
2999
+ # words `value` and `brightness` are used interchangeably and synonymously
3000
+ # in descriptions of this colorspace. This implementation follows the modern
3001
+ # convention of 0 degrees hue indicating red.
3002
+ #
3003
+ # @param hue [Fixnum] The hue component (0-360)
3004
+ # @param saturation [Fixnum] The saturation component (0-1)
3005
+ # @param value [Fixnum] The value (brightness) component (0-1)
3006
+ # @param alpha [Fixnum] Defaults to opaque (255).
3007
+ # @raise [ArgumentError] if the hsv triple is invalid.
3008
+ # @return [Integer] The newly constructed color value.
3009
+ # @see https://en.wikipedia.org/wiki/HSL_and_HSV
3010
+ #
3011
+ # source://chunky_png//lib/chunky_png/color.rb#194
3012
+ def from_hsb(hue, saturation, value, alpha = T.unsafe(nil)); end
3013
+
3014
+ # Creates a new color from an HSL triple.
3015
+ #
3016
+ # This implementation follows the modern convention of 0 degrees hue
3017
+ # indicating red.
3018
+ #
3019
+ # @param hue [Fixnum] The hue component (0-360)
3020
+ # @param saturation [Fixnum] The saturation component (0-1)
3021
+ # @param lightness [Fixnum] The lightness component (0-1)
3022
+ # @param alpha [Fixnum] Defaults to opaque (255).
3023
+ # @raise [ArgumentError] if the hsl triple is invalid.
3024
+ # @return [Integer] The newly constructed color value.
3025
+ # @see https://en.wikipedia.org/wiki/HSL_and_HSV
3026
+ #
3027
+ # source://chunky_png//lib/chunky_png/color.rb#220
3028
+ def from_hsl(hue, saturation, lightness, alpha = T.unsafe(nil)); end
3029
+
3030
+ # Creates a new color from an HSV triple.
3031
+ #
3032
+ # Create a new color using an HSV (sometimes also called HSB) triple. The
3033
+ # words `value` and `brightness` are used interchangeably and synonymously
3034
+ # in descriptions of this colorspace. This implementation follows the modern
3035
+ # convention of 0 degrees hue indicating red.
3036
+ #
3037
+ # @param hue [Fixnum] The hue component (0-360)
3038
+ # @param saturation [Fixnum] The saturation component (0-1)
3039
+ # @param value [Fixnum] The value (brightness) component (0-1)
3040
+ # @param alpha [Fixnum] Defaults to opaque (255).
3041
+ # @raise [ArgumentError] if the hsv triple is invalid.
3042
+ # @return [Integer] The newly constructed color value.
3043
+ # @see https://en.wikipedia.org/wiki/HSL_and_HSV
3044
+ #
3045
+ # source://chunky_png//lib/chunky_png/color.rb#194
3046
+ def from_hsv(hue, saturation, value, alpha = T.unsafe(nil)); end
3047
+
3048
+ # Creates a color by unpacking an rgb triple from a string.
3049
+ #
3050
+ # @param stream [String] The string to load the color from. It should be
3051
+ # at least 3 + pos bytes long.
3052
+ # @param pos [Integer] The position in the string to load the triple from.
3053
+ # @return [Integer] The newly constructed color value.
3054
+ #
3055
+ # source://chunky_png//lib/chunky_png/color.rb#142
3056
+ def from_rgb_stream(stream, pos = T.unsafe(nil)); end
3057
+
3058
+ # Creates a color by unpacking an rgba triple from a string
3059
+ #
3060
+ # @param stream [String] The string to load the color from. It should be
3061
+ # at least 4 + pos bytes long.
3062
+ # @param pos [Integer] The position in the string to load the triple from.
3063
+ # @return [Integer] The newly constructed color value.
3064
+ #
3065
+ # source://chunky_png//lib/chunky_png/color.rb#152
3066
+ def from_rgba_stream(stream, pos = T.unsafe(nil)); end
3067
+
3068
+ # Returns true if this color is fully transparent.
3069
+ #
3070
+ # @param value [Integer] The color to test.
3071
+ # @return [true, false] True if the alpha channel equals 0.
3072
+ #
3073
+ # source://chunky_png//lib/chunky_png/color.rb#330
3074
+ def fully_transparent?(value); end
3075
+
3076
+ # Returns the green-component from the color value.
3077
+ #
3078
+ # @param value [Integer] The color value.
3079
+ # @return [Integer] A value between 0 and MAX.
3080
+ #
3081
+ # source://chunky_png//lib/chunky_png/color.rb#283
3082
+ def g(value); end
3083
+
3084
+ # Creates a new color using a grayscale teint.
3085
+ #
3086
+ # @param teint [Integer] The grayscale teint (0-255), will be used as r, g,
3087
+ # and b value.
3088
+ # @return [Integer] The newly constructed color value.
3089
+ #
3090
+ # source://chunky_png//lib/chunky_png/color.rb#119
3091
+ def grayscale(teint); end
3092
+
3093
+ # Returns true if this color is fully transparent.
3094
+ #
3095
+ # @param value [Integer] The color to test.
3096
+ # @return [true, false] True if the r, g and b component are equal.
3097
+ #
3098
+ # source://chunky_png//lib/chunky_png/color.rb#322
3099
+ def grayscale?(value); end
3100
+
3101
+ # Creates a new color using a grayscale teint and alpha value.
3102
+ #
3103
+ # @param teint [Integer] The grayscale teint (0-255), will be used as r, g,
3104
+ # and b value.
3105
+ # @param a [Integer] The opacity (0-255)
3106
+ # @return [Integer] The newly constructed color value.
3107
+ #
3108
+ # source://chunky_png//lib/chunky_png/color.rb#128
3109
+ def grayscale_alpha(teint, a); end
3110
+
3111
+ # Calculates the grayscale teint of an RGB color.
3112
+ #
3113
+ # @param color [Integer] The color to convert.
3114
+ # @return [Integer] The grayscale teint of the input color, 0-255.
3115
+ #
3116
+ # source://chunky_png//lib/chunky_png/color.rb#438
3117
+ def grayscale_teint(color); end
3118
+
3119
+ # Gets a color value based on a HTML color name.
3120
+ #
3121
+ # The color name is flexible. E.g. <tt>'yellowgreen'</tt>, <tt>'Yellow
3122
+ # green'</tt>, <tt>'YellowGreen'</tt>, <tt>'YELLOW_GREEN'</tt> and
3123
+ # <tt>:yellow_green</tt> will all return the same color value.
3124
+ #
3125
+ # You can include a opacity level in the color name (e.g. <tt>'red @
3126
+ # 0.5'</tt>) or give an explicit opacity value as second argument. If no
3127
+ # opacity value is given, the color will be fully opaque.
3128
+ #
3129
+ # @param color_name [Symbol, String] The color name. It may include an
3130
+ # opacity specifier like <tt>@ 0.8</tt> to set the color's opacity.
3131
+ # @param opacity [Integer] The opacity value for the color between 0 and
3132
+ # 255. Overrides any opacity value given in the color name.
3133
+ # @raise [ChunkyPNG::Exception] If the color name was not recognized.
3134
+ # @return [Integer] The color value.
3135
+ #
3136
+ # source://chunky_png//lib/chunky_png/color.rb#909
3137
+ def html_color(color_name, opacity = T.unsafe(nil)); end
3138
+
3139
+ # Multiplies two fractions using integer math, where the fractions are
3140
+ # stored using an integer between 0 and 255. This method is used as a
3141
+ # helper method for compositing colors using integer math.
3142
+ #
3143
+ # This is a quicker implementation of ((a * b) / 255.0).round.
3144
+ #
3145
+ # @param a [Integer] The first fraction.
3146
+ # @param b [Integer] The second fraction.
3147
+ # @return [Integer] The result of the multiplication.
3148
+ #
3149
+ # source://chunky_png//lib/chunky_png/color.rb#347
3150
+ def int8_mult(a, b); end
3151
+
3152
+ # Interpolates the foreground and background colors by the given alpha
3153
+ # value. This also blends the alpha channels themselves.
3154
+ #
3155
+ # A blending factor of 255 will give entirely the foreground,
3156
+ # while a blending factor of 0 will give the background.
3157
+ #
3158
+ # @param fg [Integer] The foreground color.
3159
+ # @param bg [Integer] The background color.
3160
+ # @param alpha [Integer] The blending factor (fixed 8bit)
3161
+ # @return [Integer] The interpolated color.
3162
+ #
3163
+ # source://chunky_png//lib/chunky_png/color.rb#420
3164
+ def interpolate_quick(fg, bg, alpha); end
3165
+
3166
+ # Returns the opaque value of this color by removing the alpha channel.
3167
+ #
3168
+ # @param value [Integer] The color to transform.
3169
+ # @return [Integer] The opaque color
3170
+ #
3171
+ # source://chunky_png//lib/chunky_png/color.rb#314
3172
+ def opaque!(value); end
3173
+
3174
+ # Returns true if this color is fully opaque.
3175
+ #
3176
+ # @param value [Integer] The color to test.
3177
+ # @return [true, false] True if the alpha channel equals MAX.
3178
+ #
3179
+ # source://chunky_png//lib/chunky_png/color.rb#307
3180
+ def opaque?(value); end
3181
+
3182
+ # Parses a color value given a numeric or string argument.
3183
+ #
3184
+ # It supports color numbers, colors in hex notation and named HTML colors.
3185
+ #
3186
+ # @param source [Integer, String] The color value.
3187
+ # @return [Integer] The color value, with the opacity applied if one was
3188
+ # given.
3189
+ #
3190
+ # source://chunky_png//lib/chunky_png/color.rb#86
3191
+ def parse(source); end
3192
+
3193
+ # Returns the number of bytes used for an image pass
3194
+ #
3195
+ # @param color_mode [Integer] The color mode in which the pixels are
3196
+ # stored.
3197
+ # @param depth [Integer] The color depth of the pixels.
3198
+ # @param width [Integer] The width of the image pass.
3199
+ # @param height [Integer] The height of the image pass.
3200
+ # @return [Integer] The number of bytes used per scanline in a datastream.
3201
+ #
3202
+ # source://chunky_png//lib/chunky_png/color.rb#984
3203
+ def pass_bytesize(color_mode, depth, width, height); end
3204
+
3205
+ # Returns the size in bits of a pixel when it is stored using a given color
3206
+ # mode.
3207
+ #
3208
+ # @param color_mode [Integer] The color mode in which the pixels are
3209
+ # stored.
3210
+ # @param depth [Integer] The color depth of the pixels.
3211
+ # @return [Integer] The number of bytes used per pixel in a datastream.
3212
+ #
3213
+ # source://chunky_png//lib/chunky_png/color.rb#963
3214
+ def pixel_bitsize(color_mode, depth = T.unsafe(nil)); end
3215
+
3216
+ # Returns the size in bytes of a pixel when it is stored using a given
3217
+ # color mode.
3218
+ #
3219
+ # @param color_mode [Integer] The color mode in which the pixels are
3220
+ # stored.
3221
+ # @return [Integer] The number of bytes used per pixel in a datastream.
3222
+ #
3223
+ # source://chunky_png//lib/chunky_png/color.rb#951
3224
+ def pixel_bytesize(color_mode, depth = T.unsafe(nil)); end
3225
+
3226
+ # Returns the red-component from the color value.
3227
+ #
3228
+ # @param value [Integer] The color value.
3229
+ # @return [Integer] A value between 0 and MAX.
3230
+ #
3231
+ # source://chunky_png//lib/chunky_png/color.rb#275
3232
+ def r(value); end
3233
+
3234
+ # Creates a new color using an r, g, b triple.
3235
+ #
3236
+ # @param r [Integer] The r-component (0-255)
3237
+ # @param g [Integer] The g-component (0-255)
3238
+ # @param b [Integer] The b-component (0-255)
3239
+ # @return [Integer] The newly constructed color value.
3240
+ #
3241
+ # source://chunky_png//lib/chunky_png/color.rb#111
3242
+ def rgb(r, g, b); end
3243
+
3244
+ # Creates a new color using an r, g, b triple and an alpha value.
3245
+ #
3246
+ # @param r [Integer] The r-component (0-255)
3247
+ # @param g [Integer] The g-component (0-255)
3248
+ # @param b [Integer] The b-component (0-255)
3249
+ # @param a [Integer] The opacity (0-255)
3250
+ # @return [Integer] The newly constructed color value.
3251
+ #
3252
+ # source://chunky_png//lib/chunky_png/color.rb#102
3253
+ def rgba(r, g, b, a); end
3254
+
3255
+ # Returns the number of sample values per pixel.
3256
+ #
3257
+ # @param color_mode [Integer] The color mode being used.
3258
+ # @return [Integer] The number of sample values per pixel.
3259
+ #
3260
+ # source://chunky_png//lib/chunky_png/color.rb#934
3261
+ def samples_per_pixel(color_mode); end
3262
+
3263
+ # Returns the number of bytes used per scanline.
3264
+ #
3265
+ # @param color_mode [Integer] The color mode in which the pixels are
3266
+ # stored.
3267
+ # @param depth [Integer] The color depth of the pixels.
3268
+ # @param width [Integer] The number of pixels per scanline.
3269
+ # @return [Integer] The number of bytes used per scanline in a datastream.
3270
+ #
3271
+ # source://chunky_png//lib/chunky_png/color.rb#973
3272
+ def scanline_bytesize(color_mode, depth, width); end
3273
+
3274
+ # Converts a color to a fiting grayscale value. It will conserve the alpha
3275
+ # channel.
3276
+ #
3277
+ # This method will return a full color value, with the R, G, and B value
3278
+ # set to the grayscale teint calcuated from the input color's R, G and B
3279
+ # values.
3280
+ #
3281
+ # @param color [Integer] The color to convert.
3282
+ # @return [Integer] The input color, converted to the best fitting
3283
+ # grayscale.
3284
+ # @see #grayscale_teint
3285
+ #
3286
+ # source://chunky_png//lib/chunky_png/color.rb#453
3287
+ def to_grayscale(color); end
3288
+
3289
+ # Returns an array with the grayscale teint and alpha channel values for
3290
+ # this color.
3291
+ #
3292
+ # This method expects the color to be grayscale, i.e. r, g, and b value to
3293
+ # be equal and uses only the B channel. If you need to convert a color to
3294
+ # grayscale first, see {#to_grayscale}.
3295
+ #
3296
+ # @param color [Integer] The grayscale color to convert.
3297
+ # @return [Array<Integer>] An array with 2 Integer elements.
3298
+ # @see #to_grayscale
3299
+ #
3300
+ # source://chunky_png//lib/chunky_png/color.rb#701
3301
+ def to_grayscale_alpha_bytes(color); end
3302
+
3303
+ # Returns an array with the grayscale teint value for this color.
3304
+ #
3305
+ # This method expects the r, g, and b value to be equal, and the alpha
3306
+ # channel will be discarded.
3307
+ #
3308
+ # @param color [Integer] The grayscale color to convert.
3309
+ # @return [Array<Integer>] An array with 1 Integer element.
3310
+ #
3311
+ # source://chunky_png//lib/chunky_png/color.rb#687
3312
+ def to_grayscale_bytes(color); end
3313
+
3314
+ # Returns a string representing this color using hex notation (i.e.
3315
+ # #rrggbbaa).
3316
+ #
3317
+ # @param color [Integer] The color to convert.
3318
+ # @param include_alpha [Boolean]
3319
+ # @return [String] The color in hex notation, starting with a pound sign.
3320
+ #
3321
+ # source://chunky_png//lib/chunky_png/color.rb#572
3322
+ def to_hex(color, include_alpha = T.unsafe(nil)); end
3323
+
3324
+ # Returns an array with the separate HSV components of a color.
3325
+ #
3326
+ # Because ChunkyPNG internally handles colors as Integers for performance
3327
+ # reasons, some rounding occurs when importing or exporting HSV colors
3328
+ # whose coordinates are float-based. Because of this rounding, #to_hsv and
3329
+ # #from_hsv may not be perfect inverses.
3330
+ #
3331
+ # This implementation follows the modern convention of 0 degrees hue
3332
+ # indicating red.
3333
+ #
3334
+ # @param color [Integer] The ChunkyPNG color to convert.
3335
+ # @param include_alpha [Boolean] Flag indicates whether a fourth element
3336
+ # representing alpha channel should be included in the returned array.
3337
+ # @return [Array[0]] The hue of the color (0-360)
3338
+ # @return [Array[1]] The saturation of the color (0-1)
3339
+ # @return [Array[2]] The value of the color (0-1)
3340
+ # @return [Array[3]] Optional fourth element for alpha, included if
3341
+ # include_alpha=true (0-255)
3342
+ # @see https://en.wikipedia.org/wiki/HSL_and_HSV
3343
+ #
3344
+ # source://chunky_png//lib/chunky_png/color.rb#595
3345
+ def to_hsb(color, include_alpha = T.unsafe(nil)); end
3346
+
3347
+ # Returns an array with the separate HSL components of a color.
3348
+ #
3349
+ # Because ChunkyPNG internally handles colors as Integers for performance
3350
+ # reasons, some rounding occurs when importing or exporting HSL colors
3351
+ # whose coordinates are float-based. Because of this rounding, #to_hsl and
3352
+ # #from_hsl may not be perfect inverses.
3353
+ #
3354
+ # This implementation follows the modern convention of 0 degrees hue indicating red.
3355
+ #
3356
+ # @param color [Integer] The ChunkyPNG color to convert.
3357
+ # @param include_alpha [Boolean] Flag indicates whether a fourth element
3358
+ # representing alpha channel should be included in the returned array.
3359
+ # @return [Array<Fixnum>[0]] The hue of the color (0-360)
3360
+ # @return [Array<Fixnum>[1]] The saturation of the color (0-1)
3361
+ # @return [Array<Fixnum>[2]] The lightness of the color (0-1)
3362
+ # @return [Array<Fixnum>[3]] Optional fourth element for alpha, included if
3363
+ # include_alpha=true (0-255)
3364
+ # @see https://en.wikipedia.org/wiki/HSL_and_HSV
3365
+ #
3366
+ # source://chunky_png//lib/chunky_png/color.rb#624
3367
+ def to_hsl(color, include_alpha = T.unsafe(nil)); end
3368
+
3369
+ # Returns an array with the separate HSV components of a color.
3370
+ #
3371
+ # Because ChunkyPNG internally handles colors as Integers for performance
3372
+ # reasons, some rounding occurs when importing or exporting HSV colors
3373
+ # whose coordinates are float-based. Because of this rounding, #to_hsv and
3374
+ # #from_hsv may not be perfect inverses.
3375
+ #
3376
+ # This implementation follows the modern convention of 0 degrees hue
3377
+ # indicating red.
3378
+ #
3379
+ # @param color [Integer] The ChunkyPNG color to convert.
3380
+ # @param include_alpha [Boolean] Flag indicates whether a fourth element
3381
+ # representing alpha channel should be included in the returned array.
3382
+ # @return [Array[0]] The hue of the color (0-360)
3383
+ # @return [Array[1]] The saturation of the color (0-1)
3384
+ # @return [Array[2]] The value of the color (0-1)
3385
+ # @return [Array[3]] Optional fourth element for alpha, included if
3386
+ # include_alpha=true (0-255)
3387
+ # @see https://en.wikipedia.org/wiki/HSL_and_HSV
3388
+ #
3389
+ # source://chunky_png//lib/chunky_png/color.rb#595
3390
+ def to_hsv(color, include_alpha = T.unsafe(nil)); end
3391
+
3392
+ # Returns an array with the separate RGBA values for this color.
3393
+ #
3394
+ # @param color [Integer] The color to convert.
3395
+ # @return [Array<Integer>] An array with 4 Integer elements.
3396
+ #
3397
+ # source://chunky_png//lib/chunky_png/color.rb#667
3398
+ def to_truecolor_alpha_bytes(color); end
3399
+
3400
+ # Returns an array with the separate RGB values for this color. The alpha
3401
+ # channel will be discarded.
3402
+ #
3403
+ # @param color [Integer] The color to convert.
3404
+ # @return [Array<Integer>] An array with 3 Integer elements.
3405
+ #
3406
+ # source://chunky_png//lib/chunky_png/color.rb#676
3407
+ def to_truecolor_bytes(color); end
3408
+
3409
+ private
3410
+
3411
+ # Convert one HSL or HSV triple and associated chroma to a scaled rgb triple
3412
+ #
3413
+ # This method encapsulates the shared mathematical operations needed to
3414
+ # convert coordinates from a cylindrical colorspace such as HSL or HSV into
3415
+ # coordinates of the RGB colorspace.
3416
+ #
3417
+ # Even though chroma values are derived from the other three coordinates,
3418
+ # the formula for calculating chroma differs for each colorspace. Since it
3419
+ # is calculated differently for each colorspace, it must be passed in as
3420
+ # a parameter.
3421
+ #
3422
+ # @param hue [Fixnum] The hue-component (0-360)
3423
+ # @param saturation [Fixnum] The saturation-component (0-1)
3424
+ # @param y_component [Fixnum] The y_component can represent either lightness
3425
+ # or brightness/value (0-1) depending on which scheme (HSV/HSL) is being used.
3426
+ # @param chroma [Fixnum] The associated chroma value.
3427
+ # @private
3428
+ # @return [Array<Fixnum>] A scaled r,g,b triple. Scheme-dependent
3429
+ # adjustments are still needed to reach the true r,g,b values.
3430
+ # @see https://en.wikipedia.org/wiki/HSL_and_HSV
3431
+ #
3432
+ # source://chunky_png//lib/chunky_png/color.rb#252
3433
+ def cylindrical_to_cubic(hue, saturation, y_component, chroma); end
3434
+
3435
+ # This method encapsulates the logic needed to extract hue and chroma from
3436
+ # a ChunkPNG color. This logic is shared by the cylindrical HSV/HSB and HSL
3437
+ # color space models.
3438
+ #
3439
+ # @param color [Integer] A ChunkyPNG color.
3440
+ # @private
3441
+ # @return [Fixnum] hue The hue of the color (0-360)
3442
+ # @return [Fixnum] chroma The chroma of the color (0-1)
3443
+ # @return [Fixnum] max The magnitude of the largest scaled rgb component (0-1)
3444
+ # @return [Fixnum] min The magnitude of the smallest scaled rgb component (0-1)
3445
+ #
3446
+ # source://chunky_png//lib/chunky_png/color.rb#643
3447
+ def hue_and_chroma(color); end
3448
+ end
3449
+
3450
+ # @return [Integer] Black pixel/color
3451
+ #
3452
+ # source://chunky_png//lib/chunky_png/color.rb#919
3453
+ ChunkyPNG::Color::BLACK = T.let(T.unsafe(nil), Integer)
3454
+
3455
+ # @private
3456
+ # @return [Regexp] The regexp to parse 3-digit hex color values.
3457
+ #
3458
+ # source://chunky_png//lib/chunky_png/color.rb#65
3459
+ ChunkyPNG::Color::HEX3_COLOR_REGEXP = T.let(T.unsafe(nil), Regexp)
3460
+
3461
+ # @private
3462
+ # @return [Regexp] The regexp to parse 6- and 8-digit hex color values.
3463
+ #
3464
+ # source://chunky_png//lib/chunky_png/color.rb#69
3465
+ ChunkyPNG::Color::HEX6_COLOR_REGEXP = T.let(T.unsafe(nil), Regexp)
3466
+
3467
+ # @private
3468
+ # @return [Regexp] The regexp to parse named color values.
3469
+ #
3470
+ # source://chunky_png//lib/chunky_png/color.rb#73
3471
+ ChunkyPNG::Color::HTML_COLOR_REGEXP = T.let(T.unsafe(nil), Regexp)
3472
+
3473
+ # @return [Integer] The maximum value of each color component.
3474
+ #
3475
+ # source://chunky_png//lib/chunky_png/color.rb#61
3476
+ ChunkyPNG::Color::MAX = T.let(T.unsafe(nil), Integer)
3477
+
3478
+ # Could be simplified as MAX * 2, but this format mirrors the math in
3479
+ # {#euclidean_distance_rgba}
3480
+ #
3481
+ # @return [Float] The maximum Euclidean distance of two RGBA colors.
3482
+ #
3483
+ # source://chunky_png//lib/chunky_png/color.rb#736
3484
+ ChunkyPNG::Color::MAX_EUCLIDEAN_DISTANCE_RGBA = T.let(T.unsafe(nil), Float)
3485
+
3486
+ # @return [Hash<Symbol, Integer>] All the predefined color names in HTML.
3487
+ #
3488
+ # source://chunky_png//lib/chunky_png/color.rb#743
3489
+ ChunkyPNG::Color::PREDEFINED_COLORS = T.let(T.unsafe(nil), Hash)
3490
+
3491
+ # @return [Integer] Fully transparent pixel/color
3492
+ #
3493
+ # source://chunky_png//lib/chunky_png/color.rb#925
3494
+ ChunkyPNG::Color::TRANSPARENT = T.let(T.unsafe(nil), Integer)
3495
+
3496
+ # @return [Integer] White pixel/color
3497
+ #
3498
+ # source://chunky_png//lib/chunky_png/color.rb#922
3499
+ ChunkyPNG::Color::WHITE = T.let(T.unsafe(nil), Integer)
3500
+
3501
+ # The Datastream class represents a PNG formatted datastream. It supports
3502
+ # both reading from and writing to strings, streams and files.
3503
+ #
3504
+ # A PNG datastream begins with the PNG signature, and then contains multiple
3505
+ # chunks, starting with a header (IHDR) chunk and finishing with an end
3506
+ # (IEND) chunk.
3507
+ #
3508
+ # @see ChunkyPNG::Chunk
3509
+ #
3510
+ # source://chunky_png//lib/chunky_png/datastream.rb#12
3511
+ class ChunkyPNG::Datastream
3512
+ # Initializes a new Datastream instance.
3513
+ #
3514
+ # @return [Datastream] a new instance of Datastream
3515
+ #
3516
+ # source://chunky_png//lib/chunky_png/datastream.rb#45
3517
+ def initialize; end
3518
+
3519
+ # Returns an enumerator instance for this datastream's chunks.
3520
+ #
3521
+ # @return [Enumerable::Enumerator] An enumerator for the :each_chunk method.
3522
+ # @see ChunkyPNG::Datastream#each_chunk
3523
+ #
3524
+ # source://chunky_png//lib/chunky_png/datastream.rb#137
3525
+ def chunks; end
3526
+
3527
+ # The chunks that together compose the images pixel data.
3528
+ #
3529
+ # @return [Array<ChunkyPNG::Chunk::ImageData>]
3530
+ #
3531
+ # source://chunky_png//lib/chunky_png/datastream.rb#38
3532
+ def data_chunks; end
3533
+
3534
+ # The chunks that together compose the images pixel data.
3535
+ #
3536
+ # @return [Array<ChunkyPNG::Chunk::ImageData>]
3537
+ #
3538
+ # source://chunky_png//lib/chunky_png/datastream.rb#38
3539
+ def data_chunks=(_arg0); end
3540
+
3541
+ # Enumerates the chunks in this datastream.
3542
+ #
3543
+ # This will iterate over the chunks using the order in which the chunks
3544
+ # should appear in the PNG file.
3545
+ #
3546
+ # @see ChunkyPNG::Datastream#chunks
3547
+ # @yield [chunk] Yields the chunks in this datastream, one by one in the correct order.
3548
+ # @yieldparam chunk [ChunkyPNG::Chunk::Base] A chunk in this datastream.
3549
+ #
3550
+ # source://chunky_png//lib/chunky_png/datastream.rb#124
3551
+ def each_chunk; end
3552
+
3553
+ # The empty chunk that signals the end of this datastream
3554
+ #
3555
+ # @return [ChunkyPNG::Chunk::Header]
3556
+ #
3557
+ # source://chunky_png//lib/chunky_png/datastream.rb#42
3558
+ def end_chunk; end
3559
+
3560
+ # The empty chunk that signals the end of this datastream
3561
+ #
3562
+ # @return [ChunkyPNG::Chunk::Header]
3563
+ #
3564
+ # source://chunky_png//lib/chunky_png/datastream.rb#42
3565
+ def end_chunk=(_arg0); end
3566
+
3567
+ # The header chunk of this datastream.
3568
+ #
3569
+ # @return [ChunkyPNG::Chunk::Header]
3570
+ #
3571
+ # source://chunky_png//lib/chunky_png/datastream.rb#18
3572
+ def header_chunk; end
3573
+
3574
+ # The header chunk of this datastream.
3575
+ #
3576
+ # @return [ChunkyPNG::Chunk::Header]
3577
+ #
3578
+ # source://chunky_png//lib/chunky_png/datastream.rb#18
3579
+ def header_chunk=(_arg0); end
3580
+
3581
+ # Returns the uncompressed image data, combined from all the IDAT chunks
3582
+ #
3583
+ # @return [String] The uncompressed image data for this datastream
3584
+ #
3585
+ # source://chunky_png//lib/chunky_png/datastream.rb#153
3586
+ def imagedata; end
3587
+
3588
+ # Returns all the textual metadata key/value pairs as hash.
3589
+ #
3590
+ # @return [Hash] A hash containing metadata fields and their values.
3591
+ #
3592
+ # source://chunky_png//lib/chunky_png/datastream.rb#143
3593
+ def metadata; end
3594
+
3595
+ # All other chunks in this PNG file.
3596
+ #
3597
+ # @return [Array<ChunkyPNG::Chunk::Generic>]
3598
+ #
3599
+ # source://chunky_png//lib/chunky_png/datastream.rb#22
3600
+ def other_chunks; end
3601
+
3602
+ # All other chunks in this PNG file.
3603
+ #
3604
+ # @return [Array<ChunkyPNG::Chunk::Generic>]
3605
+ #
3606
+ # source://chunky_png//lib/chunky_png/datastream.rb#22
3607
+ def other_chunks=(_arg0); end
3608
+
3609
+ # The chunk containing the image's palette.
3610
+ #
3611
+ # @return [ChunkyPNG::Chunk::Palette]
3612
+ #
3613
+ # source://chunky_png//lib/chunky_png/datastream.rb#26
3614
+ def palette_chunk; end
3615
+
3616
+ # The chunk containing the image's palette.
3617
+ #
3618
+ # @return [ChunkyPNG::Chunk::Palette]
3619
+ #
3620
+ # source://chunky_png//lib/chunky_png/datastream.rb#26
3621
+ def palette_chunk=(_arg0); end
3622
+
3623
+ # The chunk containing the physical dimensions of the PNG's pixels.
3624
+ #
3625
+ # @return [ChunkyPNG::Chunk::Physical]
3626
+ #
3627
+ # source://chunky_png//lib/chunky_png/datastream.rb#34
3628
+ def physical_chunk; end
3629
+
3630
+ # The chunk containing the physical dimensions of the PNG's pixels.
3631
+ #
3632
+ # @return [ChunkyPNG::Chunk::Physical]
3633
+ #
3634
+ # source://chunky_png//lib/chunky_png/datastream.rb#34
3635
+ def physical_chunk=(_arg0); end
3636
+
3637
+ # Saves this datastream as a PNG file.
3638
+ #
3639
+ # @param filename [String] The filename to use.
3640
+ #
3641
+ # source://chunky_png//lib/chunky_png/datastream.rb#170
3642
+ def save(filename); end
3643
+
3644
+ # Encodes this datastream into a string.
3645
+ #
3646
+ # @return [String] The encoded PNG datastream.
3647
+ #
3648
+ # source://chunky_png//lib/chunky_png/datastream.rb#176
3649
+ def to_blob; end
3650
+
3651
+ # Encodes this datastream into a string.
3652
+ #
3653
+ # @return [String] The encoded PNG datastream.
3654
+ #
3655
+ # source://chunky_png//lib/chunky_png/datastream.rb#176
3656
+ def to_s; end
3657
+
3658
+ # Encodes this datastream into a string.
3659
+ #
3660
+ # @return [String] The encoded PNG datastream.
3661
+ #
3662
+ # source://chunky_png//lib/chunky_png/datastream.rb#176
3663
+ def to_string; end
3664
+
3665
+ # The chunk containing the transparency information of the palette.
3666
+ #
3667
+ # @return [ChunkyPNG::Chunk::Transparency]
3668
+ #
3669
+ # source://chunky_png//lib/chunky_png/datastream.rb#30
3670
+ def transparency_chunk; end
3671
+
3672
+ # The chunk containing the transparency information of the palette.
3673
+ #
3674
+ # @return [ChunkyPNG::Chunk::Transparency]
3675
+ #
3676
+ # source://chunky_png//lib/chunky_png/datastream.rb#30
3677
+ def transparency_chunk=(_arg0); end
3678
+
3679
+ # Writes the datastream to the given output stream.
3680
+ #
3681
+ # @param io [IO] The output stream to write to.
3682
+ #
3683
+ # source://chunky_png//lib/chunky_png/datastream.rb#163
3684
+ def write(io); end
3685
+
3686
+ class << self
3687
+ # Reads a PNG datastream from a string.
3688
+ #
3689
+ # @param str [String] The PNG encoded string to load from.
3690
+ # @return [ChunkyPNG::Datastream] The loaded datastream instance.
3691
+ #
3692
+ # source://chunky_png//lib/chunky_png/datastream.rb#58
3693
+ def from_blob(str); end
3694
+
3695
+ # Reads a PNG datastream from a file.
3696
+ #
3697
+ # @param filename [String] The path of the file to load from.
3698
+ # @return [ChunkyPNG::Datastream] The loaded datastream instance.
3699
+ #
3700
+ # source://chunky_png//lib/chunky_png/datastream.rb#67
3701
+ def from_file(filename); end
3702
+
3703
+ # Reads a PNG datastream from an input stream
3704
+ #
3705
+ # @param io [IO] The stream to read from.
3706
+ # @return [ChunkyPNG::Datastream] The loaded datastream instance.
3707
+ #
3708
+ # source://chunky_png//lib/chunky_png/datastream.rb#76
3709
+ def from_io(io); end
3710
+
3711
+ # Reads a PNG datastream from a string.
3712
+ #
3713
+ # @param str [String] The PNG encoded string to load from.
3714
+ # @return [ChunkyPNG::Datastream] The loaded datastream instance.
3715
+ #
3716
+ # source://chunky_png//lib/chunky_png/datastream.rb#58
3717
+ def from_string(str); end
3718
+
3719
+ # Verifies that the current stream is a PNG datastream by checking its signature.
3720
+ #
3721
+ # This method reads the PNG signature from the stream, setting the current position
3722
+ # of the stream directly after the signature, where the IHDR chunk should begin.
3723
+ #
3724
+ # @param io [IO] The stream to read the PNG signature from.
3725
+ # @raise [RuntimeError] An exception is raised if the PNG signature is not found at
3726
+ # the beginning of the stream.
3727
+ #
3728
+ # source://chunky_png//lib/chunky_png/datastream.rb#104
3729
+ def verify_signature!(io); end
3730
+ end
3731
+ end
3732
+
3733
+ # The signature that each PNG file or stream should begin with.
3734
+ #
3735
+ # source://chunky_png//lib/chunky_png/datastream.rb#14
3736
+ ChunkyPNG::Datastream::SIGNATURE = T.let(T.unsafe(nil), String)
3737
+
3738
+ # Class that represents the dimension of something, e.g. a {ChunkyPNG::Canvas}.
3739
+ #
3740
+ # This class contains some methods to simplify performing dimension related checks.
3741
+ #
3742
+ # source://chunky_png//lib/chunky_png/dimension.rb#68
3743
+ class ChunkyPNG::Dimension
3744
+ # Initializes a new dimension instance.
3745
+ #
3746
+ # @param width [Integer] The width-component of the new dimension.
3747
+ # @param height [Integer] The height-component of the new dimension.
3748
+ # @return [Dimension] a new instance of Dimension
3749
+ #
3750
+ # source://chunky_png//lib/chunky_png/dimension.rb#82
3751
+ def initialize(width, height); end
3752
+
3753
+ # Compares the size of 2 dimensions.
3754
+ #
3755
+ # @param other [ChunkyPNG::Dimension] The dimension to compare with.
3756
+ # @return [-1, 0, 1] -1 if the other dimension has a larger area, 1 of this
3757
+ # dimension is larger, 0 if both are identical in size.
3758
+ #
3759
+ # source://chunky_png//lib/chunky_png/dimension.rb#121
3760
+ def <=>(other); end
3761
+
3762
+ # Checks whether 2 dimensions are identical.
3763
+ #
3764
+ # @param other [ChunkyPNG::Dimension] The dimension to compare with.
3765
+ # @return [true, false] <tt>true</tt> iff width and height match.
3766
+ #
3767
+ # source://chunky_png//lib/chunky_png/dimension.rb#104
3768
+ def ==(other); end
3769
+
3770
+ # Returns the area of this dimension.
3771
+ #
3772
+ # @return [Integer] The area in number of pixels.
3773
+ #
3774
+ # source://chunky_png//lib/chunky_png/dimension.rb#88
3775
+ def area; end
3776
+
3777
+ # Checks whether 2 dimensions are identical.
3778
+ #
3779
+ # @param other [ChunkyPNG::Dimension] The dimension to compare with.
3780
+ # @return [true, false] <tt>true</tt> iff width and height match.
3781
+ #
3782
+ # source://chunky_png//lib/chunky_png/dimension.rb#104
3783
+ def eql?(other); end
3784
+
3785
+ # Calculates a hash for the dimension object, based on width and height
3786
+ #
3787
+ # @return [Integer] A hashed value of the dimensions
3788
+ #
3789
+ # source://chunky_png//lib/chunky_png/dimension.rb#113
3790
+ def hash; end
3791
+
3792
+ # @return [Integer] The height-component of this dimension.
3793
+ #
3794
+ # source://chunky_png//lib/chunky_png/dimension.rb#77
3795
+ def height; end
3796
+
3797
+ # @return [Integer] The height-component of this dimension.
3798
+ #
3799
+ # source://chunky_png//lib/chunky_png/dimension.rb#77
3800
+ def height=(_arg0); end
3801
+
3802
+ # Checks whether a point is within bounds of this dimension.
3803
+ #
3804
+ # @param point_like [ChunkyPNG::Point, ...] A point-like to bounds-check.
3805
+ # @return [true, false] True iff the x and y coordinate fall in this dimension.
3806
+ # @see ChunkyPNG.Point
3807
+ #
3808
+ # source://chunky_png//lib/chunky_png/dimension.rb#96
3809
+ def include?(*point_like); end
3810
+
3811
+ # Casts this dimension into an array.
3812
+ #
3813
+ # @return [Array<Integer>] <tt>[width, height]</tt> for this dimension.
3814
+ #
3815
+ # source://chunky_png//lib/chunky_png/dimension.rb#127
3816
+ def to_a; end
3817
+
3818
+ # Casts this dimension into an array.
3819
+ #
3820
+ # @return [Array<Integer>] <tt>[width, height]</tt> for this dimension.
3821
+ #
3822
+ # source://chunky_png//lib/chunky_png/dimension.rb#127
3823
+ def to_ary; end
3824
+
3825
+ # @return [Integer] The width-component of this dimension.
3826
+ #
3827
+ # source://chunky_png//lib/chunky_png/dimension.rb#74
3828
+ def width; end
3829
+
3830
+ # @return [Integer] The width-component of this dimension.
3831
+ #
3832
+ # source://chunky_png//lib/chunky_png/dimension.rb#74
3833
+ def width=(_arg0); end
3834
+ end
3835
+
3836
+ # @private
3837
+ # @return [Regexp] The regexp to parse dimensions from a string.
3838
+ #
3839
+ # source://chunky_png//lib/chunky_png/dimension.rb#71
3840
+ ChunkyPNG::Dimension::DIMENSION_REGEXP = T.let(T.unsafe(nil), Regexp)
3841
+
3842
+ # Null-byte, with the encoding set correctly to ASCII-8BIT (binary) in Ruby 1.9.
3843
+ #
3844
+ # @private
3845
+ # @return [String] A binary string, consisting of one NULL-byte.
3846
+ #
3847
+ # source://chunky_png//lib/chunky_png.rb#146
3848
+ ChunkyPNG::EXTRA_BYTE = T.let(T.unsafe(nil), String)
3849
+
3850
+ # Default exception class for ChunkyPNG
3851
+ #
3852
+ # source://chunky_png//lib/chunky_png.rb#110
3853
+ class ChunkyPNG::Exception < ::StandardError; end
3854
+
3855
+ # Exception that is raised if an expectation fails.
3856
+ #
3857
+ # source://chunky_png//lib/chunky_png.rb#131
3858
+ class ChunkyPNG::ExpectationFailed < ::ChunkyPNG::Exception; end
3859
+
3860
+ # Indicates that the PNG specification's default filtering are
3861
+ # being used in the image.
3862
+ #
3863
+ # @private
3864
+ #
3865
+ # source://chunky_png//lib/chunky_png.rb#83
3866
+ ChunkyPNG::FILTERING_DEFAULT = T.let(T.unsafe(nil), Integer)
3867
+
3868
+ # Indicates that AVERAGE filtering is used for the scanline.
3869
+ #
3870
+ # @private
3871
+ #
3872
+ # source://chunky_png//lib/chunky_png.rb#99
3873
+ ChunkyPNG::FILTER_AVERAGE = T.let(T.unsafe(nil), Integer)
3874
+
3875
+ # Indicates that no filtering is used for the scanline.
3876
+ #
3877
+ # @private
3878
+ #
3879
+ # source://chunky_png//lib/chunky_png.rb#87
3880
+ ChunkyPNG::FILTER_NONE = T.let(T.unsafe(nil), Integer)
3881
+
3882
+ # Indicates that PAETH filtering is used for the scanline.
3883
+ #
3884
+ # @private
3885
+ #
3886
+ # source://chunky_png//lib/chunky_png.rb#103
3887
+ ChunkyPNG::FILTER_PAETH = T.let(T.unsafe(nil), Integer)
3888
+
3889
+ # Indicates that SUB filtering is used for the scanline.
3890
+ #
3891
+ # @private
3892
+ #
3893
+ # source://chunky_png//lib/chunky_png.rb#91
3894
+ ChunkyPNG::FILTER_SUB = T.let(T.unsafe(nil), Integer)
3895
+
3896
+ # Indicates that UP filtering is used for the scanline.
3897
+ #
3898
+ # @private
3899
+ #
3900
+ # source://chunky_png//lib/chunky_png.rb#95
3901
+ ChunkyPNG::FILTER_UP = T.let(T.unsafe(nil), Integer)
3902
+
3903
+ # Indicates that the image uses Adam7 interlacing.
3904
+ #
3905
+ # @private
3906
+ #
3907
+ # source://chunky_png//lib/chunky_png.rb#76
3908
+ ChunkyPNG::INTERLACING_ADAM7 = T.let(T.unsafe(nil), Integer)
3909
+
3910
+ # Indicates that the image does not use interlacing.
3911
+ #
3912
+ # @private
3913
+ #
3914
+ # source://chunky_png//lib/chunky_png.rb#72
3915
+ ChunkyPNG::INTERLACING_NONE = T.let(T.unsafe(nil), Integer)
3916
+
3917
+ # ChunkyPNG::Image is an extension of the {ChunkyPNG::Canvas} class, that
3918
+ # also includes support for metadata.
3919
+ #
3920
+ # @see ChunkyPNG::Canvas
3921
+ #
3922
+ # source://chunky_png//lib/chunky_png/image.rb#10
3923
+ class ChunkyPNG::Image < ::ChunkyPNG::Canvas
3924
+ # Initializes a new ChunkyPNG::Image instance.
3925
+ #
3926
+ # @param width [Integer] The width of the new image.
3927
+ # @param height [Integer] The height of the new image.
3928
+ # @param bg_color [Integer] The background color of the new image.
3929
+ # @param metadata [Hash] A hash of metadata fields and values for this image.
3930
+ # @return [Image] a new instance of Image
3931
+ # @see ChunkyPNG::Canvas#initialize
3932
+ #
3933
+ # source://chunky_png//lib/chunky_png/image.rb#22
3934
+ def initialize(width, height, bg_color = T.unsafe(nil), metadata = T.unsafe(nil)); end
3935
+
3936
+ # @return [Hash] The hash of metadata fields for this PNG image.
3937
+ #
3938
+ # source://chunky_png//lib/chunky_png/image.rb#14
3939
+ def metadata; end
3940
+
3941
+ # @return [Hash] The hash of metadata fields for this PNG image.
3942
+ #
3943
+ # source://chunky_png//lib/chunky_png/image.rb#14
3944
+ def metadata=(_arg0); end
3945
+
3946
+ # Returns the metadata for this image as PNG chunks.
3947
+ #
3948
+ # Chunks will either be of the {ChunkyPNG::Chunk::Text} type for small
3949
+ # values (in bytes), or of the {ChunkyPNG::Chunk::CompressedText} type
3950
+ # for values that are larger in size.
3951
+ #
3952
+ # @return [Array<ChunkyPNG::Chunk>] An array of metadata chunks.
3953
+ # @see ChunkyPNG::Image::METADATA_COMPRESSION_TRESHOLD
3954
+ #
3955
+ # source://chunky_png//lib/chunky_png/image.rb#43
3956
+ def metadata_chunks; end
3957
+
3958
+ # Encodes the image to a PNG datastream for saving to disk or writing to an IO stream.
3959
+ #
3960
+ # Besides encoding the canvas, it will also encode the metadata fields to text chunks.
3961
+ #
3962
+ # @param constraints [Hash] The constraints to use when encoding the canvas.
3963
+ # @return [ChunkyPNG::Datastream] The datastream that contains this image.
3964
+ # @see ChunkyPNG::Canvas::PNGEncoding#to_datastream
3965
+ # @see #metadata_chunks
3966
+ #
3967
+ # source://chunky_png//lib/chunky_png/image.rb#61
3968
+ def to_datastream(constraints = T.unsafe(nil)); end
3969
+
3970
+ private
3971
+
3972
+ # Initializes a copy of another ChunkyPNG::Image instance.
3973
+ #
3974
+ # @param other [ChunkyPNG::Image] The other image to copy.
3975
+ #
3976
+ # source://chunky_png//lib/chunky_png/image.rb#30
3977
+ def initialize_copy(other); end
3978
+
3979
+ class << self
3980
+ # Reads a ChunkyPNG::Image instance from a data stream.
3981
+ #
3982
+ # Besides decoding the canvas, this will also read the metadata fields
3983
+ # from the datastream.
3984
+ #
3985
+ # @param ds [ChunkyPNG::Datastream] The datastream to read from.
3986
+ #
3987
+ # source://chunky_png//lib/chunky_png/image.rb#73
3988
+ def from_datastream(ds); end
3989
+ end
3990
+ end
3991
+
3992
+ # The minimum size of bytes the value of a metadata field should be before compression
3993
+ # is enabled for the chunk.
3994
+ #
3995
+ # source://chunky_png//lib/chunky_png/image.rb#11
3996
+ ChunkyPNG::Image::METADATA_COMPRESSION_TRESHOLD = T.let(T.unsafe(nil), Integer)
3997
+
3998
+ # Exception that is raised if an tTXt chunk does not contain valid UTF-8 data.
3999
+ #
4000
+ # source://chunky_png//lib/chunky_png.rb#127
4001
+ class ChunkyPNG::InvalidUTF8 < ::ChunkyPNG::Exception; end
4002
+
4003
+ # Exception that is raised for an unsupported PNG image.
4004
+ #
4005
+ # source://chunky_png//lib/chunky_png.rb#114
4006
+ class ChunkyPNG::NotSupported < ::ChunkyPNG::Exception; end
4007
+
4008
+ # Exception that when provided coordinates are out of bounds for the canvas
4009
+ #
4010
+ # source://chunky_png//lib/chunky_png.rb#135
4011
+ class ChunkyPNG::OutOfBounds < ::ChunkyPNG::ExpectationFailed; end
4012
+
4013
+ # A palette describes the set of colors that is being used for an image.
4014
+ #
4015
+ # A PNG image can contain an explicit palette which defines the colors of
4016
+ # that image, but can also use an implicit palette, e.g. all truecolor colors
4017
+ # or all grayscale colors.
4018
+ #
4019
+ # This palette supports decoding colors from a palette if an explicit palette
4020
+ # is provided in a PNG datastream, and it supports encoding colors to an
4021
+ # explicit palette (stores as PLTE & tRNS chunks in a PNG file).
4022
+ #
4023
+ # @see ChunkyPNG::Color
4024
+ #
4025
+ # source://chunky_png//lib/chunky_png/palette.rb#22
4026
+ class ChunkyPNG::Palette < ::Set
4027
+ # Builds a new palette given a set (Enumerable instance) of colors.
4028
+ #
4029
+ # @param enum [Enumerable<Integer>] The set of colors to include in this
4030
+ # palette.This Enumerable can contain duplicates.
4031
+ # @param decoding_map [Array] An array of colors in the exact order at
4032
+ # which they appeared in the palette chunk, so that this array can be
4033
+ # used for decoding.
4034
+ # @return [Palette] a new instance of Palette
4035
+ #
4036
+ # source://chunky_png//lib/chunky_png/palette.rb#23
4037
+ def initialize(enum, decoding_map = T.unsafe(nil)); end
4038
+
4039
+ # Returns a color, given the position in the original palette chunk.
4040
+ #
4041
+ # @param index [Integer] The 0-based position of the color in the palette.
4042
+ # @return [ChunkyPNG::Color] The color that is stored in the palette under
4043
+ # the given index
4044
+ # @see ChunkyPNG::Palette#can_decode?
4045
+ #
4046
+ # source://chunky_png//lib/chunky_png/palette.rb#148
4047
+ def [](index); end
4048
+
4049
+ # Determines the most suitable colormode for this palette.
4050
+ #
4051
+ # @return [Integer] The colormode which would create the smallest possible
4052
+ # file for images that use this exact palette.
4053
+ #
4054
+ # source://chunky_png//lib/chunky_png/palette.rb#195
4055
+ def best_color_settings; end
4056
+
4057
+ # Check whether this palette only contains bacl and white.
4058
+ #
4059
+ # @return [true, false] True if all colors in this palette are grayscale
4060
+ # teints.
4061
+ # @see ChunkyPNG::Color#grayscale??
4062
+ #
4063
+ # source://chunky_png//lib/chunky_png/palette.rb#104
4064
+ def black_and_white?; end
4065
+
4066
+ # Checks whether this palette is suitable for decoding an image from a
4067
+ # datastream.
4068
+ #
4069
+ # This requires that the positions of the colors in the original palette
4070
+ # chunk is known, which is stored as an array in the +@decoding_map+
4071
+ # instance variable.
4072
+ #
4073
+ # @return [true, false] True if a decoding map was built when this palette
4074
+ # was loaded.
4075
+ #
4076
+ # source://chunky_png//lib/chunky_png/palette.rb#126
4077
+ def can_decode?; end
4078
+
4079
+ # Checks whether this palette is suitable for encoding an image from to
4080
+ # datastream.
4081
+ #
4082
+ # This requires that the position of the color in the future palette chunk
4083
+ # is known, which is stored as a hash in the +@encoding_map+ instance
4084
+ # variable.
4085
+ #
4086
+ # @return [true, false] True if a encoding map was built when this palette
4087
+ # was loaded.
4088
+ #
4089
+ # source://chunky_png//lib/chunky_png/palette.rb#139
4090
+ def can_encode?; end
4091
+
4092
+ # Determines the minimal bit depth required for an indexed image
4093
+ #
4094
+ # @return [Integer] Number of bits per pixel, i.e. 1, 2, 4 or 8, or nil if
4095
+ # this image cannot be saved as an indexed image.
4096
+ #
4097
+ # source://chunky_png//lib/chunky_png/palette.rb#216
4098
+ def determine_bit_depth; end
4099
+
4100
+ # Check whether this palette only contains grayscale colors.
4101
+ #
4102
+ # @return [true, false] True if all colors in this palette are grayscale
4103
+ # teints.
4104
+ # @see ChunkyPNG::Color#grayscale??
4105
+ #
4106
+ # source://chunky_png//lib/chunky_png/palette.rb#96
4107
+ def grayscale?; end
4108
+
4109
+ # Returns the position of a color in the palette
4110
+ #
4111
+ # @param color [ChunkyPNG::Color] The color for which to look up the index.
4112
+ # @return [Integer] The 0-based position of the color in the palette.
4113
+ # @see ChunkyPNG::Palette#can_encode?
4114
+ #
4115
+ # source://chunky_png//lib/chunky_png/palette.rb#156
4116
+ def index(color); end
4117
+
4118
+ # Checks whether the size of this palette is suitable for indexed storage.
4119
+ #
4120
+ # @return [true, false] True if the number of colors in this palette is at
4121
+ # most 256.
4122
+ #
4123
+ # source://chunky_png//lib/chunky_png/palette.rb#81
4124
+ def indexable?; end
4125
+
4126
+ # Check whether this palette only contains opaque colors.
4127
+ #
4128
+ # @return [true, false] True if all colors in this palette are opaque.
4129
+ # @see ChunkyPNG::Color#opaque?
4130
+ #
4131
+ # source://chunky_png//lib/chunky_png/palette.rb#88
4132
+ def opaque?; end
4133
+
4134
+ # Returns a palette with all the opaque variants of the colors in this
4135
+ # palette.
4136
+ #
4137
+ # @return [ChunkyPNG::Palette] A new Palette instance with only opaque
4138
+ # colors.
4139
+ # @see ChunkyPNG::Color#opaque!
4140
+ #
4141
+ # source://chunky_png//lib/chunky_png/palette.rb#113
4142
+ def opaque_palette; end
4143
+
4144
+ # Creates a PLTE chunk that corresponds with this palette to store the r,
4145
+ # g, and b channels of all colors.
4146
+ #
4147
+ # @note A PLTE chunk should only be included if the image is encoded using
4148
+ # index colors. After this chunk has been built, the palette becomes
4149
+ # suitable for encoding an image.
4150
+ # @return [ChunkyPNG::Chunk::Palette] The PLTE chunk.
4151
+ # @see ChunkyPNG::Palette#can_encode?
4152
+ #
4153
+ # source://chunky_png//lib/chunky_png/palette.rb#180
4154
+ def to_plte_chunk; end
4155
+
4156
+ # Creates a tRNS chunk that corresponds with this palette to store the
4157
+ # alpha channel of all colors.
4158
+ #
4159
+ # Note that this chunk can be left out of every color in the palette is
4160
+ # opaque, and the image is encoded using indexed colors.
4161
+ #
4162
+ # @return [ChunkyPNG::Chunk::Transparency] The tRNS chunk.
4163
+ #
4164
+ # source://chunky_png//lib/chunky_png/palette.rb#167
4165
+ def to_trns_chunk; end
4166
+
4167
+ class << self
4168
+ # Builds a palette instance from a given canvas.
4169
+ #
4170
+ # @param canvas [ChunkyPNG::Canvas] The canvas to create a palette for.
4171
+ # @return [ChunkyPNG::Palette] The palette instance.
4172
+ #
4173
+ # source://chunky_png//lib/chunky_png/palette.rb#63
4174
+ def from_canvas(canvas); end
4175
+
4176
+ # Builds a palette instance from a PLTE chunk and optionally a tRNS chunk
4177
+ # from a PNG datastream.
4178
+ #
4179
+ # This method will cerate a palette that is suitable for decoding an image.
4180
+ #
4181
+ # @param palette_chunk [ChunkyPNG::Chunk::Palette] The palette chunk to
4182
+ # load from
4183
+ # @param transparency_chunk [ChunkyPNG::Chunk::Transparency, nil] The
4184
+ # optional transparency chunk.
4185
+ # @return [ChunkyPNG::Palette] The loaded palette instance.
4186
+ # @see ChunkyPNG::Palette#can_decode?
4187
+ #
4188
+ # source://chunky_png//lib/chunky_png/palette.rb#41
4189
+ def from_chunks(palette_chunk, transparency_chunk = T.unsafe(nil)); end
4190
+
4191
+ # Builds a palette instance from a given set of pixels.
4192
+ #
4193
+ # @param pixels [Enumerable<Integer>] An enumeration of pixels to create a
4194
+ # palette for
4195
+ # @return [ChunkyPNG::Palette] The palette instance.
4196
+ #
4197
+ # source://chunky_png//lib/chunky_png/palette.rb#74
4198
+ def from_pixels(pixels); end
4199
+ end
4200
+ end
4201
+
4202
+ # Simple class that represents a point on a canvas using an x and y coordinate.
4203
+ #
4204
+ # This class implements some basic methods to handle comparison, the splat operator and
4205
+ # bounds checking that make it easier to work with coordinates.
4206
+ #
4207
+ # @see ChunkyPNG.Point
4208
+ #
4209
+ # source://chunky_png//lib/chunky_png/point.rb#73
4210
+ class ChunkyPNG::Point
4211
+ # Initializes a new point instance.
4212
+ #
4213
+ # @param x [Integer, :to_i] The x-coordinate.
4214
+ # @param y [Integer, :to_i] The y-coordinate.
4215
+ # @return [Point] a new instance of Point
4216
+ #
4217
+ # source://chunky_png//lib/chunky_png/point.rb#87
4218
+ def initialize(x, y); end
4219
+
4220
+ # Compares 2 points.
4221
+ #
4222
+ # It will first compare the y coordinate, and it only takes the x-coordinate into
4223
+ # account if the y-coordinates of the points are identical. This way, an array of
4224
+ # points will be sorted into the order in which they would occur in the pixels
4225
+ # array returned by {ChunkyPNG::Canvas#pixels}.
4226
+ #
4227
+ # @param other [ChunkyPNG::Point] The point to compare this point with.
4228
+ # @return [-1, 0, 1] <tt>-1</tt> If this point comes before the other one, <tt>1</tt>
4229
+ # if after, and <tt>0</tt> if the points are identical.
4230
+ #
4231
+ # source://chunky_png//lib/chunky_png/point.rb#109
4232
+ def <=>(other); end
4233
+
4234
+ # Checks whether 2 points are identical.
4235
+ #
4236
+ # @return [true, false] <tt>true</tt> iff the x and y coordinates match
4237
+ #
4238
+ # source://chunky_png//lib/chunky_png/point.rb#93
4239
+ def ==(other); end
4240
+
4241
+ # Checks whether 2 points are identical.
4242
+ #
4243
+ # @return [true, false] <tt>true</tt> iff the x and y coordinates match
4244
+ #
4245
+ # source://chunky_png//lib/chunky_png/point.rb#93
4246
+ def eql?(other); end
4247
+
4248
+ # Converts the point instance to an array.
4249
+ #
4250
+ # @return [Array] A 2-element array, i.e. <tt>[x, y]</tt>.
4251
+ #
4252
+ # source://chunky_png//lib/chunky_png/point.rb#115
4253
+ def to_a; end
4254
+
4255
+ # Converts the point instance to an array.
4256
+ #
4257
+ # @return [Array] A 2-element array, i.e. <tt>[x, y]</tt>.
4258
+ #
4259
+ # source://chunky_png//lib/chunky_png/point.rb#115
4260
+ def to_ary; end
4261
+
4262
+ # Checks whether the point falls into a dimension
4263
+ #
4264
+ # @param dimension_like [ChunkyPNG::Dimension, ...] The dimension of which the bounds
4265
+ # should be taken for the check.
4266
+ # @return [true, false] <tt>true</tt> iff the x and y coordinate fall width the width
4267
+ # and height of the dimension.
4268
+ #
4269
+ # source://chunky_png//lib/chunky_png/point.rb#126
4270
+ def within_bounds?(*dimension_like); end
4271
+
4272
+ # @return [Integer] The x-coordinate of the point.
4273
+ #
4274
+ # source://chunky_png//lib/chunky_png/point.rb#79
4275
+ def x; end
4276
+
4277
+ # @return [Integer] The x-coordinate of the point.
4278
+ #
4279
+ # source://chunky_png//lib/chunky_png/point.rb#79
4280
+ def x=(_arg0); end
4281
+
4282
+ # @return [Integer] The y-coordinate of the point.
4283
+ #
4284
+ # source://chunky_png//lib/chunky_png/point.rb#82
4285
+ def y; end
4286
+
4287
+ # @return [Integer] The y-coordinate of the point.
4288
+ #
4289
+ # source://chunky_png//lib/chunky_png/point.rb#82
4290
+ def y=(_arg0); end
4291
+ end
4292
+
4293
+ # @private
4294
+ # @return [Regexp] The regexp to parse points from a string.
4295
+ #
4296
+ # source://chunky_png//lib/chunky_png/point.rb#76
4297
+ ChunkyPNG::Point::POINT_REGEXP = T.let(T.unsafe(nil), Regexp)
4298
+
4299
+ # Exception that is raised if the PNG signature is not encountered at the
4300
+ # beginning of the file.
4301
+ #
4302
+ # source://chunky_png//lib/chunky_png.rb#119
4303
+ class ChunkyPNG::SignatureMismatch < ::ChunkyPNG::Exception; end
4304
+
4305
+ # Indicates that the PNG chunk content is not compressed
4306
+ # flag used in iTXt chunk
4307
+ #
4308
+ # @private
4309
+ #
4310
+ # source://chunky_png//lib/chunky_png.rb#63
4311
+ ChunkyPNG::UNCOMPRESSED_CONTENT = T.let(T.unsafe(nil), Integer)
4312
+
4313
+ # Exception that is raised when requesting the DPI of a PNG that doesn't
4314
+ # specify the units of its physical pixel dimensions.
4315
+ #
4316
+ # source://chunky_png//lib/chunky_png.rb#140
4317
+ class ChunkyPNG::UnitsUnknown < ::ChunkyPNG::Exception; end
4318
+
4319
+ # The current version of ChunkyPNG.
4320
+ # Set it and commit the change this before running rake release.
4321
+ #
4322
+ # source://chunky_png//lib/chunky_png/version.rb#6
4323
+ ChunkyPNG::VERSION = T.let(T.unsafe(nil), String)
4324
+
4325
+ # Class that represents a vector of points, i.e. a list of {ChunkyPNG::Point} instances.
4326
+ #
4327
+ # Vectors can be created quite flexibly. See the {ChunkyPNG.Vector} factory methods for
4328
+ # more information on how to construct vectors.
4329
+ #
4330
+ # source://chunky_png//lib/chunky_png/vector.rb#34
4331
+ class ChunkyPNG::Vector
4332
+ include ::Enumerable
4333
+
4334
+ # Initializes a vector based on a list of Point instances.
4335
+ #
4336
+ # You usually do not want to use this method directly, but call {ChunkyPNG.Vector} instead.
4337
+ #
4338
+ # @param points [Array<ChunkyPNG::Point>]
4339
+ # @return [Vector] a new instance of Vector
4340
+ # @see ChunkyPNG.Vector
4341
+ #
4342
+ # source://chunky_png//lib/chunky_png/vector.rb#46
4343
+ def initialize(points = T.unsafe(nil)); end
4344
+
4345
+ # Comparison between two vectors for quality.
4346
+ #
4347
+ # @param other [ChunkyPNG::Vector] The vector to compare with.
4348
+ # @return [true, false] true if the list of points are identical
4349
+ #
4350
+ # source://chunky_png//lib/chunky_png/vector.rb#98
4351
+ def ==(other); end
4352
+
4353
+ # Returns the point with the given indexof this vector.
4354
+ #
4355
+ # @param index [Integer] The 0-based index of the point in this vector.
4356
+ # @return [ChunkyPNG::Point] The point instance.
4357
+ #
4358
+ # source://chunky_png//lib/chunky_png/vector.rb#69
4359
+ def [](index); end
4360
+
4361
+ # Returns the dimension of the minimal bounding rectangle of the points in this vector.
4362
+ #
4363
+ # @return [ChunkyPNG::Dimension] The dimension instance with the width and height
4364
+ #
4365
+ # source://chunky_png//lib/chunky_png/vector.rb#162
4366
+ def dimension; end
4367
+
4368
+ # Iterates over all the points in this vector
4369
+ #
4370
+ # @return [void]
4371
+ # @yield [ChunkyPNG::Point] The points in the correct order.
4372
+ #
4373
+ # source://chunky_png//lib/chunky_png/vector.rb#91
4374
+ def each(&block); end
4375
+
4376
+ # Iterates over all the edges in this vector.
4377
+ #
4378
+ # An edge is a combination of two subsequent points in the vector. Together, they will form
4379
+ # a path from the first point to the last point
4380
+ #
4381
+ # @param close [true, false] Whether to close the path, i.e. return an edge that connects the last
4382
+ # point in the vector back to the first point.
4383
+ # @raise [ChunkyPNG::ExpectationFailed] if the vector contains less than two points.
4384
+ # @return [void]
4385
+ # @see #edges
4386
+ # @yield [points.last, points.first]
4387
+ #
4388
+ # source://chunky_png//lib/chunky_png/vector.rb#60
4389
+ def each_edge(close = T.unsafe(nil)); end
4390
+
4391
+ # Returns an enumerator that will iterate over all the edges in this vector.
4392
+ #
4393
+ # @param close [true, false] Whether to close the path, i.e. return an edge that connects the last
4394
+ # point in the vector back to the first point.
4395
+ # @raise [ChunkyPNG::ExpectationFailed] if the vector contains less than two points.
4396
+ # @return [Enumerator] The enumerator that iterates over the edges.
4397
+ # @see #each_edge
4398
+ #
4399
+ # source://chunky_png//lib/chunky_png/vector.rb#78
4400
+ def edges(close = T.unsafe(nil)); end
4401
+
4402
+ # Comparison between two vectors for quality.
4403
+ #
4404
+ # @param other [ChunkyPNG::Vector] The vector to compare with.
4405
+ # @return [true, false] true if the list of points are identical
4406
+ #
4407
+ # source://chunky_png//lib/chunky_png/vector.rb#98
4408
+ def eql?(other); end
4409
+
4410
+ # Returns the height of the minimal bounding box of all the points in this vector.
4411
+ #
4412
+ # @return [Integer] The y-distance between the points that are farthest from each other.
4413
+ #
4414
+ # source://chunky_png//lib/chunky_png/vector.rb#156
4415
+ def height; end
4416
+
4417
+ # Returns the number of points in this vector.
4418
+ #
4419
+ # @return [Integer] The length of the points array.
4420
+ #
4421
+ # source://chunky_png//lib/chunky_png/vector.rb#84
4422
+ def length; end
4423
+
4424
+ # Finds the highest x-coordinate in this vector.
4425
+ #
4426
+ # @return [Integer] The highest x-coordinate of all the points in the vector.
4427
+ #
4428
+ # source://chunky_png//lib/chunky_png/vector.rb#124
4429
+ def max_x; end
4430
+
4431
+ # Finds the highest y-coordinate in this vector.
4432
+ #
4433
+ # @return [Integer] The highest y-coordinate of all the points in the vector.
4434
+ #
4435
+ # source://chunky_png//lib/chunky_png/vector.rb#136
4436
+ def max_y; end
4437
+
4438
+ # Finds the lowest x-coordinate in this vector.
4439
+ #
4440
+ # @return [Integer] The lowest x-coordinate of all the points in the vector.
4441
+ #
4442
+ # source://chunky_png//lib/chunky_png/vector.rb#118
4443
+ def min_x; end
4444
+
4445
+ # Finds the lowest y-coordinate in this vector.
4446
+ #
4447
+ # @return [Integer] The lowest y-coordinate of all the points in the vector.
4448
+ #
4449
+ # source://chunky_png//lib/chunky_png/vector.rb#130
4450
+ def min_y; end
4451
+
4452
+ # Returns the offset from (0,0) of the minimal bounding box of all the
4453
+ # points in this vector
4454
+ #
4455
+ # @return [ChunkyPNG::Point] A point that describes the top left corner if a
4456
+ # minimal bounding box would be drawn around all the points in the vector.
4457
+ #
4458
+ # source://chunky_png//lib/chunky_png/vector.rb#144
4459
+ def offset; end
4460
+
4461
+ # @return [Array<ChunkyPNG::Point>] The array that holds all the points in this vector.
4462
+ #
4463
+ # source://chunky_png//lib/chunky_png/vector.rb#38
4464
+ def points; end
4465
+
4466
+ # Returns the width of the minimal bounding box of all the points in this vector.
4467
+ #
4468
+ # @return [Integer] The x-distance between the points that are farthest from each other.
4469
+ #
4470
+ # source://chunky_png//lib/chunky_png/vector.rb#150
4471
+ def width; end
4472
+
4473
+ # Returns the range in x-coordinates for all the points in this vector.
4474
+ #
4475
+ # @return [Range] The (inclusive) range of x-coordinates.
4476
+ #
4477
+ # source://chunky_png//lib/chunky_png/vector.rb#106
4478
+ def x_range; end
4479
+
4480
+ # Returns the range in y-coordinates for all the points in this vector.
4481
+ #
4482
+ # @return [Range] The (inclusive) range of y-coordinates.
4483
+ #
4484
+ # source://chunky_png//lib/chunky_png/vector.rb#112
4485
+ def y_range; end
4486
+
4487
+ class << self
4488
+ # @return [Array<ChunkyPNG::Point>] The list of points interpreted from the input array.
4489
+ #
4490
+ # source://chunky_png//lib/chunky_png/vector.rb#167
4491
+ def multiple_from_array(source); end
4492
+
4493
+ # @return [Array<ChunkyPNG::Point>] The list of points parsed from the string.
4494
+ #
4495
+ # source://chunky_png//lib/chunky_png/vector.rb#181
4496
+ def multiple_from_string(source_str); end
4497
+ end
4498
+ end