Class RS::Utils::RSImageProperties
In: rsil/utils/rsimageproperties.rb
Parent: RS::Utils::RSProperties
RSTripel RSRectangle RSObjcWrapper RSImageUnit RSImageList RSILRMagickConverter RSILTkConverter RSConverter RSProperties RSImageProperties RSPoint RSDimension Array RSVector RSFilter RSColor RSImage\n[rsil/extension/rsimageextension.rb\nrsil/graphics/rsimage.rb] RSImageX Comparable RSAbstractConverter Enumerable Test::Unit::TestCase RSTestPoint RSTestFilter RSTestImage RSTestExtension RSTestDimension RSTestVector RSTestImageUnit RSTestImageProperties RSTestColor RSTestRectangle RSTestProperties RSTestImageList RSTestConverter RSTestComparison RSTestStress RSTestUseCases RSTestTripel RSTestScenarios MonitorMixin Benchmark StandardError Assertion RSEXIFProperties RSTests rsil/geometry/rsdimension.rb rsil/geometry/rspoint.rb rsil/geometry/rsvector.rb rsil/geometry/rsrectangle.rb rsil/geometry/rstripel.rb Geometry rsil/graphics/rsfilter.rb rsil/graphics/rsimagelist.rb rsil/graphics/rscolor.rb rsil/graphics/rsimageunit.rb rsil/extension/rsimagex.rb rsil/graphics/rsimage.rb Graphics rsil/converter/rsconverter.rb rsil/converter/rsabstractconverter.rb rsil/converter/rsiltkconverter.rb rsil/converter/rsilrmagickconverter.rb Converter rsil/test/rstestusecases.rb rsil/test/rstestcolor.rb rsil/test/rstestdimension.rb rsil/test/rstestfilter.rb rsil/test/rstestpoint.rb rsil/test/rstestconverter.rb rsil/test/rstestimagelist.rb rsil/test/rstestimageproperties.rb rsil/test/rstestscenarios.rb rsil/test/rstestvector.rb rsil/test/rstesttripel.rb rsil/test/rstestproperties.rb rsil/test/rstestimageunit.rb rsil/test/rstestextension.rb rsil/test/rstestimage.rb rsil/test/rsteststress.rb rsil/test/rstestcomparison.rb rsil/test/rstestrectangle.rb rsil/test/rstests.rb Test rsil/extension/rsextension.rb Extension rsil/utils/rsimageproperties.rb rsil/utils/rsobjcwrapper.rb rsil/utils/rsproperties.rb rsil/utils/rsexifproperties.rb Utils RS Module: RS

Class:RSImageProperties
File:rsobjcwrapper.rb
Purpose:RSImageProperties is used to keep input and output paremters for image files.
Created by:Mario Pehle, 2006/04/29
Required modules:-
Offers functions:-

Methods

Included Modules

RS::Extension

Constants

DEFAULT_CAPACITY = 13   The default capacity for the properties is set to 13, because there are 13 properties for an image settable with Cocoa.
FILE_TYPES = { :BMP => OSX::NSBMPFileType, :GIF => OSX::NSGIFFileType, :JPEG => OSX::NSJPEGFileType, :JPG => OSX::NSJPEGFileType, :JPEG2000 => OSX::NSJPEG2000FileType, :JP2 => OSX::NSJPEG2000FileType, :PNG => OSX::NSPNGFileType, :TIFF => OSX::NSTIFFFileType, :TIF => OSX::NSTIFFFileType, :bmp => OSX::NSBMPFileType, :gif => OSX::NSGIFFileType, :jpeg => OSX::NSJPEGFileType, :jpg => OSX::NSJPEGFileType, :jpeg2000 => OSX::NSJPEG2000FileType, :jp2 => OSX::NSJPEG2000FileType, :png => OSX::NSPNGFileType, :tiff => OSX::NSTIFFFileType, :tif => OSX::NSTIFFFileType, 'BMP' => OSX::NSBMPFileType, 'GIF' => OSX::NSGIFFileType, 'JPEG' => OSX::NSJPEGFileType, 'JPG' => OSX::NSJPEGFileType, 'JPEG2000' => OSX::NSJPEG2000FileType, 'JP2' => OSX::NSJPEG2000FileType, 'PNG' => OSX::NSPNGFileType, 'TIFF' => OSX::NSTIFFFileType, 'TIF' => OSX::NSTIFFFileType, 'bmp' => OSX::NSBMPFileType, 'gif' => OSX::NSGIFFileType, 'jpeg' => OSX::NSJPEGFileType, 'jpg' => OSX::NSJPEGFileType, 'jpeg2000' => OSX::NSJPEG2000FileType, 'jp2' => OSX::NSJPEG2000FileType, 'png' => OSX::NSPNGFileType, 'tiff' => OSX::NSTIFFFileType, 'tif' => OSX::NSTIFFFileType }   The Hash TILE_TYPES includes constants for specifing common file formats.
TIFF_CONSTANTS = [ OSX::NSTIFFCompressionNone, OSX::NSTIFFCompressionCCITTFAX3, OSX::NSTIFFCompressionCCITTFAX4, OSX::NSTIFFCompressionLZW, OSX::NSTIFFCompressionNEXT, OSX::NSTIFFCompressionPackBits ]   The array TIFF_CONSTANTS saves the 6 compression types Cocoa is able to handle.
DEFAULTS = { OSX::NSBitmapImageRep.getConstNSImageCompressionFactor => 0.0, OSX::NSBitmapImageRep.getConstNSImageCompressionMethod => OSX::NSTIFFCompressionNone, OSX::NSBitmapImageRep.getConstNSImageDitherTransparency => true, OSX::NSBitmapImageRep.getConstNSImageInterlaced => true, OSX::NSBitmapImageRep.getConstNSImageFrameCount => 1, OSX::NSBitmapImageRep.getConstNSImageCurrentFrame => 0, OSX::NSBitmapImageRep.getConstNSImageCurrentFrameDuration => 0.0, OSX::NSBitmapImageRep.getConstNSImageProgressive => true, OSX::NSBitmapImageRep.getConstNSImageLoopCount => 0.0 }   The DEFAULTS hash is merged with the parameters entered while initializing RSImageProperties.

Public Class methods

Description:Creates a RSImageProperty object through wrapping of OSX::NSDictionary. Merges given values against DEFAULT values. If nothing is set, takes the DEFAULT values.
Precondition:-
Postcondition:Object is initialized with given values merged with DEFAULTS and DEFAULT_CAPACITY.
Exceptions:ArgumentError
Uses:super, Hash#merge, DEFAULT_CAPACITY, DEFAULTS
Returns:RSImageProperty
Parameters:Name | i/o/io | default | Meaning
:hash | i | DEFAULT | Hash, the values to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 108
108:   def initialize hash=DEFAULTS
109:     if hash.kind_of? Hash
110:       super DEFAULT_CAPACITY
111:       DEFAULTS.merge(hash).each { |key, value| set key, value }
112:     else
113:       raise ArgumentError, "Argument has to be a Hash."
114:     end
115:     self
116:   end

Public Instance methods

Description:Determines the colorsync profile data.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Object
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 152
152:   def colorsyncprofiledata
153:     get OSX::NSBitmapImageRep.getConstNSImageColorSyncProfileData
154:   end
Description:Sets the colorsync profile data.
Precondition:-
Postcondition:colorsyncprofiledata is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | OSX::NSData / OSX::OCObject, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 131
131:   def colorsyncprofiledata= value
132:     if value.kind_of?(OSX::NSData) or value.kind_of?(OSX::OCObject)
133:       set OSX::NSBitmapImageRep.getConstNSImageColorSyncProfileData, value
134:       return value
135:     else
136:       raise ArgumentError, "Argument has to be a NSData object."
137:     end
138:   end
Description:Determines the compression factor.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Object
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 192
192:   def compressionfactor
193:     get OSX::NSBitmapImageRep.getConstNSImageCompressionFactor
194:   end
Description:Sets the compression factor, 0.0 smalles, 1.0 highest compression.
Precondition:value betwenn 0.0 and 1.0
Postcondition:compressionfactor is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | float, >= 0.0 and 1.0 the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 169
169:   def compressionfactor= value
170:     if value.respond_to? :to_f
171:       v = value.to_f
172:       raise ArgumentError, "'value' has to be between 0.0 and 1.0 " if v < 0.0 or v > 1.0
173:       set OSX::NSBitmapImageRep.getConstNSImageCompressionFactor, v
174:       return value
175:     else
176:       raise ArgumentError, "Can not convert argument. Has to be a Float between 0.0 and 1.0."
177:     end
178:   end
Description:Determines the compression method.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Object
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 230
230:   def compressionmethod
231:     get OSX::NSBitmapImageRep.getConstNSImageCompressionMethod
232:   end
Description:Sets the compression method. Only for TIFF.
Precondition:-
Postcondition:compressionmethod is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | Float, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 209
209:   def compressionmethod= value
210:     if value.respond_to? :to_i
211:       set OSX::NSBitmapImageRep.getConstNSImageCompressionMethod, value.to_i
212:       return value
213:     else
214:       raise ArgumentError, "Can not convert argument. Has to be a Float."
215:     end
216:   end
Description:Determines the current frame for a GIF animation. The first frame has number 0.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Object
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 506
506:   def currentframe
507:     get OSX::NSBitmapImageRep.getConstNSImageCurrentFrame
508:   end
Description:Sets the current frame. Only for GIF.
Precondition:-
Postcondition:currentframe is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | Fixnum, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 485
485:   def currentframe= value
486:     if value.respond_to? :to_i
487:       set OSX::NSBitmapImageRep.getConstNSImageCurrentFrame, value.to_i
488:       return value
489:     else
490:       raise ArgumentError, "Can not convert argument. Has to be a Fixnum."
491:     end
492:   end
Description:Determines the duration of the current frame of a GIF animation. Unfortunately it is no value support when writing out.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Object
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 628
628:   def currentframeduration
629:     get OSX::NSBitmapImageRep.getConstNSImageCurrentFrameDuration
630:   end
Description:Sets the current frame duration. Only for GIF.
Precondition:-
Postcondition:value greater or equal 0.0. currentframeduration is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | float >= 0.0, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 605
605:   def currentframeduration= value
606:     if value.respond_to? :to_f
607:       v = value.to_f
608:       raise ArgumentError, "'value' has to be greater or equal 0.0" if v < 0.0
609:       set OSX::NSBitmapImageRep.getConstNSImageGamma, v
610:       return value
611:     else
612:       raise ArgumentError, "Can not convert argument. Has to be a float >= 0.0."
613:     end
614:   end
Description:Determines, whether dithering is on or off.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Boolena if set, else nil
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 268
268:   def dithertransparency
269:     value = get OSX::NSBitmapImageRep.getConstNSImageDitherTransparency
270:     unless value.nil?
271:       value = value == 0.0 ? false : true
272:     end
273:     value
274:   end
Description:Sets, whether to dither the image. Only for GIF.
Precondition:-
Postcondition:dithertransparency is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | bool, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 247
247:   def dithertransparency= value
248:     if value.kind_of?(TrueClass) or value.kind_of?(FalseClass)
249:       set OSX::NSBitmapImageRep.getConstNSImageDitherTransparency, value
250:       return value
251:     else
252:       raise ArgumentError, "Argument has to be a boolean."
253:     end
254:   end
Description:Determines the EXIF data.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Object
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 390
390:   def exifdata
391:     get OSX::NSBitmapImageRep.getConstNSImageEXIFData
392:   end
Description:Sets the EXIF data of the image from a RSProperties object. Only for JPEG.
Precondition:-
Postcondition:exifdata is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | RSProperties / RSEXIFProperties, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 369
369:   def exifdata= value
370:     if value.kind_of? RSProperties
371:       set OSX::NSBitmapImageRep.getConstNSImageEXIFData, value.obj_object
372:       return value
373:     else
374:       raise ArgumentError, "Argument has to be a RSProperties object."
375:     end
376:   end
Description:Determines the number of frames in a GIF. Only useful, when reading in a GIF file.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Object
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 428
428:   def framecount
429:     get OSX::NSBitmapImageRep.getConstNSImageFrameCount
430:   end
Description:Sets the frame count, the number of frames. Only for GIF.
Precondition:-
Postcondition:framecount is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | Fixnum, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 407
407:   def framecount= value
408:     if value.respond_to? :to_i
409:       set OSX::NSBitmapImageRep.getConstNSImageFrameCount, value.to_i
410:       return value
411:     else
412:       raise ArgumentError, "Can not convert argument. Has to be a Fixnum."
413:     end
414:   end
Description:Determines the value for gamma.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Object
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 468
468:   def gamma
469:     get OSX::NSBitmapImageRep.getConstNSImageGamma
470:   end
Description:Sets the image gamma. Only for PNG.
Precondition:-
Postcondition:value betwenn 0.0 and 1.0. gamma is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | float >= 0.0 and <= 1.0, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 445
445:   def gamma= value
446:     if value.respond_to? :to_f
447:       v = value.to_f
448:       raise ArgumentError, "'value' has to be between 0.0 and 1.0 " if v < 0.0 or v > 1.0
449:       set OSX::NSBitmapImageRep.getConstNSImageGamma, v
450:       return value
451:     else
452:       raise ArgumentError, "Can not convert argument. Has to be a float >= 0.0 and <= 1.0."
453:     end
454:   end
Description:Determines, whether interlace is on or off.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Boolean if set, else nil
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 310
310:   def interlaced
311:     value = get OSX::NSBitmapImageRep.getConstNSImageInterlaced
312:     unless value.nil?
313:       value = value == 0.0 ? false : true
314:     end
315:     value
316:   end
Description:Sets, whether the image is interlaced. Only for PNG.
Precondition:-
Postcondition:interlaced is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | bool, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 289
289:   def interlaced= value
290:     if value.kind_of?(TrueClass) or value.kind_of?(FalseClass)
291:       set OSX::NSBitmapImageRep.getConstNSImageInterlaced, value
292:       return value
293:     else
294:       raise ArgumentError, "Argument has to be a boolean."
295:     end
296:   end
Description:Determines the amount of loops a GIF animation should make. A value of 0 means indefinitely looping.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Object
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 588
588:   def loopcount
589:     get OSX::NSBitmapImageRep.getConstNSImageLoopCount
590:   end
Description:Sets the amount of loops for an animation; only for GIF sequneces. A value = 0 means infinite looping.
Precondition:-
Postcondition:value >= 0. loopcount is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | Fixnum >= 0, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 565
565:   def loopcount= value
566:     if value.respond_to? :to_i
567:       v = value.to_i
568:       raise ArgumentError, "'value' has to be greater or equal 0.0" if v < 0
569:       set OSX::NSBitmapImageRep.getConstNSImageLoopCount, v
570:       return value
571:     else
572:       raise ArgumentError, "Can not convert argument. Has to be a float >= 0.0."
573:     end
574:   end
Description:Determines, whether image uses progressive encoding. Only useful with JPEG files.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Boolean if set, else nil
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 544
544:   def progressive
545:     value = get OSX::NSBitmapImageRep.getConstNSImageProgressive
546:     unless value.nil?
547:       value = value == 0.0 ? false : true
548:     end
549:     value
550:   end
Description:Sets progressive format. Only for JPEG.
Precondition:-
Postcondition:progressive is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | bool, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 523
523:   def progressive= value
524:     if value.kind_of?(TrueClass) or value.kind_of?(FalseClass)
525:       set OSX::NSBitmapImageRep.getConstNSImageProgressive, value
526:       return value
527:     else
528:       raise ArgumentError, "Argument has to be a bool."
529:     end
530:   end
Description:Determines the RGB color table. Only useful for GIF.
Precondition:-
Postcondition:-
Exceptions:-
Uses:-
Returns:Object
Parameters:Name | i/o/io | default | Meaning

[Source]

     # File rsil/utils/rsimageproperties.rb, line 352
352:   def rgbcolortable
353:     get OSX::NSBitmapImageRep.getConstNSImageRGBColorTable
354:   end
Description:Sets the RGB color table. Only for GIF.
Precondition:-
Postcondition:rgbcolortable is set irrespectively of its actual value.
Exceptions:ArgumentError
Uses:-
Returns:value if valid
Parameters:Name | i/o/io | default | Meaning
:value | i | - | OSX::NSData, the value to set

[Source]

     # File rsil/utils/rsimageproperties.rb, line 331
331:   def rgbcolortable= value
332:     if value.kind_of?(NSData) or value.kind_of?(OCObject)
333:       set OSX::NSBitmapImageRep.getConstNSImageRGBColorTable, value
334:       return value
335:     else
336:       raise ArgumentError, "Argument has to be a NSData object."
337:     end
338:   end

[Validate]