Class: Pdfrb::Color::ICCProfile
- Inherits:
-
Object
- Object
- Pdfrb::Color::ICCProfile
- Defined in:
- lib/pdfrb/color/icc_profile.rb
Overview
ICC profile stream model. An ICCBased color space is a
[/ICCBased
This class parses the ICC header to extract metadata (version, device class, color space, component count) and builds the PDF stream dictionary.
ICC spec: ISO 15076-1 / ICC.1:2010. PDF integration: ISO 32000-2 ยง8.6.5.5.
Constant Summary collapse
- HEADER_SIZE =
128- SIGNATURE_OFFSET =
36
Instance Attribute Summary collapse
-
#alternate ⇒ Object
readonly
Returns the value of attribute alternate.
-
#color_space ⇒ Object
readonly
Returns the value of attribute color_space.
-
#component_count ⇒ Object
readonly
Returns the value of attribute component_count.
-
#device_class ⇒ Object
readonly
Returns the value of attribute device_class.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(raw_data, alternate: nil) ⇒ ICCProfile
constructor
A new instance of ICCProfile.
- #pdf_color_space_array ⇒ Object
- #stream_dictionary_fields ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(raw_data, alternate: nil) ⇒ ICCProfile
Returns a new instance of ICCProfile.
22 23 24 25 26 |
# File 'lib/pdfrb/color/icc_profile.rb', line 22 def initialize(raw_data, alternate: nil) @raw_data = raw_data.b parse_header @alternate = alternate || derive_alternate end |
Instance Attribute Details
#alternate ⇒ Object (readonly)
Returns the value of attribute alternate.
19 20 21 |
# File 'lib/pdfrb/color/icc_profile.rb', line 19 def alternate @alternate end |
#color_space ⇒ Object (readonly)
Returns the value of attribute color_space.
19 20 21 |
# File 'lib/pdfrb/color/icc_profile.rb', line 19 def color_space @color_space end |
#component_count ⇒ Object (readonly)
Returns the value of attribute component_count.
19 20 21 |
# File 'lib/pdfrb/color/icc_profile.rb', line 19 def component_count @component_count end |
#device_class ⇒ Object (readonly)
Returns the value of attribute device_class.
19 20 21 |
# File 'lib/pdfrb/color/icc_profile.rb', line 19 def device_class @device_class end |
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
19 20 21 |
# File 'lib/pdfrb/color/icc_profile.rb', line 19 def raw_data @raw_data end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
19 20 21 |
# File 'lib/pdfrb/color/icc_profile.rb', line 19 def version @version end |
Class Method Details
.read(path) ⇒ Object
28 29 30 |
# File 'lib/pdfrb/color/icc_profile.rb', line 28 def self.read(path) new(File.binread(path)) end |
Instance Method Details
#pdf_color_space_array ⇒ Object
32 33 34 |
# File 'lib/pdfrb/color/icc_profile.rb', line 32 def pdf_color_space_array [:ICCBased, :__icc_stream_ref__] end |
#stream_dictionary_fields ⇒ Object
36 37 38 39 40 41 |
# File 'lib/pdfrb/color/icc_profile.rb', line 36 def stream_dictionary_fields { N: @component_count, Alternate: @alternate, }.freeze end |
#valid? ⇒ Boolean
43 44 45 |
# File 'lib/pdfrb/color/icc_profile.rb', line 43 def valid? @raw_data.bytesize >= HEADER_SIZE && signature_valid? end |