bench9000 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +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,58 @@
|
|
|
1
|
+
#include "oily_png_ext.h"
|
|
2
|
+
|
|
3
|
+
PIXEL oily_png_compose_color(PIXEL fg, PIXEL bg) {
|
|
4
|
+
BYTE a_com, new_r, new_g, new_b, new_a;
|
|
5
|
+
|
|
6
|
+
// Check for simple cases first
|
|
7
|
+
if ((A_BYTE(fg) == 0xff) || (A_BYTE(bg) == 0x00)) return fg;
|
|
8
|
+
if (A_BYTE(fg) == 0x00) return bg;
|
|
9
|
+
|
|
10
|
+
// Calculate the new values using fast 8-bit multiplication
|
|
11
|
+
a_com = INT8_MULTIPLY(0xff - A_BYTE(fg), A_BYTE(bg));
|
|
12
|
+
new_r = INT8_MULTIPLY(A_BYTE(fg), R_BYTE(fg)) + INT8_MULTIPLY(a_com, R_BYTE(bg));
|
|
13
|
+
new_g = INT8_MULTIPLY(A_BYTE(fg), G_BYTE(fg)) + INT8_MULTIPLY(a_com, G_BYTE(bg));
|
|
14
|
+
new_b = INT8_MULTIPLY(A_BYTE(fg), B_BYTE(fg)) + INT8_MULTIPLY(a_com, B_BYTE(bg));
|
|
15
|
+
new_a = A_BYTE(fg) + a_com;
|
|
16
|
+
|
|
17
|
+
return BUILD_PIXEL(new_r, new_g, new_b, new_a);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
PIXEL oily_png_color_interpolate_quick(PIXEL fg, PIXEL bg, int alpha) {
|
|
21
|
+
BYTE a_com, new_r, new_g, new_b, new_a;
|
|
22
|
+
|
|
23
|
+
if (alpha >= 255) return fg;
|
|
24
|
+
if (alpha <= 0) return bg;
|
|
25
|
+
|
|
26
|
+
a_com = 255 - alpha;
|
|
27
|
+
new_r = INT8_MULTIPLY(alpha, R_BYTE(fg)) + INT8_MULTIPLY(a_com, R_BYTE(bg));
|
|
28
|
+
new_g = INT8_MULTIPLY(alpha, G_BYTE(fg)) + INT8_MULTIPLY(a_com, G_BYTE(bg));
|
|
29
|
+
new_b = INT8_MULTIPLY(alpha, B_BYTE(fg)) + INT8_MULTIPLY(a_com, B_BYTE(bg));
|
|
30
|
+
new_a = INT8_MULTIPLY(alpha, A_BYTE(fg)) + INT8_MULTIPLY(a_com, A_BYTE(bg));
|
|
31
|
+
|
|
32
|
+
return BUILD_PIXEL(new_r, new_g, new_b, new_a);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
VALUE oily_png_color_compose_quick(VALUE self, VALUE fg_color, VALUE bg_color) {
|
|
36
|
+
UNUSED_PARAMETER(self);
|
|
37
|
+
return UINT2NUM(oily_png_compose_color(NUM2UINT(fg_color), NUM2UINT(bg_color)));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
VALUE oily_png_color_r(VALUE self, VALUE value) {
|
|
41
|
+
UNUSED_PARAMETER(self);
|
|
42
|
+
return INT2FIX(R_BYTE(NUM2UINT(value)));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
VALUE oily_png_color_g(VALUE self, VALUE value) {
|
|
46
|
+
UNUSED_PARAMETER(self);
|
|
47
|
+
return INT2FIX(G_BYTE(NUM2UINT(value)));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
VALUE oily_png_color_b(VALUE self, VALUE value) {
|
|
51
|
+
UNUSED_PARAMETER(self);
|
|
52
|
+
return INT2FIX(B_BYTE(NUM2UINT(value)));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
VALUE oily_png_color_a(VALUE self, VALUE value) {
|
|
56
|
+
UNUSED_PARAMETER(self);
|
|
57
|
+
return INT2FIX(A_BYTE(NUM2UINT(value)));
|
|
58
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#ifndef OILY_PNG_COLOR_H
|
|
2
|
+
#define OILY_PNG_COLOR_H
|
|
3
|
+
|
|
4
|
+
#define R_BYTE(pixel) ((BYTE) (((pixel) & (PIXEL) 0xff000000) >> 24))
|
|
5
|
+
#define G_BYTE(pixel) ((BYTE) (((pixel) & (PIXEL) 0x00ff0000) >> 16))
|
|
6
|
+
#define B_BYTE(pixel) ((BYTE) (((pixel) & (PIXEL) 0x0000ff00) >> 8))
|
|
7
|
+
#define A_BYTE(pixel) ((BYTE) (((pixel) & (PIXEL) 0x000000ff)))
|
|
8
|
+
|
|
9
|
+
#define BUILD_PIXEL(r, g, b, a) (((PIXEL) (r) << 24) + ((PIXEL) (g) << 16) + ((PIXEL) (b) << 8) + (PIXEL) (a))
|
|
10
|
+
#define INT8_MULTIPLY(a, b) (((((a) * (b) + 0x80) >> 8) + ((a) * (b) + 0x80)) >> 8)
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
Ruby replacement method for color composition using alpha transparency.
|
|
14
|
+
|
|
15
|
+
This method should replace ChunkyPNG::Color.compose_quick
|
|
16
|
+
*/
|
|
17
|
+
VALUE oily_png_color_compose_quick(VALUE self, VALUE fg_color, VALUE bg_color);
|
|
18
|
+
|
|
19
|
+
/* Color composition using alpha transparency. */
|
|
20
|
+
PIXEL oily_png_compose_color(PIXEL fg, PIXEL bg);
|
|
21
|
+
PIXEL oily_png_color_interpolate_quick(PIXEL fg, PIXEL bg, int alpha);
|
|
22
|
+
|
|
23
|
+
/* Accessors */
|
|
24
|
+
VALUE oily_png_color_r(VALUE self, VALUE pixel);
|
|
25
|
+
VALUE oily_png_color_g(VALUE self, VALUE pixel);
|
|
26
|
+
VALUE oily_png_color_b(VALUE self, VALUE pixel);
|
|
27
|
+
VALUE oily_png_color_a(VALUE self, VALUE pixel);
|
|
28
|
+
|
|
29
|
+
#endif
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#include "oily_png_ext.h"
|
|
2
|
+
|
|
3
|
+
void Init_oily_png() {
|
|
4
|
+
VALUE OilyPNG = rb_define_module("OilyPNG");
|
|
5
|
+
|
|
6
|
+
VALUE OilyPNG_Canvas = rb_define_module_under(OilyPNG, "Resampling");
|
|
7
|
+
rb_define_private_method(OilyPNG_Canvas, "steps_residues", oily_png_canvas_steps_residues, 2);
|
|
8
|
+
rb_define_private_method(OilyPNG_Canvas, "steps", oily_png_canvas_steps, 2);
|
|
9
|
+
rb_define_method(OilyPNG_Canvas, "resample_nearest_neighbor!", oily_png_canvas_resample_nearest_neighbor_bang, 2);
|
|
10
|
+
rb_define_method(OilyPNG_Canvas, "resample_bilinear!", oily_png_canvas_resample_bilinear_bang, 2);
|
|
11
|
+
|
|
12
|
+
// Setup decoding module
|
|
13
|
+
VALUE OilyPNG_PNGDecoding = rb_define_module_under(OilyPNG, "PNGDecoding");
|
|
14
|
+
rb_define_method(OilyPNG_PNGDecoding, "decode_png_image_pass", oily_png_decode_png_image_pass, 6);
|
|
15
|
+
|
|
16
|
+
// Setup encoding module
|
|
17
|
+
VALUE OilyPNG_PNGEncoding = rb_define_module_under(OilyPNG, "PNGEncoding");
|
|
18
|
+
rb_define_method(OilyPNG_PNGEncoding, "encode_png_image_pass_to_stream", oily_png_encode_png_image_pass_to_stream, 4);
|
|
19
|
+
|
|
20
|
+
// Setup Color module
|
|
21
|
+
VALUE OilyPNG_Color = rb_define_module_under(OilyPNG, "Color");
|
|
22
|
+
rb_define_method(OilyPNG_Color, "compose_quick", oily_png_color_compose_quick, 2);
|
|
23
|
+
rb_define_method(OilyPNG_Color, "r", oily_png_color_r, 1);
|
|
24
|
+
rb_define_method(OilyPNG_Color, "g", oily_png_color_g, 1);
|
|
25
|
+
rb_define_method(OilyPNG_Color, "b", oily_png_color_b, 1);
|
|
26
|
+
rb_define_method(OilyPNG_Color, "a", oily_png_color_a, 1);
|
|
27
|
+
|
|
28
|
+
// Setup Operations module
|
|
29
|
+
VALUE OilyPNG_Operations = rb_define_module_under(OilyPNG, "Operations");
|
|
30
|
+
rb_define_method(OilyPNG_Operations, "compose!", oily_png_compose_bang, -1);
|
|
31
|
+
rb_define_method(OilyPNG_Operations, "replace!", oily_png_replace_bang, -1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
char oily_png_samples_per_pixel(char color_mode) {
|
|
35
|
+
switch (color_mode) {
|
|
36
|
+
case OILY_PNG_COLOR_GRAYSCALE: return 1;
|
|
37
|
+
case OILY_PNG_COLOR_TRUECOLOR: return 3;
|
|
38
|
+
case OILY_PNG_COLOR_INDEXED: return 1;
|
|
39
|
+
case OILY_PNG_COLOR_GRAYSCALE_ALPHA: return 2;
|
|
40
|
+
case OILY_PNG_COLOR_TRUECOLOR_ALPHA: return 4;
|
|
41
|
+
default: rb_raise(rb_eRuntimeError, "Unsupported color mode: %d", color_mode);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
char oily_png_pixel_bitsize(char color_mode, char bit_depth) {
|
|
46
|
+
return oily_png_samples_per_pixel(color_mode) * bit_depth;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
char oily_png_pixel_bytesize(char color_mode, char bit_depth) {
|
|
50
|
+
return (bit_depth < 8) ? 1 : (oily_png_pixel_bitsize(color_mode, bit_depth) + 7) >> 3;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
long oily_png_scanline_bytesize(char color_mode, char bit_depth, long width) {
|
|
54
|
+
return (8 + ((oily_png_pixel_bitsize(color_mode, bit_depth) * width) + 7)) >> 3;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
long oily_png_pass_bytesize(char color_mode, char bit_depth, long width, long height) {
|
|
58
|
+
return (width == 0 || height == 0) ? 0 : (oily_png_scanline_bytesize(color_mode, bit_depth, width)) * height;
|
|
59
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#ifndef OILY_PNG_OILY_PNG_EXT
|
|
2
|
+
#define OILY_PNG_OILY_PNG_EXT
|
|
3
|
+
|
|
4
|
+
#include "ruby.h"
|
|
5
|
+
|
|
6
|
+
#define RSTRING_NOT_MODIFIED
|
|
7
|
+
|
|
8
|
+
// PNG color mode constants
|
|
9
|
+
#define OILY_PNG_COLOR_GRAYSCALE 0
|
|
10
|
+
#define OILY_PNG_COLOR_TRUECOLOR 2
|
|
11
|
+
#define OILY_PNG_COLOR_INDEXED 3
|
|
12
|
+
#define OILY_PNG_COLOR_GRAYSCALE_ALPHA 4
|
|
13
|
+
#define OILY_PNG_COLOR_TRUECOLOR_ALPHA 6
|
|
14
|
+
|
|
15
|
+
// PNG filter constants
|
|
16
|
+
#define OILY_PNG_FILTER_NONE 0
|
|
17
|
+
#define OILY_PNG_FILTER_SUB 1
|
|
18
|
+
#define OILY_PNG_FILTER_UP 2
|
|
19
|
+
#define OILY_PNG_FILTER_AVERAGE 3
|
|
20
|
+
#define OILY_PNG_FILTER_PAETH 4
|
|
21
|
+
|
|
22
|
+
// Macro to surpress warnings about unused parameters.
|
|
23
|
+
#define UNUSED_PARAMETER(param) (void) param
|
|
24
|
+
|
|
25
|
+
// Type definitions
|
|
26
|
+
typedef uint32_t PIXEL; // Pixels use 32 bits unsigned integers
|
|
27
|
+
typedef unsigned char BYTE; // Bytes use 8 bits unsigned integers
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
#include "png_decoding.h"
|
|
31
|
+
#include "png_encoding.h"
|
|
32
|
+
#include "color.h"
|
|
33
|
+
#include "operations.h"
|
|
34
|
+
#include "resampling.h"
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
Initialize the extension by creating the OilyPNG modules, and registering
|
|
38
|
+
the encoding and decoding replacement functions.
|
|
39
|
+
|
|
40
|
+
Note, this does not actually replace functionality in ChunkyPNG; you will need
|
|
41
|
+
to extend the ChunkyPNG::Canvas class with the OilyPNG::PNGDecoding module to
|
|
42
|
+
speed up decoding, and include OilyPNG::PNGEncoding into the same class to speed
|
|
43
|
+
up encoding. This is done in lib/oily_png.rb
|
|
44
|
+
*/
|
|
45
|
+
void Init_oily_png();
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
Returns the number of samples per pixel for a given color mode
|
|
49
|
+
*/
|
|
50
|
+
char oily_png_samples_per_pixel(char color_mode);
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
Returns the number of bits per pixel for a given color mode and bit depth.
|
|
54
|
+
*/
|
|
55
|
+
char oily_png_pixel_bitsize(char color_mode, char bit_depth);
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
Returns the number of bytes per pixel for a given color mode and bit depth.
|
|
59
|
+
*/
|
|
60
|
+
char oily_png_pixel_bytesize(char color_mode, char bit_depth);
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
Returns the number of bytes per scanline for a given width, color mode and bit depth.
|
|
64
|
+
*/
|
|
65
|
+
long oily_png_scanline_bytesize(char color_mode, char bit_depth, long width);
|
|
66
|
+
|
|
67
|
+
/*
|
|
68
|
+
Returns the number of bytes in an image pass with the given properties.
|
|
69
|
+
*/
|
|
70
|
+
long oily_png_pass_bytesize(char color_mode, char bit_depth, long width, long height);
|
|
71
|
+
|
|
72
|
+
#endif
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#include "oily_png_ext.h"
|
|
2
|
+
|
|
3
|
+
void oily_png_check_size_constraints(long self_width, long self_height, long other_width, long other_height, long offset_x, long offset_y){
|
|
4
|
+
// For now, these raise a standard runtime error. They should however raise custom exception classes (OutOfBounds)
|
|
5
|
+
if(self_width < other_width + offset_x){
|
|
6
|
+
rb_raise(rb_eRuntimeError, "Background image width is too small!");
|
|
7
|
+
}
|
|
8
|
+
if(self_height < other_height + offset_y){
|
|
9
|
+
rb_raise(rb_eRuntimeError, "Background image height is too small!");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
VALUE oily_png_compose_bang(int argc, VALUE *argv, VALUE self) {
|
|
14
|
+
// Corresponds to the other image(foreground) that we want to compose onto this one(background).
|
|
15
|
+
VALUE other;
|
|
16
|
+
|
|
17
|
+
// The offsets are optional arguments, so these may or may not be null pointers.
|
|
18
|
+
// We'll prefix them with 'opt' to identify this.
|
|
19
|
+
VALUE opt_offset_x;
|
|
20
|
+
VALUE opt_offset_y;
|
|
21
|
+
|
|
22
|
+
// Scan the passed in arguments, and populate the above-declared variables. Notice that '12'
|
|
23
|
+
// specifies that oily_png_compose_bang takes in 1 required parameter, and 2 optional ones (the offsets)
|
|
24
|
+
rb_scan_args(argc, argv, "12", &other,&opt_offset_x,&opt_offset_y);
|
|
25
|
+
|
|
26
|
+
// Regardless of whether offsets were provided, we must specify a default value for them since they will
|
|
27
|
+
// be used in calculating the position of the composed element.
|
|
28
|
+
long offset_x = 0;
|
|
29
|
+
long offset_y = 0;
|
|
30
|
+
|
|
31
|
+
// If offsets were provided, then the opt_offset_* variables will not be null pointers. FIXNUM_P checks
|
|
32
|
+
// whether they point to a fixnum object. If they do, then we can safely assign our offset_* variables to the values.
|
|
33
|
+
if(FIXNUM_P(opt_offset_x)){
|
|
34
|
+
offset_x = FIX2LONG(opt_offset_x);
|
|
35
|
+
}
|
|
36
|
+
if(FIXNUM_P(opt_offset_y)){
|
|
37
|
+
offset_y = FIX2LONG(opt_offset_y);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Get the dimension data for both foreground and background images.
|
|
41
|
+
long self_width = FIX2LONG(rb_funcall(self, rb_intern("width"), 0));
|
|
42
|
+
long self_height = FIX2LONG(rb_funcall(self, rb_intern("height"), 0));
|
|
43
|
+
long other_width = FIX2LONG(rb_funcall(other, rb_intern("width"), 0));
|
|
44
|
+
long other_height = FIX2LONG(rb_funcall(other, rb_intern("height"), 0));
|
|
45
|
+
|
|
46
|
+
// Make sure that the 'other' image fits within the current image. If it doesn't, an exception is raised
|
|
47
|
+
// and the operation should be aborted.
|
|
48
|
+
oily_png_check_size_constraints( self_width, self_height, other_width, other_height, offset_x, offset_y );
|
|
49
|
+
|
|
50
|
+
// Get the pixel data for both the foreground(other) and background(self) pixels.
|
|
51
|
+
VALUE* bg_pixels = RARRAY_PTR(rb_funcall(self, rb_intern("pixels"), 0));
|
|
52
|
+
VALUE* fg_pixels = RARRAY_PTR(rb_funcall(other, rb_intern("pixels"), 0));
|
|
53
|
+
|
|
54
|
+
long x = 0;
|
|
55
|
+
long y = 0;
|
|
56
|
+
long bg_index = 0; // corresponds to the current index in the bg_pixels array.
|
|
57
|
+
for( y = 0; y < other_height; y++ ){
|
|
58
|
+
for( x = 0; x < other_width; x++ ){
|
|
59
|
+
// We need to find the value of bg_index twice, so we only calculate and store it once.
|
|
60
|
+
bg_index = ( x + offset_x ) + ( y + offset_y ) * self_width;
|
|
61
|
+
// Replace the background pixel with the composition of background + foreground
|
|
62
|
+
bg_pixels[bg_index] = UINT2NUM( oily_png_compose_color( NUM2UINT( fg_pixels[x+ y * other_width] ), NUM2UINT( bg_pixels[bg_index] ) ) );
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return self;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
VALUE oily_png_replace_bang(int argc, VALUE *argv, VALUE self) {
|
|
70
|
+
// Corresponds to the other image(foreground) that we want to compose onto this one(background).
|
|
71
|
+
VALUE other;
|
|
72
|
+
|
|
73
|
+
// The offsets are optional arguments, so these may or may not be null pointers.
|
|
74
|
+
// We'll prefix them with 'opt' to identify this.
|
|
75
|
+
VALUE opt_offset_x;
|
|
76
|
+
VALUE opt_offset_y;
|
|
77
|
+
|
|
78
|
+
// Scan the passed in arguments, and populate the above-declared variables. Notice that '12'
|
|
79
|
+
// specifies that oily_png_compose_bang takes in 1 required parameter, and 2 optional ones (the offsets)
|
|
80
|
+
rb_scan_args(argc, argv, "12", &other,&opt_offset_x,&opt_offset_y);
|
|
81
|
+
|
|
82
|
+
// Regardless of whether offsets were provided, we must specify a default value for them since they will
|
|
83
|
+
// be used in calculating the position of the composed element.
|
|
84
|
+
long offset_x = 0;
|
|
85
|
+
long offset_y = 0;
|
|
86
|
+
|
|
87
|
+
// If offsets were provided, then the opt_offset_* variables will not be null pointers. FIXNUM_P checks
|
|
88
|
+
// whether they point to a fixnum object. If they do, then we can safely assign our offset_* variables to the values.
|
|
89
|
+
if(FIXNUM_P(opt_offset_x)){
|
|
90
|
+
offset_x = FIX2LONG(opt_offset_x);
|
|
91
|
+
}
|
|
92
|
+
if(FIXNUM_P(opt_offset_y)){
|
|
93
|
+
offset_y = FIX2LONG(opt_offset_y);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Get the dimension data for both foreground and background images.
|
|
97
|
+
long self_width = FIX2LONG(rb_funcall(self, rb_intern("width"), 0));
|
|
98
|
+
long self_height = FIX2LONG(rb_funcall(self, rb_intern("height"), 0));
|
|
99
|
+
long other_width = FIX2LONG(rb_funcall(other, rb_intern("width"), 0));
|
|
100
|
+
long other_height = FIX2LONG(rb_funcall(other, rb_intern("height"), 0));
|
|
101
|
+
|
|
102
|
+
// Make sure that the 'other' image fits within the current image. If it doesn't, an exception is raised
|
|
103
|
+
// and the operation should be aborted.
|
|
104
|
+
oily_png_check_size_constraints( self_width, self_height, other_width, other_height, offset_x, offset_y );
|
|
105
|
+
|
|
106
|
+
// Get the pixel data for both the foreground(other) and background(self) pixels.
|
|
107
|
+
VALUE* bg_pixels = RARRAY_PTR(rb_funcall(self, rb_intern("pixels"), 0));
|
|
108
|
+
VALUE* fg_pixels = RARRAY_PTR(rb_funcall(other, rb_intern("pixels"), 0));
|
|
109
|
+
|
|
110
|
+
long x = 0;
|
|
111
|
+
long y = 0;
|
|
112
|
+
long bg_index = 0; // corresponds to the current index in the bg_pixels array.
|
|
113
|
+
for( y = 0; y < other_height; y++ ){
|
|
114
|
+
for( x = 0; x < other_width; x++ ){
|
|
115
|
+
// We need to find the value of bg_index twice, so we only calculate and store it once.
|
|
116
|
+
bg_index = ( x + offset_x ) + ( y + offset_y ) * self_width;
|
|
117
|
+
// Replace the background pixel with the composition of background + foreground
|
|
118
|
+
bg_pixels[bg_index] = fg_pixels[x+ y * other_width];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return self;
|
|
122
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#ifndef OILY_PNG_OPERATIONS_H
|
|
2
|
+
#define OILY_PNG_OPERATIONS_H
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
Checks whether an image 'other' can fits into 'self'. Takes offset into account.
|
|
6
|
+
An exception is raised if the check fails.
|
|
7
|
+
|
|
8
|
+
Instead of taking in an object 'self' and an object 'other' and then calculating their parameters,
|
|
9
|
+
we ask for the respective height and width directly. This is because these variables will need to be calculated
|
|
10
|
+
by 'rb_intern()' within the method calling oily_png_check_size_constraints (ex: oily_png_compose), so there's no
|
|
11
|
+
use in calculating them twice.
|
|
12
|
+
|
|
13
|
+
*/
|
|
14
|
+
void oily_png_check_size_constraints(long self_width, long self_height, long other_width, long other_height, long offset_x, long offset_y);
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
C replacement method for composing another image onto this image using alpha blending.
|
|
18
|
+
|
|
19
|
+
TODO: Implement functionality with ChunkyPNG and OilyPNG so that an image can be composited onto another
|
|
20
|
+
regardless of its size: however, only the intersecting elements of both images should be mixed.
|
|
21
|
+
|
|
22
|
+
This method should replace ChunkyPNG::Canvas.compose!
|
|
23
|
+
*/
|
|
24
|
+
VALUE oily_png_compose_bang(int argc, VALUE *argv, VALUE c);
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
C replacement method for composing another image onto this image by simply replacing pixels.
|
|
28
|
+
|
|
29
|
+
TODO: Implement functionality with ChunkyPNG and OilyPNG so that an image can be composited onto another
|
|
30
|
+
regardless of its size: however, only the intersecting elements of both images should be mixed.
|
|
31
|
+
|
|
32
|
+
This method should replace ChunkyPNG::Canvas.replace!
|
|
33
|
+
*/
|
|
34
|
+
VALUE oily_png_replace_bang(int argc, VALUE *argv, VALUE c);
|
|
35
|
+
|
|
36
|
+
#endif
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
#include "oily_png_ext.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/////////////////////////////////////////////////////////////////////
|
|
5
|
+
// UNFILTERING SCANLINES
|
|
6
|
+
/////////////////////////////////////////////////////////////////////
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// Decodes a SUB filtered scanline at the given position in the byte array
|
|
10
|
+
void oily_png_decode_filter_sub(BYTE* bytes, long pos, long line_length, char pixel_size) {
|
|
11
|
+
long i;
|
|
12
|
+
for (i = 1 + pixel_size; i < line_length; i++) {
|
|
13
|
+
UNFILTER_BYTE(bytes[pos + i], bytes[pos + i - pixel_size]);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Decodes an UP filtered scanline at the given position in the byte array
|
|
18
|
+
void oily_png_decode_filter_up(BYTE* bytes, long pos, long line_size, char pixel_size) {
|
|
19
|
+
UNUSED_PARAMETER(pixel_size);
|
|
20
|
+
long i;
|
|
21
|
+
if (pos >= line_size) { // The first line is not filtered because there is no privous line
|
|
22
|
+
for (i = 1; i < line_size; i++) {
|
|
23
|
+
UNFILTER_BYTE(bytes[pos + i], bytes[pos + i - line_size]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Decodes an AVERAGE filtered scanline at the given position in the byte array
|
|
29
|
+
void oily_png_decode_filter_average(BYTE* bytes, long pos, long line_size, char pixel_size) {
|
|
30
|
+
long i;
|
|
31
|
+
BYTE a, b;
|
|
32
|
+
for (i = 1; i < line_size; i++) {
|
|
33
|
+
a = (i > pixel_size) ? bytes[pos + i - pixel_size] : 0;
|
|
34
|
+
b = (pos >= line_size) ? bytes[pos + i - line_size] : 0;
|
|
35
|
+
UNFILTER_BYTE(bytes[pos + i], (a + b) >> 1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Decodes a PAETH filtered scanline at the given position in the byte array
|
|
40
|
+
void oily_png_decode_filter_paeth(BYTE* bytes, long pos, long line_size, char pixel_size) {
|
|
41
|
+
BYTE a, b, c, pr;
|
|
42
|
+
long i, p, pa, pb, pc;
|
|
43
|
+
for (i = 1; i < line_size; i++) {
|
|
44
|
+
a = (i > pixel_size) ? bytes[pos + i - pixel_size] : 0;
|
|
45
|
+
b = (pos >= line_size) ? bytes[pos + i - line_size] : 0;
|
|
46
|
+
c = (pos >= line_size && i > pixel_size) ? bytes[pos + i - line_size - pixel_size] : 0;
|
|
47
|
+
p = a + b - c;
|
|
48
|
+
pa = (p > a) ? p - a : a - p;
|
|
49
|
+
pb = (p > b) ? p - b : b - p;
|
|
50
|
+
pc = (p > c) ? p - c : c - p;
|
|
51
|
+
pr = (pa <= pb) ? (pa <= pc ? a : c) : (pb <= pc ? b : c);
|
|
52
|
+
UNFILTER_BYTE(bytes[pos + i], pr);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/////////////////////////////////////////////////////////////////////
|
|
57
|
+
// BIT HANDLING
|
|
58
|
+
/////////////////////////////////////////////////////////////////////
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
BYTE oily_png_extract_1bit_element(BYTE* bytes, long start, long x) {
|
|
62
|
+
BYTE byte = bytes[start + 1 + (x >> 3)];
|
|
63
|
+
char bitshift = 7 - (x & (BYTE) 0x07);
|
|
64
|
+
return (byte & (0x01 << bitshift)) >> bitshift;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
BYTE oily_png_extract_2bit_element(BYTE* bytes, long start, long x) {
|
|
69
|
+
BYTE byte = bytes[start + 1 + (x >> 2)];
|
|
70
|
+
char bitshift = (6 - ((x & (BYTE) 0x03) << 1));
|
|
71
|
+
return (byte & (0x03 << bitshift)) >> bitshift;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
BYTE oily_png_extract_4bit_element(BYTE* bytes, long start, long x) {
|
|
75
|
+
return ((x & 0x01) == 0) ? ((bytes[(start) + 1 + ((x) >> 1)] & (BYTE) 0xf0) >> 4) : (bytes[(start) + 1 + ((x) >> 1)] & (BYTE) 0x0f);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
BYTE oily_png_resample_1bit_element(BYTE* bytes, long start, long x) {
|
|
79
|
+
BYTE value = oily_png_extract_1bit_element(bytes, start, x);
|
|
80
|
+
return (value == 0) ? 0x00 : 0xff;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
BYTE oily_png_resample_2bit_element(BYTE* bytes, long start, long x) {
|
|
84
|
+
return oily_png_extract_2bit_element(bytes, start, x) * 85;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
BYTE oily_png_resample_4bit_element(BYTE* bytes, long start, long x) {
|
|
88
|
+
return oily_png_extract_4bit_element(bytes, start, x) * 17;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/////////////////////////////////////////////////////////////////////
|
|
92
|
+
// PIXEL DECODING SCANLINES
|
|
93
|
+
/////////////////////////////////////////////////////////////////////
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
void oily_png_decode_scanline_grayscale_1bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
97
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
98
|
+
long x;
|
|
99
|
+
for (x = 0; x < width; x++) {
|
|
100
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
101
|
+
oily_png_resample_1bit_element(bytes, start, x),
|
|
102
|
+
oily_png_resample_1bit_element(bytes, start, x),
|
|
103
|
+
oily_png_resample_1bit_element(bytes, start, x),
|
|
104
|
+
0xff);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
void oily_png_decode_scanline_grayscale_2bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
109
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
110
|
+
long x;
|
|
111
|
+
for (x = 0; x < width; x++) {
|
|
112
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
113
|
+
oily_png_resample_2bit_element(bytes, start, x),
|
|
114
|
+
oily_png_resample_2bit_element(bytes, start, x),
|
|
115
|
+
oily_png_resample_2bit_element(bytes, start, x),
|
|
116
|
+
0xff);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
void oily_png_decode_scanline_grayscale_4bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
121
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
122
|
+
long x;
|
|
123
|
+
for (x = 0; x < width; x++) {
|
|
124
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
125
|
+
oily_png_resample_4bit_element(bytes, start, x),
|
|
126
|
+
oily_png_resample_4bit_element(bytes, start, x),
|
|
127
|
+
oily_png_resample_4bit_element(bytes, start, x),
|
|
128
|
+
0xff);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
void oily_png_decode_scanline_grayscale_8bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
133
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
134
|
+
long x;
|
|
135
|
+
for (x = 0; x < width; x++) {
|
|
136
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
137
|
+
bytes[start + 1 + x],
|
|
138
|
+
bytes[start + 1 + x],
|
|
139
|
+
bytes[start + 1 + x],
|
|
140
|
+
0xff);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
void oily_png_decode_scanline_grayscale_16bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
145
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
146
|
+
long x;
|
|
147
|
+
for (x = 0; x < width; x++) {
|
|
148
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
149
|
+
bytes[start + 1 + (x * 2)],
|
|
150
|
+
bytes[start + 1 + (x * 2)],
|
|
151
|
+
bytes[start + 1 + (x * 2)],
|
|
152
|
+
0xff);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
void oily_png_decode_scanline_grayscale_alpha_8bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
157
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
158
|
+
long x;
|
|
159
|
+
for (x = 0; x < width; x++) {
|
|
160
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
161
|
+
bytes[start + 1 + (x * 2) + 0],
|
|
162
|
+
bytes[start + 1 + (x * 2) + 0],
|
|
163
|
+
bytes[start + 1 + (x * 2) + 0],
|
|
164
|
+
bytes[start + 1 + (x * 2) + 1]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
void oily_png_decode_scanline_grayscale_alpha_16bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
169
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
170
|
+
long x;
|
|
171
|
+
for (x = 0; x < width; x++) {
|
|
172
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
173
|
+
bytes[start + 1 + (x * 4) + 0],
|
|
174
|
+
bytes[start + 1 + (x * 4) + 0],
|
|
175
|
+
bytes[start + 1 + (x * 4) + 0],
|
|
176
|
+
bytes[start + 1 + (x * 4) + 2]);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
void oily_png_decode_scanline_indexed_1bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
181
|
+
long x;
|
|
182
|
+
for (x = 0; x < width; x++) {
|
|
183
|
+
ADD_PIXEL_FROM_PALLETE(pixels, decoding_palette, oily_png_extract_1bit_element(bytes, start, x));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
void oily_png_decode_scanline_indexed_2bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
188
|
+
long x;
|
|
189
|
+
for (x = 0; x < width; x++) {
|
|
190
|
+
ADD_PIXEL_FROM_PALLETE(pixels, decoding_palette, oily_png_extract_2bit_element(bytes, start, x));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
void oily_png_decode_scanline_indexed_4bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
195
|
+
long x;
|
|
196
|
+
for (x = 0; x < width; x++) {
|
|
197
|
+
ADD_PIXEL_FROM_PALLETE(pixels, decoding_palette, oily_png_extract_4bit_element(bytes, start, x));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
void oily_png_decode_scanline_indexed_8bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
202
|
+
long x;
|
|
203
|
+
for (x = 0; x < width; x++) {
|
|
204
|
+
ADD_PIXEL_FROM_PALLETE(pixels, decoding_palette, bytes[start + 1 + x]);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
void oily_png_decode_scanline_truecolor_8bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
209
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
210
|
+
long x;
|
|
211
|
+
for (x = 0; x < width; x++) {
|
|
212
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
213
|
+
bytes[start + 1 + (x * 3) + 0],
|
|
214
|
+
bytes[start + 1 + (x * 3) + 1],
|
|
215
|
+
bytes[start + 1 + (x * 3) + 2],
|
|
216
|
+
0xff);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
void oily_png_decode_scanline_truecolor_16bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
221
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
222
|
+
long x;
|
|
223
|
+
for (x = 0; x < width; x++) {
|
|
224
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
225
|
+
bytes[start + 1 + (x * 6) + 0],
|
|
226
|
+
bytes[start + 1 + (x * 6) + 2],
|
|
227
|
+
bytes[start + 1 + (x * 6) + 4],
|
|
228
|
+
0xff);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
void oily_png_decode_scanline_truecolor_alpha_8bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
233
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
234
|
+
long x;
|
|
235
|
+
for (x = 0; x < width; x++) {
|
|
236
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
237
|
+
bytes[start + 1 + (x * 4) + 0],
|
|
238
|
+
bytes[start + 1 + (x * 4) + 1],
|
|
239
|
+
bytes[start + 1 + (x * 4) + 2],
|
|
240
|
+
bytes[start + 1 + (x * 4) + 3]);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
void oily_png_decode_scanline_truecolor_alpha_16bit(VALUE pixels, BYTE* bytes, long start, long width, VALUE decoding_palette) {
|
|
245
|
+
UNUSED_PARAMETER(decoding_palette);
|
|
246
|
+
long x;
|
|
247
|
+
for (x = 0; x < width; x++) {
|
|
248
|
+
ADD_PIXEL_FROM_RGBA(pixels,
|
|
249
|
+
bytes[start + 1 + (x * 8) + 0],
|
|
250
|
+
bytes[start + 1 + (x * 8) + 2],
|
|
251
|
+
bytes[start + 1 + (x * 8) + 4],
|
|
252
|
+
bytes[start + 1 + (x * 8) + 6]);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
scanline_decoder_func oily_png_decode_scanline_func(int color_mode, int bit_depth) {
|
|
257
|
+
switch (color_mode) {
|
|
258
|
+
case OILY_PNG_COLOR_GRAYSCALE:
|
|
259
|
+
switch (bit_depth) {
|
|
260
|
+
case 1: return &oily_png_decode_scanline_grayscale_1bit;
|
|
261
|
+
case 2: return &oily_png_decode_scanline_grayscale_2bit;
|
|
262
|
+
case 4: return &oily_png_decode_scanline_grayscale_4bit;
|
|
263
|
+
case 8: return &oily_png_decode_scanline_grayscale_8bit;
|
|
264
|
+
case 16: return &oily_png_decode_scanline_grayscale_16bit;
|
|
265
|
+
default: return NULL;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
case OILY_PNG_COLOR_TRUECOLOR:
|
|
269
|
+
switch (bit_depth) {
|
|
270
|
+
case 8: return &oily_png_decode_scanline_truecolor_8bit;
|
|
271
|
+
case 16: return &oily_png_decode_scanline_truecolor_16bit;
|
|
272
|
+
default: return NULL;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
case OILY_PNG_COLOR_INDEXED:
|
|
276
|
+
switch (bit_depth) {
|
|
277
|
+
case 1: return &oily_png_decode_scanline_indexed_1bit;
|
|
278
|
+
case 2: return &oily_png_decode_scanline_indexed_2bit;
|
|
279
|
+
case 4: return &oily_png_decode_scanline_indexed_4bit;
|
|
280
|
+
case 8: return &oily_png_decode_scanline_indexed_8bit;
|
|
281
|
+
default: return NULL;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
case OILY_PNG_COLOR_GRAYSCALE_ALPHA:
|
|
285
|
+
switch (bit_depth) {
|
|
286
|
+
case 8: return &oily_png_decode_scanline_grayscale_alpha_8bit;
|
|
287
|
+
case 16: return &oily_png_decode_scanline_grayscale_alpha_16bit;
|
|
288
|
+
default: return NULL;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
case OILY_PNG_COLOR_TRUECOLOR_ALPHA:
|
|
292
|
+
switch (bit_depth) {
|
|
293
|
+
case 8: return &oily_png_decode_scanline_truecolor_alpha_8bit;
|
|
294
|
+
case 16: return &oily_png_decode_scanline_truecolor_alpha_16bit;
|
|
295
|
+
default: return NULL;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
default: return NULL;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/////////////////////////////////////////////////////////////////////
|
|
303
|
+
// DECODING AN IMAGE PASS
|
|
304
|
+
/////////////////////////////////////////////////////////////////////
|
|
305
|
+
|
|
306
|
+
VALUE oily_png_decode_palette(VALUE self) {
|
|
307
|
+
VALUE palette_instance = rb_funcall(self, rb_intern("decoding_palette"), 0);
|
|
308
|
+
if (palette_instance != Qnil) {
|
|
309
|
+
VALUE decoding_map = rb_iv_get(palette_instance, "@decoding_map");
|
|
310
|
+
if (rb_funcall(decoding_map, rb_intern("kind_of?"), 1, rb_cArray) == Qtrue) {
|
|
311
|
+
return decoding_map;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
rb_raise(rb_eRuntimeError, "Could not retrieve a decoding palette for this image!");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
VALUE oily_png_decode_png_image_pass(VALUE self, VALUE stream, VALUE width, VALUE height, VALUE color_mode, VALUE depth, VALUE start_pos) {
|
|
319
|
+
|
|
320
|
+
VALUE pixels = rb_ary_new();
|
|
321
|
+
|
|
322
|
+
if ((FIX2LONG(height) > 0) && (FIX2LONG(width) > 0)) {
|
|
323
|
+
|
|
324
|
+
char pixel_size = oily_png_pixel_bytesize(FIX2INT(color_mode), FIX2INT(depth));
|
|
325
|
+
long line_size = oily_png_scanline_bytesize(FIX2INT(color_mode), FIX2INT(depth), FIX2LONG(width));
|
|
326
|
+
long pass_size = oily_png_pass_bytesize(FIX2INT(color_mode), FIX2INT(depth), FIX2LONG(width), FIX2LONG(height));
|
|
327
|
+
|
|
328
|
+
// Make sure that the stream is large enough to contain our pass.
|
|
329
|
+
if (RSTRING_LEN(stream) < pass_size + FIX2LONG(start_pos)) {
|
|
330
|
+
rb_raise(rb_eRuntimeError, "The length of the stream is too short to contain the image!");
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Copy the bytes for this pass from the stream to a separate location
|
|
334
|
+
// so we can work on this byte array directly.
|
|
335
|
+
BYTE* bytes = ALLOC_N(BYTE, pass_size);
|
|
336
|
+
memcpy(bytes, RSTRING_PTR(stream) + FIX2LONG(start_pos), pass_size);
|
|
337
|
+
|
|
338
|
+
// Get the decoding palette for indexed images.
|
|
339
|
+
VALUE decoding_palette = Qnil;
|
|
340
|
+
if (FIX2INT(color_mode) == OILY_PNG_COLOR_INDEXED) {
|
|
341
|
+
decoding_palette = oily_png_decode_palette(self);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Select the scanline decoder function for this color mode and bit depth.
|
|
345
|
+
scanline_decoder_func scanline_decoder = oily_png_decode_scanline_func(FIX2INT(color_mode), FIX2INT(depth));
|
|
346
|
+
if (scanline_decoder == NULL) {
|
|
347
|
+
rb_raise(rb_eRuntimeError, "No decoder for color mode %d and bit depth %d", FIX2INT(color_mode), FIX2INT(depth));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
long y, line_start;
|
|
351
|
+
for (y = 0; y < FIX2LONG(height); y++) {
|
|
352
|
+
line_start = y * line_size;
|
|
353
|
+
|
|
354
|
+
// Apply filering to the line
|
|
355
|
+
switch (bytes[line_start]) {
|
|
356
|
+
case OILY_PNG_FILTER_NONE: break;
|
|
357
|
+
case OILY_PNG_FILTER_SUB: oily_png_decode_filter_sub( bytes, line_start, line_size, pixel_size); break;
|
|
358
|
+
case OILY_PNG_FILTER_UP: oily_png_decode_filter_up( bytes, line_start, line_size, pixel_size); break;
|
|
359
|
+
case OILY_PNG_FILTER_AVERAGE: oily_png_decode_filter_average( bytes, line_start, line_size, pixel_size); break;
|
|
360
|
+
case OILY_PNG_FILTER_PAETH: oily_png_decode_filter_paeth( bytes, line_start, line_size, pixel_size); break;
|
|
361
|
+
default: rb_raise(rb_eRuntimeError, "Filter type not supported: %d", bytes[line_start]);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Set the filter byte to 0 because the bytearray is now unfiltered.
|
|
365
|
+
bytes[line_start] = OILY_PNG_FILTER_NONE;
|
|
366
|
+
scanline_decoder(pixels, bytes, line_start, FIX2LONG(width), decoding_palette);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
xfree(bytes);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Now, return a new ChunkyPNG::Canvas instance with the decoded pixels.
|
|
373
|
+
return rb_funcall(self, rb_intern("new"), 3, width, height, pixels);
|
|
374
|
+
}
|