Class: FreeImage::AbstractSource
- Inherits:
-
Object
- Object
- FreeImage::AbstractSource
- 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
Defined Under Namespace
Instance Method Summary collapse
-
#open(format = nil, flags = 0) ⇒ Object
:nodoc: - This method is documented on subclasses.
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 171 172 173 174 175 176 177 |
# 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) # Make sure we didn't get a null pointer. This can # happen - see test_file for example#test_corrupt_wrong_format if ptr.null? error = Error.new(:unknown, "Could not load the image") raise(error) end Bitmap.new(ptr, self) end |