Commit a2cae2d8 authored by Ryan LeFevre's avatar Ryan LeFevre

Add greyscale image exporting

parent 111ea5a8
.DS_Store .DS_Store
node_modules node_modules
index.html index.html
output.png
...@@ -8,6 +8,7 @@ module.exports = class Image extends Module ...@@ -8,6 +8,7 @@ module.exports = class Image extends Module
@includes ImageFormat.RAW @includes ImageFormat.RAW
@includes ImageFormat.RLE @includes ImageFormat.RLE
@includes ImageMode.RGB @includes ImageMode.RGB
@includes ImageMode.Greyscale
@includes Export.PNG @includes Export.PNG
COMPRESSIONS = [ COMPRESSIONS = [
...@@ -38,6 +39,7 @@ module.exports = class Image extends Module ...@@ -38,6 +39,7 @@ module.exports = class Image extends Module
setChannelsInfo: -> setChannelsInfo: ->
switch @mode() switch @mode()
when 1 then @setGreyscaleChannels()
when 3 then @setRgbChannels() when 3 then @setRgbChannels()
calculateLength: -> calculateLength: ->
......
module.exports = module.exports =
RGB: require('./image_modes/rgb.coffee') RGB: require('./image_modes/rgb.coffee')
\ No newline at end of file Greyscale: require('./image_modes/greyscale.coffee')
module.exports =
setGreyscaleChannels: ->
@channelsInfo = [{id: 0}]
@channelsInfo.push {id: -1} if @channels() is 2
combineGreyscaleChannel: ->
for i in [0...@numPixels]
grey = @channelData[i]
alpha = if @channels() is 2
@channelData[@channelLength + i]
else
255
@pixelData.push grey, grey, grey, alpha
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