bench9000 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +7 -0
- data/benchmarks/chunky_png/chunky-canvas-resampling-bilinear.rb +69 -0
- data/benchmarks/chunky_png/chunky-canvas-resampling-nearest-neighbor.rb +68 -0
- data/benchmarks/chunky_png/chunky-canvas-resampling-steps-residues.rb +37 -0
- data/benchmarks/chunky_png/chunky-canvas-resampling-steps.rb +37 -0
- data/benchmarks/chunky_png/chunky-color-a.rb +39 -0
- data/benchmarks/chunky_png/chunky-color-b.rb +39 -0
- data/benchmarks/chunky_png/chunky-color-compose-quick.rb +39 -0
- data/benchmarks/chunky_png/chunky-color-g.rb +39 -0
- data/benchmarks/chunky_png/chunky-color-r.rb +39 -0
- data/benchmarks/chunky_png/chunky-decode-png-image-pass.rb +74 -0
- data/benchmarks/chunky_png/chunky-encode-png-image-pass-to-stream.rb +84 -0
- data/benchmarks/chunky_png/chunky-operations-compose.rb +70 -0
- data/benchmarks/chunky_png/chunky-operations-replace.rb +69 -0
- data/benchmarks/chunky_png/chunky_png.patch +22 -0
- data/benchmarks/chunky_png/version.txt +2 -0
- data/benchmarks/classic/binary-trees.rb +100 -0
- data/benchmarks/classic/deltablue.rb +732 -0
- data/benchmarks/classic/fannkuch-redux.rb +111 -0
- data/benchmarks/classic/fasta-string.rb +71 -0
- data/benchmarks/classic/mandelbrot.rb +112 -0
- data/benchmarks/classic/matrix-multiply.rb +78 -0
- data/benchmarks/classic/n-body.rb +188 -0
- data/benchmarks/classic/pidigits.rb +88 -0
- data/benchmarks/classic/red-black.rb +363 -0
- data/benchmarks/classic/richards-kwargs.rb +403 -0
- data/benchmarks/classic/richards.rb +403 -0
- data/benchmarks/classic/spectral-norm.rb +95 -0
- data/benchmarks/default.config.rb +206 -0
- data/benchmarks/graph/connected.rb +62 -0
- data/benchmarks/literature/acid.rb +46 -0
- data/benchmarks/micro/pack-big-U-loop.rb +24 -0
- data/benchmarks/micro/pack-big-xLX-repeat.rb +22 -0
- data/benchmarks/micro/pack-small-mixture.rb +17 -0
- data/benchmarks/micro/string-equal.rb +28 -0
- data/benchmarks/octane/deltablue.rb +981 -0
- data/benchmarks/psd.rb/mock-logger.rb +23 -0
- data/benchmarks/psd.rb/psd-color-cmyk-to-rgb.rb +46 -0
- data/benchmarks/psd.rb/psd-compose-color-burn.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-color-dodge.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-darken.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-difference.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-exclusion.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-hard-light.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-hard-mix.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-lighten.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-linear-burn.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-linear-dodge.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-linear-light.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-multiply.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-normal.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-overlay.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-pin-light.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-screen.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-soft-light.rb +43 -0
- data/benchmarks/psd.rb/psd-compose-vivid-light.rb +43 -0
- data/benchmarks/psd.rb/psd-imageformat-layerraw-parse-raw.rb +70 -0
- data/benchmarks/psd.rb/psd-imageformat-rle-decode-rle-channel.rb +87 -0
- data/benchmarks/psd.rb/psd-imagemode-cmyk-combine-cmyk-channel.rb +65 -0
- data/benchmarks/psd.rb/psd-imagemode-greyscale-combine-greyscale-channel.rb +68 -0
- data/benchmarks/psd.rb/psd-imagemode-rgb-combine-rgb-channel.rb +65 -0
- data/benchmarks/psd.rb/psd-renderer-blender-compose.rb +113 -0
- data/benchmarks/psd.rb/psd-renderer-clippingmask-apply.rb +129 -0
- data/benchmarks/psd.rb/psd-renderer-mask-apply.rb +137 -0
- data/benchmarks/psd.rb/psd-util-clamp.rb +42 -0
- data/benchmarks/psd.rb/psd-util-pad2.rb +42 -0
- data/benchmarks/psd.rb/psd-util-pad4.rb +42 -0
- data/benchmarks/psd.rb/psd_native.patch +99 -0
- data/benchmarks/psd.rb/version.txt +2 -0
- data/benchmarks/topaz/neural-net.rb +208 -0
- data/benchmarks/vm/codeload.rb +35 -0
- data/benchmarks/vm/fixtures/codeload/LICENSE.txt +25 -0
- data/benchmarks/vm/fixtures/codeload/lexer.rb +21493 -0
- data/bin/bench9000 +13 -0
- data/example/report.data +945 -0
- data/example/report.html +59178 -0
- data/lib/bench9000.rb +27 -0
- data/lib/bench9000/benchmark.rb +29 -0
- data/lib/bench9000/commands/command.rb +30 -0
- data/lib/bench9000/commands/compare-reference.rb +70 -0
- data/lib/bench9000/commands/compare.rb +43 -0
- data/lib/bench9000/commands/detail.rb +51 -0
- data/lib/bench9000/commands/list-benchmarks.rb +29 -0
- data/lib/bench9000/commands/list-implementations.rb +29 -0
- data/lib/bench9000/commands/reference.rb +46 -0
- data/lib/bench9000/commands/remove.rb +41 -0
- data/lib/bench9000/commands/report.rb +71 -0
- data/lib/bench9000/commands/score.rb +27 -0
- data/lib/bench9000/config.rb +88 -0
- data/lib/bench9000/group.rb +23 -0
- data/lib/bench9000/harness.rb +68 -0
- data/lib/bench9000/implementation.rb +134 -0
- data/lib/bench9000/json-formatter.rb +50 -0
- data/lib/bench9000/main.rb +268 -0
- data/lib/bench9000/measurement.rb +75 -0
- data/lib/bench9000/micro-harness.rb +39 -0
- data/lib/bench9000/options.rb +31 -0
- data/lib/bench9000/report/bootstrap-theme.css +5 -0
- data/lib/bench9000/report/bootstrap.css +5 -0
- data/lib/bench9000/report/bootstrap.js +6 -0
- data/lib/bench9000/report/chart.js +3432 -0
- data/lib/bench9000/report/chartjs.patch +91 -0
- data/lib/bench9000/report/jquery.js +4 -0
- data/lib/bench9000/report/report.html +177 -0
- data/lib/bench9000/report/report.js +547 -0
- data/lib/bench9000/stats.rb +41 -0
- data/readme.md +205 -0
- data/vendor/chunky_png/BENCHMARKS.rdoc +31 -0
- data/vendor/chunky_png/Gemfile +10 -0
- data/vendor/chunky_png/LICENSE +20 -0
- data/vendor/chunky_png/README.rdoc +84 -0
- data/vendor/chunky_png/Rakefile +11 -0
- data/vendor/chunky_png/benchmarks/decoding_benchmark.rb +36 -0
- data/vendor/chunky_png/benchmarks/encoding_benchmark.rb +40 -0
- data/vendor/chunky_png/benchmarks/filesize_benchmark.rb +28 -0
- data/vendor/chunky_png/chunky_png.gemspec +47 -0
- data/vendor/chunky_png/lib/chunky_png.rb +160 -0
- data/vendor/chunky_png/lib/chunky_png/canvas.rb +372 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/adam7_interlacing.rb +72 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/data_url_exporting.rb +15 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/data_url_importing.rb +21 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/drawing.rb +338 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/masking.rb +91 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/operations.rb +395 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/png_decoding.rb +492 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/png_encoding.rb +442 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/resampling.rb +147 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/stream_exporting.rb +58 -0
- data/vendor/chunky_png/lib/chunky_png/canvas/stream_importing.rb +77 -0
- data/vendor/chunky_png/lib/chunky_png/chunk.rb +328 -0
- data/vendor/chunky_png/lib/chunky_png/color.rb +780 -0
- data/vendor/chunky_png/lib/chunky_png/compatibility.rb +15 -0
- data/vendor/chunky_png/lib/chunky_png/datastream.rb +185 -0
- data/vendor/chunky_png/lib/chunky_png/dimension.rb +113 -0
- data/vendor/chunky_png/lib/chunky_png/image.rb +79 -0
- data/vendor/chunky_png/lib/chunky_png/palette.rb +209 -0
- data/vendor/chunky_png/lib/chunky_png/point.rb +115 -0
- data/vendor/chunky_png/lib/chunky_png/rmagick.rb +43 -0
- data/vendor/chunky_png/lib/chunky_png/vector.rb +186 -0
- data/vendor/chunky_png/lib/chunky_png/version.rb +5 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/adam7_interlacing_spec.rb +106 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/data_url_exporting_spec.rb +13 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/data_url_importing_spec.rb +15 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/drawing_spec.rb +170 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/masking_spec.rb +51 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/operations_spec.rb +388 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/png_decoding_spec.rb +97 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/png_encoding_spec.rb +235 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/resampling_spec.rb +121 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/stream_exporting_spec.rb +59 -0
- data/vendor/chunky_png/spec/chunky_png/canvas/stream_importing_spec.rb +31 -0
- data/vendor/chunky_png/spec/chunky_png/canvas_spec.rb +226 -0
- data/vendor/chunky_png/spec/chunky_png/color_spec.rb +251 -0
- data/vendor/chunky_png/spec/chunky_png/datastream_spec.rb +32 -0
- data/vendor/chunky_png/spec/chunky_png/dimension_spec.rb +48 -0
- data/vendor/chunky_png/spec/chunky_png/image_spec.rb +25 -0
- data/vendor/chunky_png/spec/chunky_png/point_spec.rb +76 -0
- data/vendor/chunky_png/spec/chunky_png/rmagick_spec.rb +23 -0
- data/vendor/chunky_png/spec/chunky_png/vector_spec.rb +104 -0
- data/vendor/chunky_png/spec/chunky_png_spec.rb +8 -0
- data/vendor/chunky_png/spec/png_suite/background_chunks/bgai4a08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/background_chunks/bgai4a16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/background_chunks/bgan6a08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/background_chunks/bgan6a16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/background_chunks/bgbn4a08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/background_chunks/bggn4a16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/background_chunks/bgwn6a08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/background_chunks/bgyn6a16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi0g01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi0g01.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi0g02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi0g02.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi0g04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi0g04.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi0g08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi0g08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi0g16.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi2c08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi2c16.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi3p01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi3p01.rgba +1 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi3p02.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi3p04.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi3p08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi4a08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi4a08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi4a16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi4a16.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi6a08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi6a08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi6a16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basi6a16.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn0g01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn0g01.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn0g02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn0g02.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn0g04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn0g04.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn0g08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn0g08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn0g16.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn2c08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn2c16.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn3p01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn3p01.rgba +1 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn3p02.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn3p04.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn3p08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn4a08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn4a08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn4a16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn4a16.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn6a08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn6a08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn6a16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/basic/basn6a16.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/broken/x00n0g01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/broken/xcrn0g04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/broken/xlfn0g04.png +13 -0
- data/vendor/chunky_png/spec/png_suite/chunk_ordering/oi1n0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/chunk_ordering/oi1n2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/chunk_ordering/oi2n0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/chunk_ordering/oi2n2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/chunk_ordering/oi4n0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/chunk_ordering/oi4n2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/chunk_ordering/oi9n0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/chunk_ordering/oi9n2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/compression_levels/z00n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/compression_levels/z03n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/compression_levels/z06n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/compression_levels/z09n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f00n0g08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f00n0g08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f00n0g08_reference.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f00n0g08_reference.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f00n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f00n2c08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f00n2c08_reference.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f00n2c08_reference.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f01n0g08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f01n0g08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f01n0g08_reference.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f01n0g08_reference.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f01n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f01n2c08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f01n2c08_reference.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f01n2c08_reference.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f02n0g08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f02n0g08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f02n0g08_reference.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f02n0g08_reference.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f02n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f02n2c08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f02n2c08_reference.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f02n2c08_reference.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f03n0g08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f03n0g08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f03n0g08_reference.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f03n0g08_reference.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f03n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f03n2c08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f03n2c08_reference.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f03n2c08_reference.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f04n0g08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f04n0g08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f04n0g08_reference.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f04n0g08_reference.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f04n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f04n2c08.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f04n2c08_reference.png +0 -0
- data/vendor/chunky_png/spec/png_suite/filtering/f04n2c08_reference.rgba +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g03n0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g03n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g03n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g04n0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g04n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g04n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g05n0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g05n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g05n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g07n0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g07n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g07n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g10n0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g10n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g10n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g25n0g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g25n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/gamma/g25n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/metadata/cm0n0g04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/metadata/cm7n0g04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/metadata/cm9n0g04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ccwn2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ccwn3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/cdfn2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/cdhn2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/cdsn2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/cdun2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ch1n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ch2n3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/cs3n2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/cs3n3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/cs5n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/cs5n3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/cs8n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/cs8n3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ct0n0g04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ct1n0g04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ctzn0g04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/pp0n2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/pp0n6a08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ps1n0g08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ps1n2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ps2n0g08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/other/ps2n2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s01i3p01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s01n3p01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s02i3p01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s02n3p01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s03i3p01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s03n3p01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s04i3p01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s04n3p01.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s05i3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s05n3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s06i3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s06n3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s07i3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s07n3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s08i3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s08n3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s09i3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s09n3p02.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s32i3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s32n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s33i3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s33n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s34i3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s34n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s35i3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s35n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s36i3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s36n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s37i3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s37n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s38i3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s38n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s39i3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s39n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s40i3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/sizes/s40n3p04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tbbn1g04.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tbbn2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tbbn3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tbgn2c16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tbgn3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tbrn2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tbwn1g16.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tbwn3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tbyn3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tp0n1g08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tp0n2c08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tp0n3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite/transparency/tp1n3p08.png +0 -0
- data/vendor/chunky_png/spec/png_suite_spec.rb +121 -0
- data/vendor/chunky_png/spec/resources/adam7.png +0 -0
- data/vendor/chunky_png/spec/resources/bezier_five_point.png +0 -0
- data/vendor/chunky_png/spec/resources/bezier_four_point.png +0 -0
- data/vendor/chunky_png/spec/resources/bezier_four_point_flipped.png +0 -0
- data/vendor/chunky_png/spec/resources/bezier_four_point_s.png +0 -0
- data/vendor/chunky_png/spec/resources/bezier_six_point.png +0 -0
- data/vendor/chunky_png/spec/resources/bezier_three_point.png +0 -0
- data/vendor/chunky_png/spec/resources/bezier_three_point_flipped.png +0 -0
- data/vendor/chunky_png/spec/resources/circles.png +0 -0
- data/vendor/chunky_png/spec/resources/clock.png +0 -0
- data/vendor/chunky_png/spec/resources/clock_base.png +0 -0
- data/vendor/chunky_png/spec/resources/clock_bl_xdown_ydown.png +0 -0
- data/vendor/chunky_png/spec/resources/clock_bl_xdown_yup.png +0 -0
- data/vendor/chunky_png/spec/resources/clock_bl_xup_yup.png +0 -0
- data/vendor/chunky_png/spec/resources/clock_mask.png +0 -0
- data/vendor/chunky_png/spec/resources/clock_mask_updated.png +0 -0
- data/vendor/chunky_png/spec/resources/clock_nn_xdown_ydown.png +0 -0
- data/vendor/chunky_png/spec/resources/clock_nn_xdown_yup.png +0 -0
- data/vendor/chunky_png/spec/resources/clock_nn_xup_yup.png +0 -0
- data/vendor/chunky_png/spec/resources/clock_updated.png +0 -0
- data/vendor/chunky_png/spec/resources/composited.png +0 -0
- data/vendor/chunky_png/spec/resources/cropped.png +0 -0
- data/vendor/chunky_png/spec/resources/damaged_chunk.png +0 -0
- data/vendor/chunky_png/spec/resources/damaged_signature.png +13 -0
- data/vendor/chunky_png/spec/resources/lines.png +0 -0
- data/vendor/chunky_png/spec/resources/operations.png +0 -0
- data/vendor/chunky_png/spec/resources/operations_border.png +0 -0
- data/vendor/chunky_png/spec/resources/operations_grayscale.png +0 -0
- data/vendor/chunky_png/spec/resources/partial_circles.png +0 -0
- data/vendor/chunky_png/spec/resources/pixelstream.bgr +67 -0
- data/vendor/chunky_png/spec/resources/pixelstream.rgb +67 -1
- data/vendor/chunky_png/spec/resources/pixelstream.rgba +67 -0
- data/vendor/chunky_png/spec/resources/pixelstream_best_compression.png +0 -0
- data/vendor/chunky_png/spec/resources/pixelstream_fast_rgba.png +0 -0
- data/vendor/chunky_png/spec/resources/pixelstream_reference.png +0 -0
- data/vendor/chunky_png/spec/resources/polygon_filled_horizontal.png +0 -0
- data/vendor/chunky_png/spec/resources/polygon_filled_vertical.png +0 -0
- data/vendor/chunky_png/spec/resources/polygon_triangle_filled.png +0 -0
- data/vendor/chunky_png/spec/resources/polygon_unfilled.png +0 -0
- data/vendor/chunky_png/spec/resources/rect.png +0 -0
- data/vendor/chunky_png/spec/resources/replaced.png +0 -0
- data/vendor/chunky_png/spec/resources/text_chunk.png +0 -0
- data/vendor/chunky_png/spec/resources/ztxt_chunk.png +0 -0
- data/vendor/chunky_png/spec/spec_helper.rb +52 -0
- data/vendor/chunky_png/tasks/benchmarks.rake +26 -0
- data/vendor/oily_png/Gemfile +4 -0
- data/vendor/oily_png/LICENSE +20 -0
- data/vendor/oily_png/README.rdoc +26 -0
- data/vendor/oily_png/Rakefile +19 -0
- data/vendor/oily_png/ext/oily_png/color.c +58 -0
- data/vendor/oily_png/ext/oily_png/color.h +29 -0
- data/vendor/oily_png/ext/oily_png/extconf.rb +3 -0
- data/vendor/oily_png/ext/oily_png/oily_png_ext.c +59 -0
- data/vendor/oily_png/ext/oily_png/oily_png_ext.h +72 -0
- data/vendor/oily_png/ext/oily_png/operations.c +122 -0
- data/vendor/oily_png/ext/oily_png/operations.h +36 -0
- data/vendor/oily_png/ext/oily_png/png_decoding.c +374 -0
- data/vendor/oily_png/ext/oily_png/png_decoding.h +27 -0
- data/vendor/oily_png/ext/oily_png/png_encoding.c +302 -0
- data/vendor/oily_png/ext/oily_png/png_encoding.h +19 -0
- data/vendor/oily_png/ext/oily_png/resampling.c +213 -0
- data/vendor/oily_png/ext/oily_png/resampling.h +25 -0
- data/vendor/oily_png/lib/oily_png.rb +21 -0
- data/vendor/oily_png/lib/oily_png/canvas.rb +15 -0
- data/vendor/oily_png/lib/oily_png/version.rb +3 -0
- data/vendor/oily_png/oily_png.gemspec +39 -0
- data/vendor/oily_png/spec/color_spec.rb +38 -0
- data/vendor/oily_png/spec/decoding_spec.rb +51 -0
- data/vendor/oily_png/spec/encoding_spec.rb +135 -0
- data/vendor/oily_png/spec/operations_spec.rb +52 -0
- data/vendor/oily_png/spec/resampling_spec.rb +51 -0
- data/vendor/oily_png/spec/resources/basi0g01.png +0 -0
- data/vendor/oily_png/spec/resources/basi0g02.png +0 -0
- data/vendor/oily_png/spec/resources/basi0g04.png +0 -0
- data/vendor/oily_png/spec/resources/basi0g08.png +0 -0
- data/vendor/oily_png/spec/resources/basi0g16.png +0 -0
- data/vendor/oily_png/spec/resources/basi2c08.png +0 -0
- data/vendor/oily_png/spec/resources/basi2c16.png +0 -0
- data/vendor/oily_png/spec/resources/basi3p01.png +0 -0
- data/vendor/oily_png/spec/resources/basi3p02.png +0 -0
- data/vendor/oily_png/spec/resources/basi3p04.png +0 -0
- data/vendor/oily_png/spec/resources/basi3p08.png +0 -0
- data/vendor/oily_png/spec/resources/basi4a08.png +0 -0
- data/vendor/oily_png/spec/resources/basi4a16.png +0 -0
- data/vendor/oily_png/spec/resources/basi6a08.png +0 -0
- data/vendor/oily_png/spec/resources/basi6a16.png +0 -0
- data/vendor/oily_png/spec/resources/basn0g01.png +0 -0
- data/vendor/oily_png/spec/resources/basn0g02.png +0 -0
- data/vendor/oily_png/spec/resources/basn0g04.png +0 -0
- data/vendor/oily_png/spec/resources/basn0g08.png +0 -0
- data/vendor/oily_png/spec/resources/basn0g16.png +0 -0
- data/vendor/oily_png/spec/resources/basn2c08.png +0 -0
- data/vendor/oily_png/spec/resources/basn2c16.png +0 -0
- data/vendor/oily_png/spec/resources/basn3p01.png +0 -0
- data/vendor/oily_png/spec/resources/basn3p02.png +0 -0
- data/vendor/oily_png/spec/resources/basn3p04.png +0 -0
- data/vendor/oily_png/spec/resources/basn3p08.png +0 -0
- data/vendor/oily_png/spec/resources/basn4a08.png +0 -0
- data/vendor/oily_png/spec/resources/basn4a16.png +0 -0
- data/vendor/oily_png/spec/resources/basn6a08.png +0 -0
- data/vendor/oily_png/spec/resources/basn6a16.png +0 -0
- data/vendor/oily_png/spec/resources/composited.png +0 -0
- data/vendor/oily_png/spec/resources/gray.png +0 -0
- data/vendor/oily_png/spec/resources/interlaced.png +0 -0
- data/vendor/oily_png/spec/resources/nonsquare.png +0 -0
- data/vendor/oily_png/spec/resources/operations.png +0 -0
- data/vendor/oily_png/spec/resources/replaced.png +0 -0
- data/vendor/oily_png/spec/resources/s01i3p01.png +0 -0
- data/vendor/oily_png/spec/resources/s01n3p01.png +0 -0
- data/vendor/oily_png/spec/resources/s02i3p01.png +0 -0
- data/vendor/oily_png/spec/resources/s02n3p01.png +0 -0
- data/vendor/oily_png/spec/resources/s03i3p01.png +0 -0
- data/vendor/oily_png/spec/resources/s03n3p01.png +0 -0
- data/vendor/oily_png/spec/resources/s04i3p01.png +0 -0
- data/vendor/oily_png/spec/resources/s04n3p01.png +0 -0
- data/vendor/oily_png/spec/resources/s05i3p02.png +0 -0
- data/vendor/oily_png/spec/resources/s05n3p02.png +0 -0
- data/vendor/oily_png/spec/resources/s06i3p02.png +0 -0
- data/vendor/oily_png/spec/resources/s06n3p02.png +0 -0
- data/vendor/oily_png/spec/resources/s07i3p02.png +0 -0
- data/vendor/oily_png/spec/resources/s07n3p02.png +0 -0
- data/vendor/oily_png/spec/resources/s08i3p02.png +0 -0
- data/vendor/oily_png/spec/resources/s08n3p02.png +0 -0
- data/vendor/oily_png/spec/resources/s09i3p02.png +0 -0
- data/vendor/oily_png/spec/resources/s09n3p02.png +0 -0
- data/vendor/oily_png/spec/resources/s32i3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s32n3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s33i3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s33n3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s34i3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s34n3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s35i3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s35n3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s36i3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s36n3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s37i3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s37n3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s38i3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s38n3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s39i3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s39n3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s40i3p04.png +0 -0
- data/vendor/oily_png/spec/resources/s40n3p04.png +0 -0
- data/vendor/oily_png/spec/resources/square.png +0 -0
- data/vendor/oily_png/spec/resources/tbbn1g04.png +0 -0
- data/vendor/oily_png/spec/resources/tbbn2c16.png +0 -0
- data/vendor/oily_png/spec/resources/tbbn3p08.png +0 -0
- data/vendor/oily_png/spec/resources/tbgn2c16.png +0 -0
- data/vendor/oily_png/spec/resources/tbgn3p08.png +0 -0
- data/vendor/oily_png/spec/resources/tbrn2c08.png +0 -0
- data/vendor/oily_png/spec/resources/tbwn1g16.png +0 -0
- data/vendor/oily_png/spec/resources/tbwn3p08.png +0 -0
- data/vendor/oily_png/spec/resources/tbyn3p08.png +0 -0
- data/vendor/oily_png/spec/resources/tp0n1g08.png +0 -0
- data/vendor/oily_png/spec/resources/tp0n2c08.png +0 -0
- data/vendor/oily_png/spec/resources/tp0n3p08.png +0 -0
- data/vendor/oily_png/spec/resources/tp1n3p08.png +0 -0
- data/vendor/oily_png/spec/spec_helper.rb +40 -0
- data/vendor/oily_png/tasks/testing.rake +49 -0
- data/vendor/psd.rb/CONTRIBUTING.md +7 -0
- data/vendor/psd.rb/Gemfile +2 -0
- data/vendor/psd.rb/Guardfile +8 -0
- data/vendor/psd.rb/LICENSE.txt +22 -0
- data/vendor/psd.rb/README.md +235 -0
- data/vendor/psd.rb/Rakefile +6 -0
- data/vendor/psd.rb/circle.yml +6 -0
- data/vendor/psd.rb/examples/build_image.rb +16 -0
- data/vendor/psd.rb/examples/export_image.rb +12 -0
- data/vendor/psd.rb/examples/export_layer_images.rb +19 -0
- data/vendor/psd.rb/examples/export_node.rb +7 -0
- data/vendor/psd.rb/examples/export_text_data.rb +13 -0
- data/vendor/psd.rb/examples/guides.rb +17 -0
- data/vendor/psd.rb/examples/images/comp-example.psd +0 -0
- data/vendor/psd.rb/examples/images/example-cmyk.psd +0 -0
- data/vendor/psd.rb/examples/images/example-greyscale.psd +0 -0
- data/vendor/psd.rb/examples/images/example-nocompat.psd +0 -0
- data/vendor/psd.rb/examples/images/example.psd +0 -0
- data/vendor/psd.rb/examples/images/example16.psd +0 -0
- data/vendor/psd.rb/examples/images/guides.psd +0 -0
- data/vendor/psd.rb/examples/layer_comps.rb +20 -0
- data/vendor/psd.rb/examples/parse.rb +36 -0
- data/vendor/psd.rb/examples/path.rb +7 -0
- data/vendor/psd.rb/examples/profile.rb +15 -0
- data/vendor/psd.rb/examples/slices.rb +17 -0
- data/vendor/psd.rb/examples/tree.rb +8 -0
- data/vendor/psd.rb/examples/unimplemented_info.rb +9 -0
- data/vendor/psd.rb/lib/psd.rb +173 -0
- data/vendor/psd.rb/lib/psd/blend_mode.rb +80 -0
- data/vendor/psd.rb/lib/psd/channel_image.rb +115 -0
- data/vendor/psd.rb/lib/psd/color.rb +125 -0
- data/vendor/psd.rb/lib/psd/descriptor.rb +200 -0
- data/vendor/psd.rb/lib/psd/file.rb +104 -0
- data/vendor/psd.rb/lib/psd/header.rb +69 -0
- data/vendor/psd.rb/lib/psd/helpers.rb +51 -0
- data/vendor/psd.rb/lib/psd/image.rb +123 -0
- data/vendor/psd.rb/lib/psd/image_exports/png.rb +31 -0
- data/vendor/psd.rb/lib/psd/image_formats/layer_raw.rb +21 -0
- data/vendor/psd.rb/lib/psd/image_formats/layer_rle.rb +24 -0
- data/vendor/psd.rb/lib/psd/image_formats/raw.rb +12 -0
- data/vendor/psd.rb/lib/psd/image_formats/rle.rb +63 -0
- data/vendor/psd.rb/lib/psd/image_modes/cmyk.rb +31 -0
- data/vendor/psd.rb/lib/psd/image_modes/greyscale.rb +22 -0
- data/vendor/psd.rb/lib/psd/image_modes/rgb.rb +32 -0
- data/vendor/psd.rb/lib/psd/layer.rb +77 -0
- data/vendor/psd.rb/lib/psd/layer/blend_modes.rb +30 -0
- data/vendor/psd.rb/lib/psd/layer/blending_ranges.rb +62 -0
- data/vendor/psd.rb/lib/psd/layer/channel_image.rb +15 -0
- data/vendor/psd.rb/lib/psd/layer/exporting.rb +28 -0
- data/vendor/psd.rb/lib/psd/layer/helpers.rb +77 -0
- data/vendor/psd.rb/lib/psd/layer/info.rb +74 -0
- data/vendor/psd.rb/lib/psd/layer/mask.rb +19 -0
- data/vendor/psd.rb/lib/psd/layer/name.rb +33 -0
- data/vendor/psd.rb/lib/psd/layer/path_components.rb +22 -0
- data/vendor/psd.rb/lib/psd/layer/position_and_channels.rb +47 -0
- data/vendor/psd.rb/lib/psd/layer_info.rb +27 -0
- data/vendor/psd.rb/lib/psd/layer_info/blend_clipping_elements.rb +13 -0
- data/vendor/psd.rb/lib/psd/layer_info/blend_interior_elements.rb +13 -0
- data/vendor/psd.rb/lib/psd/layer_info/fill_opacity.rb +13 -0
- data/vendor/psd.rb/lib/psd/layer_info/layer_group.rb +30 -0
- data/vendor/psd.rb/lib/psd/layer_info/layer_id.rb +13 -0
- data/vendor/psd.rb/lib/psd/layer_info/layer_name_source.rb +14 -0
- data/vendor/psd.rb/lib/psd/layer_info/layer_section_divider.rb +48 -0
- data/vendor/psd.rb/lib/psd/layer_info/legacy_typetool.rb +88 -0
- data/vendor/psd.rb/lib/psd/layer_info/locked.rb +19 -0
- data/vendor/psd.rb/lib/psd/layer_info/metadata_setting.rb +35 -0
- data/vendor/psd.rb/lib/psd/layer_info/object_effects.rb +16 -0
- data/vendor/psd.rb/lib/psd/layer_info/placed_layer.rb +13 -0
- data/vendor/psd.rb/lib/psd/layer_info/reference_point.rb +16 -0
- data/vendor/psd.rb/lib/psd/layer_info/typetool.rb +165 -0
- data/vendor/psd.rb/lib/psd/layer_info/unicode_name.rb +17 -0
- data/vendor/psd.rb/lib/psd/layer_info/vector_mask.rb +25 -0
- data/vendor/psd.rb/lib/psd/layer_info/vector_mask_2.rb +10 -0
- data/vendor/psd.rb/lib/psd/layer_info/vector_stroke.rb +12 -0
- data/vendor/psd.rb/lib/psd/layer_info/vector_stroke_content.rb +15 -0
- data/vendor/psd.rb/lib/psd/layer_mask.rb +129 -0
- data/vendor/psd.rb/lib/psd/lazy_execute.rb +60 -0
- data/vendor/psd.rb/lib/psd/logger.rb +40 -0
- data/vendor/psd.rb/lib/psd/mask.rb +74 -0
- data/vendor/psd.rb/lib/psd/node.rb +70 -0
- data/vendor/psd.rb/lib/psd/node_exporting.rb +20 -0
- data/vendor/psd.rb/lib/psd/node_group.rb +86 -0
- data/vendor/psd.rb/lib/psd/node_layer.rb +81 -0
- data/vendor/psd.rb/lib/psd/node_root.rb +93 -0
- data/vendor/psd.rb/lib/psd/nodes/ancestry.rb +98 -0
- data/vendor/psd.rb/lib/psd/nodes/build_preview.rb +17 -0
- data/vendor/psd.rb/lib/psd/nodes/has_children.rb +13 -0
- data/vendor/psd.rb/lib/psd/nodes/lock_to_origin.rb +7 -0
- data/vendor/psd.rb/lib/psd/nodes/parse_layers.rb +18 -0
- data/vendor/psd.rb/lib/psd/nodes/search.rb +91 -0
- data/vendor/psd.rb/lib/psd/path_record.rb +180 -0
- data/vendor/psd.rb/lib/psd/renderer.rb +91 -0
- data/vendor/psd.rb/lib/psd/renderer/blender.rb +53 -0
- data/vendor/psd.rb/lib/psd/renderer/canvas.rb +95 -0
- data/vendor/psd.rb/lib/psd/renderer/canvas_management.rb +26 -0
- data/vendor/psd.rb/lib/psd/renderer/clipping_mask.rb +41 -0
- data/vendor/psd.rb/lib/psd/renderer/compose.rb +361 -0
- data/vendor/psd.rb/lib/psd/renderer/layer_styles.rb +56 -0
- data/vendor/psd.rb/lib/psd/renderer/layer_styles/color_overlay.rb +65 -0
- data/vendor/psd.rb/lib/psd/renderer/layer_styles/drop_shadow.rb +75 -0
- data/vendor/psd.rb/lib/psd/renderer/mask.rb +46 -0
- data/vendor/psd.rb/lib/psd/resource.rb +26 -0
- data/vendor/psd.rb/lib/psd/resource_section.rb +22 -0
- data/vendor/psd.rb/lib/psd/resources.rb +69 -0
- data/vendor/psd.rb/lib/psd/resources/guides.rb +35 -0
- data/vendor/psd.rb/lib/psd/resources/layer_comps.rb +42 -0
- data/vendor/psd.rb/lib/psd/resources/slices.rb +132 -0
- data/vendor/psd.rb/lib/psd/section.rb +26 -0
- data/vendor/psd.rb/lib/psd/util.rb +18 -0
- data/vendor/psd.rb/lib/psd/version.rb +3 -0
- data/vendor/psd.rb/psd.gemspec +32 -0
- data/vendor/psd.rb/spec/files/blendmodes.psd +0 -0
- data/vendor/psd.rb/spec/files/empty-layer-subgroups.psd +0 -0
- data/vendor/psd.rb/spec/files/empty-layer.psd +0 -0
- data/vendor/psd.rb/spec/files/example.psd +0 -0
- data/vendor/psd.rb/spec/files/guides.psd +0 -0
- data/vendor/psd.rb/spec/files/locked.psd +0 -0
- data/vendor/psd.rb/spec/files/one_layer.psd +0 -0
- data/vendor/psd.rb/spec/files/path.psd +0 -0
- data/vendor/psd.rb/spec/files/pixel.psd +0 -0
- data/vendor/psd.rb/spec/files/simplest.psd +0 -0
- data/vendor/psd.rb/spec/files/slices.psd +0 -0
- data/vendor/psd.rb/spec/files/text.psd +0 -0
- data/vendor/psd.rb/spec/guides_spec.rb +34 -0
- data/vendor/psd.rb/spec/hierarchy_spec.rb +152 -0
- data/vendor/psd.rb/spec/image_spec.rb +86 -0
- data/vendor/psd.rb/spec/lazy_execute_spec.rb +20 -0
- data/vendor/psd.rb/spec/locked_spec.rb +78 -0
- data/vendor/psd.rb/spec/parsing_spec.rb +163 -0
- data/vendor/psd.rb/spec/psd_spec.rb +37 -0
- data/vendor/psd.rb/spec/slices_spec.rb +57 -0
- data/vendor/psd.rb/spec/spec_helper.rb +13 -0
- data/vendor/psd.rb/spec/text_spec.rb +27 -0
- data/vendor/psd_native/Gemfile +4 -0
- data/vendor/psd_native/Guardfile +6 -0
- data/vendor/psd_native/LICENSE.txt +22 -0
- data/vendor/psd_native/README.md +48 -0
- data/vendor/psd_native/Rakefile +13 -0
- data/vendor/psd_native/ext/psd_native/blender.c +57 -0
- data/vendor/psd_native/ext/psd_native/blender.h +6 -0
- data/vendor/psd_native/ext/psd_native/canvas.c +9 -0
- data/vendor/psd_native/ext/psd_native/canvas.h +6 -0
- data/vendor/psd_native/ext/psd_native/clipping_mask.c +57 -0
- data/vendor/psd_native/ext/psd_native/clipping_mask.h +6 -0
- data/vendor/psd_native/ext/psd_native/color.c +20 -0
- data/vendor/psd_native/ext/psd_native/color.h +18 -0
- data/vendor/psd_native/ext/psd_native/compose.c +394 -0
- data/vendor/psd_native/ext/psd_native/compose.h +43 -0
- data/vendor/psd_native/ext/psd_native/extconf.rb +3 -0
- data/vendor/psd_native/ext/psd_native/file.c +20 -0
- data/vendor/psd_native/ext/psd_native/file.h +9 -0
- data/vendor/psd_native/ext/psd_native/image_mode_cmyk.c +64 -0
- data/vendor/psd_native/ext/psd_native/image_mode_cmyk.h +6 -0
- data/vendor/psd_native/ext/psd_native/image_mode_greyscale.c +27 -0
- data/vendor/psd_native/ext/psd_native/image_mode_greyscale.h +6 -0
- data/vendor/psd_native/ext/psd_native/image_mode_rgb.c +49 -0
- data/vendor/psd_native/ext/psd_native/image_mode_rgb.h +6 -0
- data/vendor/psd_native/ext/psd_native/layer_raw.c +20 -0
- data/vendor/psd_native/ext/psd_native/layer_raw.h +6 -0
- data/vendor/psd_native/ext/psd_native/mask.c +52 -0
- data/vendor/psd_native/ext/psd_native/mask.h +6 -0
- data/vendor/psd_native/ext/psd_native/psd_native_ext.c +87 -0
- data/vendor/psd_native/ext/psd_native/psd_native_ext.h +31 -0
- data/vendor/psd_native/ext/psd_native/rle_decoding.c +53 -0
- data/vendor/psd_native/ext/psd_native/rle_decoding.h +6 -0
- data/vendor/psd_native/ext/psd_native/util.c +17 -0
- data/vendor/psd_native/ext/psd_native/util.h +8 -0
- data/vendor/psd_native/lib/psd_native.rb +35 -0
- data/vendor/psd_native/lib/psd_native/compose.rb +19 -0
- data/vendor/psd_native/lib/psd_native/version.rb +3 -0
- data/vendor/psd_native/psd_native.gemspec +35 -0
- data/vendor/psd_native/spec/files/example.psd +0 -0
- data/vendor/psd_native/spec/files/one_layer.psd +0 -0
- data/vendor/psd_native/spec/files/path.psd +0 -0
- data/vendor/psd_native/spec/files/pixel.psd +0 -0
- data/vendor/psd_native/spec/files/simplest.psd +0 -0
- data/vendor/psd_native/spec/files/text.psd +0 -0
- data/vendor/psd_native/spec/image_spec.rb +86 -0
- data/vendor/psd_native/spec/psd_spec.rb +37 -0
- data/vendor/psd_native/spec/spec_helper.rb +13 -0
- data/vendor/psd_native/spec/util_spec.rb +15 -0
- metadata +767 -0
@@ -0,0 +1,780 @@
|
|
1
|
+
module ChunkyPNG
|
2
|
+
|
3
|
+
# Factory method to return a color value, based on the arguments given.
|
4
|
+
#
|
5
|
+
# @overload Color(r, g, b, a)
|
6
|
+
# @param (see ChunkyPNG::Color.rgba)
|
7
|
+
# @return [Integer] The rgba color value.
|
8
|
+
#
|
9
|
+
# @overload Color(r, g, b)
|
10
|
+
# @param (see ChunkyPNG::Color.rgb)
|
11
|
+
# @return [Integer] The rgb color value.
|
12
|
+
#
|
13
|
+
# @overload Color(hex_value, opacity = nil)
|
14
|
+
# @param (see ChunkyPNG::Color.from_hex)
|
15
|
+
# @return [Integer] The hex color value, with the opacity applied if one
|
16
|
+
# was given.
|
17
|
+
#
|
18
|
+
# @overload Color(color_name, opacity = nil)
|
19
|
+
# @param (see ChunkyPNG::Color.html_color)
|
20
|
+
# @return [Integer] The hex color value, with the opacity applied if one
|
21
|
+
# was given.
|
22
|
+
#
|
23
|
+
# @overload Color(color_value, opacity = nil)
|
24
|
+
# @param [Integer, :to_i] The color value.
|
25
|
+
# @return [Integer] The color value, with the opacity applied if one was
|
26
|
+
# given.
|
27
|
+
#
|
28
|
+
# @return [Integer] The determined color value as RGBA integer.
|
29
|
+
# @raise [ArgumentError] if the arguments weren't understood as a color.
|
30
|
+
# @see ChunkyPNG::Color
|
31
|
+
# @see ChunkyPNG::Color.parse
|
32
|
+
def self.Color(*args)
|
33
|
+
case args.length
|
34
|
+
when 1; ChunkyPNG::Color.parse(args.first)
|
35
|
+
when 2; (ChunkyPNG::Color.parse(args.first) & 0xffffff00) | args[1].to_i
|
36
|
+
when 3; ChunkyPNG::Color.rgb(*args)
|
37
|
+
when 4; ChunkyPNG::Color.rgba(*args)
|
38
|
+
else raise ArgumentError, "Don't know how to create a color from #{args.inspect}!"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# The Color module defines methods for handling colors. Within the ChunkyPNG
|
43
|
+
# library, the concepts of pixels and colors are both used, and they are
|
44
|
+
# both represented by a Integer.
|
45
|
+
#
|
46
|
+
# Pixels/colors are represented in RGBA components. Each of the four
|
47
|
+
# components is stored with a depth of 8 bits (maximum value = 255 =
|
48
|
+
# {ChunkyPNG::Color::MAX}). Together, these components are stored in a 4-byte
|
49
|
+
# Integer.
|
50
|
+
#
|
51
|
+
# A color will always be represented using these 4 components in memory.
|
52
|
+
# When the image is encoded, a more suitable representation can be used
|
53
|
+
# (e.g. rgb, grayscale, palette-based), for which several conversion methods
|
54
|
+
# are provided in this module.
|
55
|
+
module Color
|
56
|
+
extend self
|
57
|
+
|
58
|
+
# @return [Integer] The maximum value of each color component.
|
59
|
+
MAX = 0xff
|
60
|
+
|
61
|
+
# @private
|
62
|
+
# @return [Regexp] The regexp to parse 3-digit hex color values.
|
63
|
+
HEX3_COLOR_REGEXP = /\A(?:#|0x)?([0-9a-f]{3})\z/i
|
64
|
+
|
65
|
+
# @private
|
66
|
+
# @return [Regexp] The regexp to parse 6- and 8-digit hex color values.
|
67
|
+
HEX6_COLOR_REGEXP = /\A(?:#|0x)?([0-9a-f]{6})([0-9a-f]{2})?\z/i
|
68
|
+
|
69
|
+
# @private
|
70
|
+
# @return [Regexp] The regexp to parse named color values.
|
71
|
+
HTML_COLOR_REGEXP = /^([a-z][a-z_ ]+[a-z])(?:\ ?\@\ ?(1\.0|0\.\d+))?$/i
|
72
|
+
|
73
|
+
####################################################################
|
74
|
+
# CONSTRUCTING COLOR VALUES
|
75
|
+
####################################################################
|
76
|
+
|
77
|
+
# Parses a color value given a numeric or string argument.
|
78
|
+
#
|
79
|
+
# It supports color numbers, colors in hex notation and named HTML colors.
|
80
|
+
#
|
81
|
+
# @param [Integer, String] The color value.
|
82
|
+
# @return [Integer] The color value, with the opacity applied if one was
|
83
|
+
# given.
|
84
|
+
def parse(source)
|
85
|
+
return source if source.kind_of?(Integer)
|
86
|
+
case source.to_s
|
87
|
+
when /^\d+$/; source.to_s.to_i
|
88
|
+
when HEX3_COLOR_REGEXP, HEX6_COLOR_REGEXP; from_hex(source.to_s)
|
89
|
+
when HTML_COLOR_REGEXP; html_color(source.to_s)
|
90
|
+
else raise ArgumentError, "Don't know how to create a color from #{source.inspect}!"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Creates a new color using an r, g, b triple and an alpha value.
|
95
|
+
# @param [Integer] r The r-component (0-255)
|
96
|
+
# @param [Integer] g The g-component (0-255)
|
97
|
+
# @param [Integer] b The b-component (0-255)
|
98
|
+
# @param [Integer] a The opacity (0-255)
|
99
|
+
# @return [Integer] The newly constructed color value.
|
100
|
+
def rgba(r, g, b, a)
|
101
|
+
r << 24 | g << 16 | b << 8 | a
|
102
|
+
end
|
103
|
+
|
104
|
+
# Creates a new color using an r, g, b triple.
|
105
|
+
# @param [Integer] r The r-component (0-255)
|
106
|
+
# @param [Integer] g The g-component (0-255)
|
107
|
+
# @param [Integer] b The b-component (0-255)
|
108
|
+
# @return [Integer] The newly constructed color value.
|
109
|
+
def rgb(r, g, b)
|
110
|
+
r << 24 | g << 16 | b << 8 | 0xff
|
111
|
+
end
|
112
|
+
|
113
|
+
# Creates a new color using a grayscale teint.
|
114
|
+
# @param [Integer] teint The grayscale teint (0-255), will be used as r, g,
|
115
|
+
# and b value.
|
116
|
+
# @return [Integer] The newly constructed color value.
|
117
|
+
def grayscale(teint)
|
118
|
+
teint << 24 | teint << 16 | teint << 8 | 0xff
|
119
|
+
end
|
120
|
+
|
121
|
+
# Creates a new color using a grayscale teint and alpha value.
|
122
|
+
# @param [Integer] teint The grayscale teint (0-255), will be used as r, g,
|
123
|
+
# and b value.
|
124
|
+
# @param [Integer] a The opacity (0-255)
|
125
|
+
# @return [Integer] The newly constructed color value.
|
126
|
+
def grayscale_alpha(teint, a)
|
127
|
+
teint << 24 | teint << 16 | teint << 8 | a
|
128
|
+
end
|
129
|
+
|
130
|
+
####################################################################
|
131
|
+
# COLOR IMPORTING
|
132
|
+
####################################################################
|
133
|
+
|
134
|
+
# Creates a color by unpacking an rgb triple from a string.
|
135
|
+
#
|
136
|
+
# @param [String] stream The string to load the color from. It should be
|
137
|
+
# at least 3 + pos bytes long.
|
138
|
+
# @param [Integer] pos The position in the string to load the triple from.
|
139
|
+
# @return [Integer] The newly constructed color value.
|
140
|
+
def from_rgb_stream(stream, pos = 0)
|
141
|
+
rgb(*stream.unpack("@#{pos}C3"))
|
142
|
+
end
|
143
|
+
|
144
|
+
# Creates a color by unpacking an rgba triple from a string
|
145
|
+
#
|
146
|
+
# @param [String] stream The string to load the color from. It should be
|
147
|
+
# at least 4 + pos bytes long.
|
148
|
+
# @param [Integer] pos The position in the string to load the triple from.
|
149
|
+
# @return [Integer] The newly constructed color value.
|
150
|
+
def from_rgba_stream(stream, pos = 0)
|
151
|
+
rgba(*stream.unpack("@#{pos}C4"))
|
152
|
+
end
|
153
|
+
|
154
|
+
# Creates a color by converting it from a string in hex notation.
|
155
|
+
#
|
156
|
+
# It supports colors with (#rrggbbaa) or without (#rrggbb) alpha channel
|
157
|
+
# as well as the 3-digit short format (#rgb) for those without.
|
158
|
+
# Color strings may include the prefix "0x" or "#".
|
159
|
+
#
|
160
|
+
# @param [String] str The color in hex notation. @return [Integer] The
|
161
|
+
# converted color value.
|
162
|
+
# @param [Integer] opacity The opacity value for the color. Overrides any
|
163
|
+
# opacity value given in the hex value if given.
|
164
|
+
# @return [Integer] The color value.
|
165
|
+
# @raise [ArgumentError] if the value given is not a hex color notation.
|
166
|
+
def from_hex(hex_value, opacity = nil)
|
167
|
+
base_color = case hex_value
|
168
|
+
when HEX3_COLOR_REGEXP
|
169
|
+
$1.gsub(/([0-9a-f])/i, '\1\1').hex << 8
|
170
|
+
when HEX6_COLOR_REGEXP
|
171
|
+
$1.hex << 8
|
172
|
+
else
|
173
|
+
raise ArgumentError, "Not a valid hex color notation: #{hex_value.inspect}!"
|
174
|
+
end
|
175
|
+
opacity ||= $2 ? $2.hex : 0xff
|
176
|
+
base_color | opacity
|
177
|
+
end
|
178
|
+
|
179
|
+
####################################################################
|
180
|
+
# PROPERTIES
|
181
|
+
####################################################################
|
182
|
+
|
183
|
+
# Returns the red-component from the color value.
|
184
|
+
#
|
185
|
+
# @param [Integer] value The color value.
|
186
|
+
# @return [Integer] A value between 0 and MAX.
|
187
|
+
def r(value)
|
188
|
+
(value & 0xff000000) >> 24
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the green-component from the color value.
|
192
|
+
#
|
193
|
+
# @param [Integer] value The color value.
|
194
|
+
# @return [Integer] A value between 0 and MAX.
|
195
|
+
def g(value)
|
196
|
+
(value & 0x00ff0000) >> 16
|
197
|
+
end
|
198
|
+
|
199
|
+
# Returns the blue-component from the color value.
|
200
|
+
#
|
201
|
+
# @param [Integer] value The color value.
|
202
|
+
# @return [Integer] A value between 0 and MAX.
|
203
|
+
def b(value)
|
204
|
+
(value & 0x0000ff00) >> 8
|
205
|
+
end
|
206
|
+
|
207
|
+
# Returns the alpha channel value for the color value.
|
208
|
+
#
|
209
|
+
# @param [Integer] value The color value.
|
210
|
+
# @return [Integer] A value between 0 and MAX.
|
211
|
+
def a(value)
|
212
|
+
value & 0x000000ff
|
213
|
+
end
|
214
|
+
|
215
|
+
# Returns true if this color is fully opaque.
|
216
|
+
#
|
217
|
+
# @param [Integer] value The color to test.
|
218
|
+
# @return [true, false] True if the alpha channel equals MAX.
|
219
|
+
def opaque?(value)
|
220
|
+
a(value) == 0x000000ff
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the opaque value of this color by removing the alpha channel.
|
224
|
+
# @param [Integer] value The color to transform.
|
225
|
+
# @return [Integer] The opaque color
|
226
|
+
def opaque!(value)
|
227
|
+
value | 0x000000ff
|
228
|
+
end
|
229
|
+
|
230
|
+
# Returns true if this color is fully transparent.
|
231
|
+
#
|
232
|
+
# @param [Integer] value The color to test.
|
233
|
+
# @return [true, false] True if the r, g and b component are equal.
|
234
|
+
def grayscale?(value)
|
235
|
+
r(value) == b(value) && b(value) == g(value)
|
236
|
+
end
|
237
|
+
|
238
|
+
# Returns true if this color is fully transparent.
|
239
|
+
#
|
240
|
+
# @param [Integer] value The color to test.
|
241
|
+
# @return [true, false] True if the alpha channel equals 0.
|
242
|
+
def fully_transparent?(value)
|
243
|
+
a(value) == 0x00000000
|
244
|
+
end
|
245
|
+
|
246
|
+
####################################################################
|
247
|
+
# ALPHA COMPOSITION
|
248
|
+
####################################################################
|
249
|
+
|
250
|
+
# Multiplies two fractions using integer math, where the fractions are
|
251
|
+
# stored using an integer between 0 and 255. This method is used as a
|
252
|
+
# helper method for compositing colors using integer math.
|
253
|
+
#
|
254
|
+
# This is a quicker implementation of ((a * b) / 255.0).round.
|
255
|
+
#
|
256
|
+
# @param [Integer] a The first fraction.
|
257
|
+
# @param [Integer] b The second fraction.
|
258
|
+
# @return [Integer] The result of the multiplication.
|
259
|
+
def int8_mult(a, b)
|
260
|
+
t = a * b + 0x80
|
261
|
+
((t >> 8) + t) >> 8
|
262
|
+
end
|
263
|
+
|
264
|
+
# Composes two colors with an alpha channel using integer math.
|
265
|
+
#
|
266
|
+
# This version is faster than the version based on floating point math, so
|
267
|
+
# this compositing function is used by default.
|
268
|
+
#
|
269
|
+
# @param [Integer] fg The foreground color.
|
270
|
+
# @param [Integer] bg The foreground color.
|
271
|
+
# @return [Integer] The composited color.
|
272
|
+
# @see ChunkyPNG::Color#compose_precise
|
273
|
+
def compose_quick(fg, bg)
|
274
|
+
return fg if opaque?(fg) || fully_transparent?(bg)
|
275
|
+
return bg if fully_transparent?(fg)
|
276
|
+
|
277
|
+
a_com = int8_mult(0xff - a(fg), a(bg))
|
278
|
+
new_r = int8_mult(a(fg), r(fg)) + int8_mult(a_com, r(bg))
|
279
|
+
new_g = int8_mult(a(fg), g(fg)) + int8_mult(a_com, g(bg))
|
280
|
+
new_b = int8_mult(a(fg), b(fg)) + int8_mult(a_com, b(bg))
|
281
|
+
new_a = a(fg) + a_com
|
282
|
+
rgba(new_r, new_g, new_b, new_a)
|
283
|
+
end
|
284
|
+
|
285
|
+
# Composes two colors with an alpha channel using floating point math.
|
286
|
+
#
|
287
|
+
# This method uses more precise floating point math, but this precision is
|
288
|
+
# lost when the result is converted back to an integer. Because it is
|
289
|
+
# slower than the version based on integer math, that version is preferred.
|
290
|
+
#
|
291
|
+
# @param [Integer] fg The foreground color.
|
292
|
+
# @param [Integer] bg The foreground color.
|
293
|
+
# @return [Integer] The composited color.
|
294
|
+
# @see ChunkyPNG::Color#compose_quick
|
295
|
+
def compose_precise(fg, bg)
|
296
|
+
return fg if opaque?(fg) || fully_transparent?(bg)
|
297
|
+
return bg if fully_transparent?(fg)
|
298
|
+
|
299
|
+
fg_a = a(fg).to_f / MAX
|
300
|
+
bg_a = a(bg).to_f / MAX
|
301
|
+
a_com = (1.0 - fg_a) * bg_a
|
302
|
+
|
303
|
+
new_r = (fg_a * r(fg) + a_com * r(bg)).round
|
304
|
+
new_g = (fg_a * g(fg) + a_com * g(bg)).round
|
305
|
+
new_b = (fg_a * b(fg) + a_com * b(bg)).round
|
306
|
+
new_a = ((fg_a + a_com) * MAX).round
|
307
|
+
rgba(new_r, new_g, new_b, new_a)
|
308
|
+
end
|
309
|
+
|
310
|
+
alias :compose :compose_quick
|
311
|
+
|
312
|
+
# Blends the foreground and background color by taking the average of
|
313
|
+
# the components.
|
314
|
+
#
|
315
|
+
# @param [Integer] fg The foreground color.
|
316
|
+
# @param [Integer] bg The foreground color.
|
317
|
+
# @return [Integer] The blended color.
|
318
|
+
def blend(fg, bg)
|
319
|
+
(fg + bg) >> 1
|
320
|
+
end
|
321
|
+
|
322
|
+
# Interpolates the foreground and background colors by the given alpha
|
323
|
+
# value. This also blends the alpha channels themselves.
|
324
|
+
#
|
325
|
+
# A blending factor of 255 will give entirely the foreground,
|
326
|
+
# while a blending factor of 0 will give the background.
|
327
|
+
#
|
328
|
+
# @param [Integer] fg The foreground color.
|
329
|
+
# @param [Integer] bg The background color.
|
330
|
+
# @param [Integer] alpha The blending factor (fixed 8bit)
|
331
|
+
# @param [Integer] The interpolated color.
|
332
|
+
def interpolate_quick(fg, bg, alpha)
|
333
|
+
return fg if alpha >= 255
|
334
|
+
return bg if alpha <= 0
|
335
|
+
|
336
|
+
alpha_com = 255 - alpha
|
337
|
+
|
338
|
+
new_r = int8_mult(alpha, r(fg)) + int8_mult(alpha_com, r(bg))
|
339
|
+
new_g = int8_mult(alpha, g(fg)) + int8_mult(alpha_com, g(bg))
|
340
|
+
new_b = int8_mult(alpha, b(fg)) + int8_mult(alpha_com, b(bg))
|
341
|
+
new_a = int8_mult(alpha, a(fg)) + int8_mult(alpha_com, a(bg))
|
342
|
+
|
343
|
+
rgba(new_r, new_g, new_b, new_a)
|
344
|
+
end
|
345
|
+
|
346
|
+
# Calculates the grayscale teint of an RGB color.
|
347
|
+
#
|
348
|
+
# @param [Integer] color The color to convert.
|
349
|
+
# @return [Integer] The grayscale teint of the input color, 0-255.
|
350
|
+
def grayscale_teint(color)
|
351
|
+
(r(color) * 0.3 + g(color) * 0.59 + b(color) * 0.11).round
|
352
|
+
end
|
353
|
+
|
354
|
+
# Converts a color to a fiting grayscale value. It will conserve the alpha
|
355
|
+
# channel.
|
356
|
+
#
|
357
|
+
# This method will return a full color value, with the R, G, and B value
|
358
|
+
# set to the grayscale teint calcuated from the input color's R, G and B
|
359
|
+
# values.
|
360
|
+
#
|
361
|
+
# @param [Integer] color The color to convert.
|
362
|
+
# @return [Integer] The input color, converted to the best fitting
|
363
|
+
# grayscale.
|
364
|
+
# @see #grayscale_teint
|
365
|
+
def to_grayscale(color)
|
366
|
+
grayscale_alpha(grayscale_teint(color), a(color))
|
367
|
+
end
|
368
|
+
|
369
|
+
# Lowers the intensity of a color, by lowering its alpha by a given factor.
|
370
|
+
# @param [Integer] color The color to adjust.
|
371
|
+
# @param [Integer] factor Fade factor as an integer between 0 and 255.
|
372
|
+
# @return [Integer] The faded color.
|
373
|
+
def fade(color, factor)
|
374
|
+
new_alpha = int8_mult(a(color), factor)
|
375
|
+
(color & 0xffffff00) | new_alpha
|
376
|
+
end
|
377
|
+
|
378
|
+
# Decomposes a color, given a color, a mask color and a background color.
|
379
|
+
# The returned color will be a variant of the mask color, with the alpha
|
380
|
+
# channel set to the best fitting value. This basically is the reverse
|
381
|
+
# operation if alpha composition.
|
382
|
+
#
|
383
|
+
# If the color cannot be decomposed, this method will return the fully
|
384
|
+
# transparent variant of the mask color.
|
385
|
+
#
|
386
|
+
# @param [Integer] color The color that was the result of compositing.
|
387
|
+
# @param [Integer] mask The opaque variant of the color that was being
|
388
|
+
# composed
|
389
|
+
# @param [Integer] bg The background color on which the color was composed.
|
390
|
+
# @param [Integer] tolerance The decomposition tolerance level, a value
|
391
|
+
# between 0 and 255.
|
392
|
+
# @return [Integer] The decomposed color, a variant of the masked color
|
393
|
+
# with the alpha channel set to an appropriate value.
|
394
|
+
def decompose_color(color, mask, bg, tolerance = 1)
|
395
|
+
if alpha_decomposable?(color, mask, bg, tolerance)
|
396
|
+
mask & 0xffffff00 | decompose_alpha(color, mask, bg)
|
397
|
+
else
|
398
|
+
mask & 0xffffff00
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
# Checks whether an alpha channel value can successfully be composed
|
403
|
+
# given the resulting color, the mask color and a background color,
|
404
|
+
# all of which should be opaque.
|
405
|
+
#
|
406
|
+
# @param [Integer] color The color that was the result of compositing.
|
407
|
+
# @param [Integer] mask The opaque variant of the color that was being
|
408
|
+
# composed
|
409
|
+
# @param [Integer] bg The background color on which the color was composed.
|
410
|
+
# @param [Integer] tolerance The decomposition tolerance level, a value
|
411
|
+
# between 0 and 255.
|
412
|
+
# @return [Boolean] True if the alpha component can be decomposed
|
413
|
+
# successfully.
|
414
|
+
# @see #decompose_alpha
|
415
|
+
def alpha_decomposable?(color, mask, bg, tolerance = 1)
|
416
|
+
components = decompose_alpha_components(color, mask, bg)
|
417
|
+
sum = components.inject(0) { |a,b| a + b }
|
418
|
+
max = components.max * 3
|
419
|
+
components.max <= 255 && components.min >= 0 && (sum + tolerance * 3) >= max
|
420
|
+
end
|
421
|
+
|
422
|
+
# Decomposes the alpha channel value given the resulting color, the mask
|
423
|
+
# color and a background color, all of which should be opaque.
|
424
|
+
#
|
425
|
+
# Make sure to call {#alpha_decomposable?} first to see if the alpha
|
426
|
+
# channel value can successfully decomposed with a given tolerance,
|
427
|
+
# otherwise the return value of this method is undefined.
|
428
|
+
#
|
429
|
+
# @param [Integer] color The color that was the result of compositing.
|
430
|
+
# @param [Integer] mask The opaque variant of the color that was being
|
431
|
+
# composed
|
432
|
+
# @param [Integer] bg The background color on which the color was composed.
|
433
|
+
# @return [Integer] The best fitting alpha channel, a value between 0 and
|
434
|
+
# 255.
|
435
|
+
# @see #alpha_decomposable?
|
436
|
+
def decompose_alpha(color, mask, bg)
|
437
|
+
components = decompose_alpha_components(color, mask, bg)
|
438
|
+
(components.inject(0) { |a,b| a + b } / 3.0).round
|
439
|
+
end
|
440
|
+
|
441
|
+
# Decomposes an alpha channel for either the r, g or b color channel.
|
442
|
+
# @param [:r, :g, :b] channel The channel to decompose the alpha channel
|
443
|
+
# from.
|
444
|
+
# @param [Integer] color The color that was the result of compositing.
|
445
|
+
# @param [Integer] mask The opaque variant of the color that was being
|
446
|
+
# composed
|
447
|
+
# @param [Integer] bg The background color on which the color was composed.
|
448
|
+
# @return [Integer] The decomposed alpha value for the channel.
|
449
|
+
def decompose_alpha_component(channel, color, mask, bg)
|
450
|
+
cc, mc, bc = send(channel, color), send(channel, mask), send(channel, bg)
|
451
|
+
|
452
|
+
return 0x00 if bc == cc
|
453
|
+
return 0xff if bc == mc
|
454
|
+
return 0xff if cc == mc
|
455
|
+
|
456
|
+
(((bc - cc).to_f / (bc - mc).to_f) * MAX).round
|
457
|
+
end
|
458
|
+
|
459
|
+
# Decomposes the alpha channels for the r, g and b color channel.
|
460
|
+
# @param [Integer] color The color that was the result of compositing.
|
461
|
+
# @param [Integer] mask The opaque variant of the color that was being
|
462
|
+
# composed
|
463
|
+
# @param [Integer] bg The background color on which the color was composed.
|
464
|
+
# @return [Array<Integer>] The decomposed alpha values for the r, g and b
|
465
|
+
# channels.
|
466
|
+
def decompose_alpha_components(color, mask, bg)
|
467
|
+
[
|
468
|
+
decompose_alpha_component(:r, color, mask, bg),
|
469
|
+
decompose_alpha_component(:g, color, mask, bg),
|
470
|
+
decompose_alpha_component(:b, color, mask, bg)
|
471
|
+
]
|
472
|
+
end
|
473
|
+
|
474
|
+
####################################################################
|
475
|
+
# CONVERSIONS
|
476
|
+
####################################################################
|
477
|
+
|
478
|
+
# Returns a string representing this color using hex notation (i.e.
|
479
|
+
# #rrggbbaa).
|
480
|
+
#
|
481
|
+
# @param [Integer] value The color to convert.
|
482
|
+
# @return [String] The color in hex notation, starting with a pound sign.
|
483
|
+
def to_hex(color, include_alpha = true)
|
484
|
+
include_alpha ? ('#%08x' % color) : ('#%06x' % [color >> 8])
|
485
|
+
end
|
486
|
+
|
487
|
+
# Returns an array with the separate RGBA values for this color.
|
488
|
+
#
|
489
|
+
# @param [Integer] color The color to convert.
|
490
|
+
# @return [Array<Integer>] An array with 4 Integer elements.
|
491
|
+
def to_truecolor_alpha_bytes(color)
|
492
|
+
[r(color), g(color), b(color), a(color)]
|
493
|
+
end
|
494
|
+
|
495
|
+
# Returns an array with the separate RGB values for this color. The alpha
|
496
|
+
# channel will be discarded.
|
497
|
+
#
|
498
|
+
# @param [Integer] color The color to convert.
|
499
|
+
# @return [Array<Integer>] An array with 3 Integer elements.
|
500
|
+
def to_truecolor_bytes(color)
|
501
|
+
[r(color), g(color), b(color)]
|
502
|
+
end
|
503
|
+
|
504
|
+
# Returns an array with the grayscale teint value for this color.
|
505
|
+
#
|
506
|
+
# This method expects the r, g, and b value to be equal, and the alpha
|
507
|
+
# channel will be discarded.
|
508
|
+
#
|
509
|
+
# @param [Integer] color The grayscale color to convert.
|
510
|
+
# @return [Array<Integer>] An array with 1 Integer element.
|
511
|
+
def to_grayscale_bytes(color)
|
512
|
+
[b(color)] # assumption r == g == b
|
513
|
+
end
|
514
|
+
|
515
|
+
# Returns an array with the grayscale teint and alpha channel values for
|
516
|
+
# this color.
|
517
|
+
#
|
518
|
+
# This method expects the color to be grayscale, i.e. r, g, and b value to
|
519
|
+
# be equal and uses only the B channel. If you need to convert a color to
|
520
|
+
# grayscale first, see {#to_grayscale}.
|
521
|
+
#
|
522
|
+
# @param [Integer] color The grayscale color to convert.
|
523
|
+
# @return [Array<Integer>] An array with 2 Integer elements.
|
524
|
+
# @see #to_grayscale
|
525
|
+
def to_grayscale_alpha_bytes(color)
|
526
|
+
[b(color), a(color)] # assumption r == g == b
|
527
|
+
end
|
528
|
+
|
529
|
+
####################################################################
|
530
|
+
# COLOR CONSTANTS
|
531
|
+
####################################################################
|
532
|
+
|
533
|
+
# @return [Hash<Symbol, Integer>] All the predefined color names in HTML.
|
534
|
+
PREDEFINED_COLORS = {
|
535
|
+
:aliceblue => 0xf0f8ff00,
|
536
|
+
:antiquewhite => 0xfaebd700,
|
537
|
+
:aqua => 0x00ffff00,
|
538
|
+
:aquamarine => 0x7fffd400,
|
539
|
+
:azure => 0xf0ffff00,
|
540
|
+
:beige => 0xf5f5dc00,
|
541
|
+
:bisque => 0xffe4c400,
|
542
|
+
:black => 0x00000000,
|
543
|
+
:blanchedalmond => 0xffebcd00,
|
544
|
+
:blue => 0x0000ff00,
|
545
|
+
:blueviolet => 0x8a2be200,
|
546
|
+
:brown => 0xa52a2a00,
|
547
|
+
:burlywood => 0xdeb88700,
|
548
|
+
:cadetblue => 0x5f9ea000,
|
549
|
+
:chartreuse => 0x7fff0000,
|
550
|
+
:chocolate => 0xd2691e00,
|
551
|
+
:coral => 0xff7f5000,
|
552
|
+
:cornflowerblue => 0x6495ed00,
|
553
|
+
:cornsilk => 0xfff8dc00,
|
554
|
+
:crimson => 0xdc143c00,
|
555
|
+
:cyan => 0x00ffff00,
|
556
|
+
:darkblue => 0x00008b00,
|
557
|
+
:darkcyan => 0x008b8b00,
|
558
|
+
:darkgoldenrod => 0xb8860b00,
|
559
|
+
:darkgray => 0xa9a9a900,
|
560
|
+
:darkgrey => 0xa9a9a900,
|
561
|
+
:darkgreen => 0x00640000,
|
562
|
+
:darkkhaki => 0xbdb76b00,
|
563
|
+
:darkmagenta => 0x8b008b00,
|
564
|
+
:darkolivegreen => 0x556b2f00,
|
565
|
+
:darkorange => 0xff8c0000,
|
566
|
+
:darkorchid => 0x9932cc00,
|
567
|
+
:darkred => 0x8b000000,
|
568
|
+
:darksalmon => 0xe9967a00,
|
569
|
+
:darkseagreen => 0x8fbc8f00,
|
570
|
+
:darkslateblue => 0x483d8b00,
|
571
|
+
:darkslategray => 0x2f4f4f00,
|
572
|
+
:darkslategrey => 0x2f4f4f00,
|
573
|
+
:darkturquoise => 0x00ced100,
|
574
|
+
:darkviolet => 0x9400d300,
|
575
|
+
:deeppink => 0xff149300,
|
576
|
+
:deepskyblue => 0x00bfff00,
|
577
|
+
:dimgray => 0x69696900,
|
578
|
+
:dimgrey => 0x69696900,
|
579
|
+
:dodgerblue => 0x1e90ff00,
|
580
|
+
:firebrick => 0xb2222200,
|
581
|
+
:floralwhite => 0xfffaf000,
|
582
|
+
:forestgreen => 0x228b2200,
|
583
|
+
:fuchsia => 0xff00ff00,
|
584
|
+
:gainsboro => 0xdcdcdc00,
|
585
|
+
:ghostwhite => 0xf8f8ff00,
|
586
|
+
:gold => 0xffd70000,
|
587
|
+
:goldenrod => 0xdaa52000,
|
588
|
+
:gray => 0x80808000,
|
589
|
+
:grey => 0x80808000,
|
590
|
+
:green => 0x00800000,
|
591
|
+
:greenyellow => 0xadff2f00,
|
592
|
+
:honeydew => 0xf0fff000,
|
593
|
+
:hotpink => 0xff69b400,
|
594
|
+
:indianred => 0xcd5c5c00,
|
595
|
+
:indigo => 0x4b008200,
|
596
|
+
:ivory => 0xfffff000,
|
597
|
+
:khaki => 0xf0e68c00,
|
598
|
+
:lavender => 0xe6e6fa00,
|
599
|
+
:lavenderblush => 0xfff0f500,
|
600
|
+
:lawngreen => 0x7cfc0000,
|
601
|
+
:lemonchiffon => 0xfffacd00,
|
602
|
+
:lightblue => 0xadd8e600,
|
603
|
+
:lightcoral => 0xf0808000,
|
604
|
+
:lightcyan => 0xe0ffff00,
|
605
|
+
:lightgoldenrodyellow => 0xfafad200,
|
606
|
+
:lightgray => 0xd3d3d300,
|
607
|
+
:lightgrey => 0xd3d3d300,
|
608
|
+
:lightgreen => 0x90ee9000,
|
609
|
+
:lightpink => 0xffb6c100,
|
610
|
+
:lightsalmon => 0xffa07a00,
|
611
|
+
:lightseagreen => 0x20b2aa00,
|
612
|
+
:lightskyblue => 0x87cefa00,
|
613
|
+
:lightslategray => 0x77889900,
|
614
|
+
:lightslategrey => 0x77889900,
|
615
|
+
:lightsteelblue => 0xb0c4de00,
|
616
|
+
:lightyellow => 0xffffe000,
|
617
|
+
:lime => 0x00ff0000,
|
618
|
+
:limegreen => 0x32cd3200,
|
619
|
+
:linen => 0xfaf0e600,
|
620
|
+
:magenta => 0xff00ff00,
|
621
|
+
:maroon => 0x80000000,
|
622
|
+
:mediumaquamarine => 0x66cdaa00,
|
623
|
+
:mediumblue => 0x0000cd00,
|
624
|
+
:mediumorchid => 0xba55d300,
|
625
|
+
:mediumpurple => 0x9370d800,
|
626
|
+
:mediumseagreen => 0x3cb37100,
|
627
|
+
:mediumslateblue => 0x7b68ee00,
|
628
|
+
:mediumspringgreen => 0x00fa9a00,
|
629
|
+
:mediumturquoise => 0x48d1cc00,
|
630
|
+
:mediumvioletred => 0xc7158500,
|
631
|
+
:midnightblue => 0x19197000,
|
632
|
+
:mintcream => 0xf5fffa00,
|
633
|
+
:mistyrose => 0xffe4e100,
|
634
|
+
:moccasin => 0xffe4b500,
|
635
|
+
:navajowhite => 0xffdead00,
|
636
|
+
:navy => 0x00008000,
|
637
|
+
:oldlace => 0xfdf5e600,
|
638
|
+
:olive => 0x80800000,
|
639
|
+
:olivedrab => 0x6b8e2300,
|
640
|
+
:orange => 0xffa50000,
|
641
|
+
:orangered => 0xff450000,
|
642
|
+
:orchid => 0xda70d600,
|
643
|
+
:palegoldenrod => 0xeee8aa00,
|
644
|
+
:palegreen => 0x98fb9800,
|
645
|
+
:paleturquoise => 0xafeeee00,
|
646
|
+
:palevioletred => 0xd8709300,
|
647
|
+
:papayawhip => 0xffefd500,
|
648
|
+
:peachpuff => 0xffdab900,
|
649
|
+
:peru => 0xcd853f00,
|
650
|
+
:pink => 0xffc0cb00,
|
651
|
+
:plum => 0xdda0dd00,
|
652
|
+
:powderblue => 0xb0e0e600,
|
653
|
+
:purple => 0x80008000,
|
654
|
+
:red => 0xff000000,
|
655
|
+
:rosybrown => 0xbc8f8f00,
|
656
|
+
:royalblue => 0x4169e100,
|
657
|
+
:saddlebrown => 0x8b451300,
|
658
|
+
:salmon => 0xfa807200,
|
659
|
+
:sandybrown => 0xf4a46000,
|
660
|
+
:seagreen => 0x2e8b5700,
|
661
|
+
:seashell => 0xfff5ee00,
|
662
|
+
:sienna => 0xa0522d00,
|
663
|
+
:silver => 0xc0c0c000,
|
664
|
+
:skyblue => 0x87ceeb00,
|
665
|
+
:slateblue => 0x6a5acd00,
|
666
|
+
:slategray => 0x70809000,
|
667
|
+
:slategrey => 0x70809000,
|
668
|
+
:snow => 0xfffafa00,
|
669
|
+
:springgreen => 0x00ff7f00,
|
670
|
+
:steelblue => 0x4682b400,
|
671
|
+
:tan => 0xd2b48c00,
|
672
|
+
:teal => 0x00808000,
|
673
|
+
:thistle => 0xd8bfd800,
|
674
|
+
:tomato => 0xff634700,
|
675
|
+
:turquoise => 0x40e0d000,
|
676
|
+
:violet => 0xee82ee00,
|
677
|
+
:wheat => 0xf5deb300,
|
678
|
+
:white => 0xffffff00,
|
679
|
+
:whitesmoke => 0xf5f5f500,
|
680
|
+
:yellow => 0xffff0000,
|
681
|
+
:yellowgreen => 0x9acd3200
|
682
|
+
}
|
683
|
+
|
684
|
+
# Gets a color value based on a HTML color name.
|
685
|
+
#
|
686
|
+
# The color name is flexible. E.g. <tt>'yellowgreen'</tt>, <tt>'Yellow
|
687
|
+
# green'</tt>, <tt>'YellowGreen'</tt>, <tt>'YELLOW_GREEN'</tt> and
|
688
|
+
# <tt>:yellow_green</tt> will all return the same color value.
|
689
|
+
#
|
690
|
+
# You can include a opacity level in the color name (e.g. <tt>'red @
|
691
|
+
# 0.5'</tt>) or give an explicit opacity value as second argument. If no
|
692
|
+
# opacity value is given, the color will be fully opaque.
|
693
|
+
#
|
694
|
+
# @param [Symbol, String] color_name The color name. It may include an
|
695
|
+
# opacity specifier like <tt>@ 0.8</tt> to set the color's opacity.
|
696
|
+
# @param [Integer] opacity The opacity value for the color between 0 and
|
697
|
+
# 255. Overrides any opacity value given in the color name.
|
698
|
+
# @return [Integer] The color value.
|
699
|
+
# @raise [ChunkyPNG::Exception] If the color name was not recognized.
|
700
|
+
def html_color(color_name, opacity = nil)
|
701
|
+
if color_name.to_s =~ HTML_COLOR_REGEXP
|
702
|
+
opacity ||= $2 ? ($2.to_f * 255.0).round : 0xff
|
703
|
+
base_color_name = $1.gsub(/[^a-z]+/i, '').downcase.to_sym
|
704
|
+
return PREDEFINED_COLORS[base_color_name] | opacity if PREDEFINED_COLORS.has_key?(base_color_name)
|
705
|
+
end
|
706
|
+
raise ArgumentError, "Unknown color name #{color_name}!"
|
707
|
+
end
|
708
|
+
|
709
|
+
# @return [Integer] Black pixel/color
|
710
|
+
BLACK = rgb( 0, 0, 0)
|
711
|
+
|
712
|
+
# @return [Integer] White pixel/color
|
713
|
+
WHITE = rgb(255, 255, 255)
|
714
|
+
|
715
|
+
# @return [Integer] Fully transparent pixel/color
|
716
|
+
TRANSPARENT = rgba(0, 0, 0, 0)
|
717
|
+
|
718
|
+
####################################################################
|
719
|
+
# STATIC UTILITY METHODS
|
720
|
+
####################################################################
|
721
|
+
|
722
|
+
# Returns the number of sample values per pixel.
|
723
|
+
# @param [Integer] color_mode The color mode being used.
|
724
|
+
# @return [Integer] The number of sample values per pixel.
|
725
|
+
def samples_per_pixel(color_mode)
|
726
|
+
case color_mode
|
727
|
+
when ChunkyPNG::COLOR_INDEXED; 1
|
728
|
+
when ChunkyPNG::COLOR_TRUECOLOR; 3
|
729
|
+
when ChunkyPNG::COLOR_TRUECOLOR_ALPHA; 4
|
730
|
+
when ChunkyPNG::COLOR_GRAYSCALE; 1
|
731
|
+
when ChunkyPNG::COLOR_GRAYSCALE_ALPHA; 2
|
732
|
+
else raise ChunkyPNG::NotSupported, "Don't know the numer of samples for this colormode: #{color_mode}!"
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
736
|
+
# Returns the size in bytes of a pixel when it is stored using a given
|
737
|
+
# color mode.
|
738
|
+
#
|
739
|
+
# @param [Integer] color_mode The color mode in which the pixels are
|
740
|
+
# stored.
|
741
|
+
# @return [Integer] The number of bytes used per pixel in a datastream.
|
742
|
+
def pixel_bytesize(color_mode, depth = 8)
|
743
|
+
return 1 if depth < 8
|
744
|
+
(pixel_bitsize(color_mode, depth) + 7) >> 3
|
745
|
+
end
|
746
|
+
|
747
|
+
# Returns the size in bits of a pixel when it is stored using a given color
|
748
|
+
# mode.
|
749
|
+
#
|
750
|
+
# @param [Integer] color_mode The color mode in which the pixels are
|
751
|
+
# stored.
|
752
|
+
# @param [Integer] depth The color depth of the pixels.
|
753
|
+
# @return [Integer] The number of bytes used per pixel in a datastream.
|
754
|
+
def pixel_bitsize(color_mode, depth = 8)
|
755
|
+
samples_per_pixel(color_mode) * depth
|
756
|
+
end
|
757
|
+
|
758
|
+
# Returns the number of bytes used per scanline.
|
759
|
+
# @param [Integer] color_mode The color mode in which the pixels are
|
760
|
+
# stored.
|
761
|
+
# @param [Integer] depth The color depth of the pixels.
|
762
|
+
# @param [Integer] width The number of pixels per scanline.
|
763
|
+
# @return [Integer] The number of bytes used per scanline in a datastream.
|
764
|
+
def scanline_bytesize(color_mode, depth, width)
|
765
|
+
((pixel_bitsize(color_mode, depth) * width) + 7) >> 3
|
766
|
+
end
|
767
|
+
|
768
|
+
# Returns the number of bytes used for an image pass
|
769
|
+
# @param [Integer] color_mode The color mode in which the pixels are
|
770
|
+
# stored.
|
771
|
+
# @param [Integer] depth The color depth of the pixels.
|
772
|
+
# @param [Integer] width The width of the image pass.
|
773
|
+
# @param [Integer] width The height of the image pass.
|
774
|
+
# @return [Integer] The number of bytes used per scanline in a datastream.
|
775
|
+
def pass_bytesize(color_mode, depth, width, height)
|
776
|
+
return 0 if width == 0 || height == 0
|
777
|
+
(scanline_bytesize(color_mode, depth, width) + 1) * height
|
778
|
+
end
|
779
|
+
end
|
780
|
+
end
|