Class: TexPlay::ImageStub

Inherits:
Object
  • Object
show all
Defined in:
lib/texplay.rb

Overview

Used internally to create images from raw binary (blob) data (TexPlay::from_blob).

This object duck-types an RMagick image (#rows, #columns, #to_blob), so that Gosu will import it.

Direct Known Subclasses

EmptyImageStub

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blob_data, width, height) ⇒ ImageStub

The first pixel in the blob will be at the top left hand corner of the created image, since that is the orientation of Gosu images.

Parameters:

  • blob_data (String)

    Raw data string to import. Must be RGBA ordered, (4 * width * height) bytes in length.

  • width (Integer)

    Number of pixels wide.

  • height (Integer)

    Number of pixels high.



140
141
142
# File 'lib/texplay.rb', line 140

def initialize(blob_data, width, height)
  @data, @columns, @rows = blob_data, width, height
end

Instance Attribute Details

#columnsInteger (readonly)

Returns:

  • (Integer)


132
133
134
# File 'lib/texplay.rb', line 132

def columns
  @columns
end

#rowsInteger (readonly)

Returns:

  • (Integer)


132
133
134
# File 'lib/texplay.rb', line 132

def rows
  @rows
end

Instance Method Details

#to_blobString

Returns:

  • (String)


145
146
147
# File 'lib/texplay.rb', line 145

def to_blob
  @data
end