Class: FreeImage::AbstractSource

Inherits:
Object
  • Object
show all
Defined in:
lib/free-image/sources/abstract_source.rb

Overview

Summary

FreeImage can load images from a variety of files, memory or streams. For additional details please see:

FreeImage::File

Use to load images from files

FreeImage::Memory

Use to load images from byte strings

FreeImage::IO

Use to load images from io streams

Direct Known Subclasses

File, IO, Memory

Defined Under Namespace

Modules: Decoder, Encoder

Instance Method Summary collapse

Instance Method Details

#open(format = nil, flags = 0) ⇒ Object

:nodoc: - This method is documented on subclasses



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/free-image/sources/abstract_source.rb', line 155

def open(format = nil, flags = 0)
  format ||= self.format

  # Do we know the format?
  if format == :unknown
    raise(Error.new(:unknown, "Cannot load :unknown image format"))
  end

  # Can we load the image?
  unless FreeImage.FreeImage_FIFSupportsReading(format)
    raise(Error.new("Cannot load image"))
  end

  ptr = load(format, flags)
  Bitmap.new(ptr, self)
end