Commit c895ffd7 authored by Ryan LeFevre's avatar Ryan LeFevre

Start on channel image parsing

parent 7998c9a7
_ = require 'lodash'
Image = require './image.coffee'
module.exports = class ChannelImage extends Image
constructor: (file, header, @layer) ->
@width = @layer.width
@height = @layer.height
super(file, header)
@channelsInfo = @layer.channelsInfo
@hasMask = _.any @channelsInfo, (c) -> c.id < -1
@opacity = @layer.opacity / 255.0
@maskData = []
skip: ->
for chan in @channelsInfo
@file.seek chan.length, true
channels: -> @layer.channels
parse: ->
@chanPos = 0
for chan in @channelsInfo
if chan.length <= 0
@parseCompression()
continue
@chan = chan
if chan.id < -1
@width = @layer.mask.width
@height = @layer.mask.height
else
@width = @layer.width
@height = @layer.height
@length = @width * @height
start = @file.tell()
@parseImageData()
finish = @file.tell()
if finish isnt start + @chan.length
@file.seek(start + @chan.length)
@width = @layer.width
@height = @layer.height
@processImageData()
......@@ -8,7 +8,7 @@ module.exports = class Layer extends Module
@includes require('./layer/name.coffee')
@includes require('./layer/info.coffee')
@includes require('./layer/helpers.coffee')
# @includes require('./layer/channel_image.coffee')
@includes require('./layer/channel_image.coffee')
constructor: (@file, @header) ->
@mask = {}
......
ChannelImage = require '../channel_image.coffee'
module.exports =
parseChannelImage: ->
image = new ChannelImage(@file, @header, @)
@image = new LazyExecute(image, @file)
.now('skip')
.later('parse')
.get()
......@@ -36,6 +36,8 @@ module.exports = class LayerMask
for i in [0...layerCount]
@layers.push new Layer(@file, @header).parse()
layer.parseChannelImage() for layer in @layers
parseGlobalMask: ->
length = @file.readInt()
return if length <= 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment