Sha256: de938d2696e687eb5c90837d7d15cc463acaf2c9f05405a42afd0e405b070cd3

Contents?: true

Size: 723 Bytes

Versions: 23

Compression:

Stored size: 723 Bytes

Contents

class PSD::Image
  module Export
    # PNG image export. This is the default export format.
    module PNG
      # Load the image pixels into a PNG file and return a reference to the
      # data.
      def to_png
        return @png if @png

        PSD.logger.debug "Beginning PNG export"
        @png = ChunkyPNG::Canvas.new(width.to_i, height.to_i, ChunkyPNG::Color::TRANSPARENT)

        i = 0
        height.times do |y|
          width.times do |x|
            @png[x, y] = @pixel_data[i]
            i += 1
          end
        end

        @png
      end
      alias :export :to_png

      # Saves the PNG data to disk.
      def save_as_png(file)
        to_png.save(file, :fast_rgba)
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
psd-3.9.0 lib/psd/image_exports/png.rb
psd-3.8.0 lib/psd/image_exports/png.rb
psd-3.7.0 lib/psd/image_exports/png.rb
psd-3.6.0 lib/psd/image_exports/png.rb
bench9000-0.1 vendor/psd.rb/lib/psd/image_exports/png.rb
psd-3.5.0 lib/psd/image_exports/png.rb
psd-3.4.0 lib/psd/image_exports/png.rb
psd-3.3.3 lib/psd/image_exports/png.rb
psd-3.3.2 lib/psd/image_exports/png.rb
psd-3.3.1 lib/psd/image_exports/png.rb
psd-3.2.4 lib/psd/image_exports/png.rb
psd-3.2.3 lib/psd/image_exports/png.rb
psd-3.2.2 lib/psd/image_exports/png.rb
psd-3.2.1 lib/psd/image_exports/png.rb
psd-3.2.0 lib/psd/image_exports/png.rb
psd-3.1.5 lib/psd/image_exports/png.rb
psd-3.1.4 lib/psd/image_exports/png.rb
psd-3.1.3 lib/psd/image_exports/png.rb
psd-3.1.2 lib/psd/image_exports/png.rb
psd-2.1.2 lib/psd/image_exports/png.rb