Class: JotPDF::Document::ImageContext

Inherits:
Object
  • Object
show all
Defined in:
lib/jot_pdf/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(core, width:, height:) ⇒ ImageContext

Returns a new instance of ImageContext.



245
246
247
248
249
250
251
# File 'lib/jot_pdf/document.rb', line 245

def initialize(core, width:, height:)
  @core = core
  @width = width
  @height = height
  @mask_obj = core.alloc_obj
  @image_obj = core.alloc_obj
end

Instance Attribute Details

#image_objObject (readonly)

Returns the value of attribute image_obj.



243
244
245
# File 'lib/jot_pdf/document.rb', line 243

def image_obj
  @image_obj
end

Instance Method Details

#alpha(&block) ⇒ Object



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/jot_pdf/document.rb', line 253

def alpha(&block)
  @core.dsl do
    alloc_obj => length_obj
    stream_size = nil
    obj(@mask_obj) do
      dict do
        entry("Type").of_name "XObject"
        entry("Subtype").of_name "Image"
        entry("Width").of_num @width
        entry("Height").of_num @height
        entry("ColorSpace").of_name "DeviceGray"
        entry("Decode").of_array { num 0; num 1 }
        entry("BitsPerComponent").of_num 8
        entry("Length").of_ref length_obj
      end
      stream(&block) => stream_size
    end
    obj(length_obj) { num stream_size }
  end
end

#dsl(&block) ⇒ Object



295
296
297
# File 'lib/jot_pdf/document.rb', line 295

def dsl(&block)
  Docile.dsl_eval(self, &block)
end

#rgb(&block) ⇒ Object



274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/jot_pdf/document.rb', line 274

def rgb(&block)
  @core.dsl do
    alloc_obj => length_obj
    stream_size = nil
    obj(@image_obj) do
      dict do
        entry("Type").of_name "XObject"
        entry("Subtype").of_name "Image"
        entry("Width").of_num @width
        entry("Height").of_num @height
        entry("ColorSpace").of_name "DeviceRGB"
        entry("BitsPerComponent").of_num 8
        entry("SMask").of_ref @mask_obj
        entry("Length").of_ref length_obj
      end
      stream(&block) => stream_size
    end
    obj(length_obj) { num stream_size }
  end
end