Class: TinyGLTF::Image

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/tiny_gltf.rb,
ext/tiny_gltf/rb_tiny_gltf_init.c

Instance Attribute Summary

Attributes included from Base

#model

Instance Method Summary collapse

Methods included from Base

included, #inspect, #to_h, #to_json

Constructor Details

#initialize(model = nil, name: nil, width: nil, height: nil, components: nil, buffer_view_index: nil, mime_type: nil, uri: nil, extras: nil, extensions: nil) ⇒ Image

Returns a new instance of Image.



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/tiny_gltf.rb', line 306

def initialize(model = nil,
               name:              nil,
               width:             nil,
               height:            nil,
               components:        nil,
               buffer_view_index: nil,
               mime_type:         nil,
               uri:               nil,
               extras:            nil,
               extensions:        nil)
  @model             = model
  @name              = name
  @width             = width
  @height            = height
  @components        = components
  @buffer_view_index = buffer_view_index
  @mime_type         = mime_type
  @extras            = extras
  @extensions        = extensions
  self.uri = uri if uri
end

Instance Method Details

#buffer_viewObject



328
329
330
# File 'lib/tiny_gltf.rb', line 328

def buffer_view
  buffer_view_index && model.buffer_views[buffer_view_index]
end

#sizeObject

Returns the size of the image data in bytes.

#to_ptrObject

Returns a Fiddle::Pointer representing the start of the image data in memory. For performance, try to use this rather than #to_s.

#to_sObject

Returns a string containing the raw image data. For better performance, prefer #to_ptr where possible.

#uriObject

Returns the URI from which this data was retrieved, if available. Returns nil if a URI was not used.

#uri=Object