Commit 111ea5a8 authored by Ryan LeFevre's avatar Ryan LeFevre

Set default channels based on image mode

parent ee14acb0
...@@ -31,17 +31,15 @@ module.exports = class Image extends Module ...@@ -31,17 +31,15 @@ module.exports = class Image extends Module
@startPos = @file.tell() @startPos = @file.tell()
@endPos = @startPos + @length @endPos = @startPos + @length
@channelsInfo = [ @setChannelsInfo()
{id: 0}
{id: 1}
{id: 2}
]
@channelsInfo.push {id: -1} if @channels() is 4
for attr in ['width', 'height', 'channels', 'depth', 'mode'] then do (attr) => for attr in ['width', 'height', 'channels', 'depth', 'mode'] then do (attr) =>
@::[attr] = -> @header[attr] @::[attr] = -> @header[attr]
setChannelsInfo: ->
switch @mode()
when 3 then @setRgbChannels()
calculateLength: -> calculateLength: ->
@length = switch @depth() @length = switch @depth()
when 1 then (@width() + 7) / 8 * @height() when 1 then (@width() + 7) / 8 * @height()
......
module.exports = module.exports =
setRgbChannels: ->
@channelsInfo = [
{id: 0}
{id: 1}
{id: 2}
]
@channelsInfo.push {id: -1} if @channels() is 4
combineRgbChannel: -> combineRgbChannel: ->
rgbChannels = @channelsInfo rgbChannels = @channelsInfo
.map (ch) -> ch.id .map (ch) -> ch.id
.filter (ch) -> ch >= -1 .filter (ch) -> ch >= -1 # Mask data is -2
for i in [0...@numPixels] for i in [0...@numPixels]
r = g = b = 0 r = g = b = 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