Class: ChunkyPNG::Chunk::CompressedText

### Home Classes Methods

### In Files

- lib/chunky_png/chunk.rb

### Parent

ChunkyPNG::Chunk::Base

### Methods

- ::new
- ::read
- #content

### Files

- BENCHMARKING.rdoc
- CHANGELOG.rdoc
- CONTRIBUTING.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- ChunkyPNG
- ChunkyPNG::CRCMismatch
- ChunkyPNG::Canvas
- ChunkyPNG::Canvas::Adam7Interlacing
- ChunkyPNG::Canvas::DataUrlExporting
- ChunkyPNG::Canvas::DataUrlImporting
- ChunkyPNG::Canvas::Drawing
- ChunkyPNG::Canvas::Masking
- ChunkyPNG::Canvas::Operations
- ChunkyPNG::Canvas::PNGDecoding
- ChunkyPNG::Canvas::PNGEncoding
- ChunkyPNG::Canvas::Resampling
- ChunkyPNG::Canvas::StreamExporting
- ChunkyPNG::Canvas::StreamImporting
- ChunkyPNG::Chunk
- ChunkyPNG::Chunk::Base
- ChunkyPNG::Chunk::CompressedText
- ChunkyPNG::Chunk::End
- ChunkyPNG::Chunk::Generic
- ChunkyPNG::Chunk::Header
- ChunkyPNG::Chunk::ImageData
- ChunkyPNG::Chunk::InternationalText
- ChunkyPNG::Chunk::Palette
- ChunkyPNG::Chunk::Text
- ChunkyPNG::Chunk::Transparency
- ChunkyPNG::Color
- ChunkyPNG::Datastream
- ChunkyPNG::Dimension
- ChunkyPNG::Exception
- ChunkyPNG::ExpectationFailed
- ChunkyPNG::Image
- ChunkyPNG::NotSupported
- ChunkyPNG::OutOfBounds
- ChunkyPNG::Palette
- ChunkyPNG::Point
- ChunkyPNG::RMagick
- ChunkyPNG::SignatureMismatch
- ChunkyPNG::Vector
- Enumerable
- String

No matching classes.

# ChunkyPNG::Chunk::CompressedText

The CompressedText (zTXt) chunk contains keyword/value metadata about the PNG stream. In this chunk, the value is compressed using Deflate compression.

@see ChunkyPNG::Chunk::CompressedText @see ChunkyPNG::Chunk::InternationalText

### Attributes

keyword[RW]
value[RW]

### Public Class Methods

new(keyword, value) click to toggle source

    # File lib/chunky_png/chunk.rb, line 297
    def initialize(keyword, value)
      super('zTXt')
      @keyword, @value = keyword, value
    end

read(type, content) click to toggle source

    # File lib/chunky_png/chunk.rb, line 302
    def self.read(type, content)
      keyword, compression, value = content.unpack('Z*Ca*')
      raise ChunkyPNG::NotSupported, "Compression method #{compression.inspect} not supported!" unless compression == ChunkyPNG::COMPRESSION_DEFAULT
      new(keyword, Zlib::Inflate.inflate(value))
    end

### Public Instance Methods

content() click to toggle source

Creates the content to write to the stream, by concatenating the keyword with the deflated value, joined by a null character.

@return The content that should be written to the datastream.

    # File lib/chunky_png/chunk.rb, line 312
    def content
      [keyword, ChunkyPNG::COMPRESSION_DEFAULT, Zlib::Deflate.deflate(value)].
        pack('Z*Ca*')
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.