Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoder #8

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Encoder #8

wants to merge 13 commits into from

Conversation

goto-bus-stop
Copy link
Member

This PR adds a basic SLP file encoder.

const SLPEncoder = require('genie-slp/lib/SLPEncoder')

const encoder = SLPEncoder({
  palette: somePalette,
  comment: 'optional comment', // up to 24 characters
  version: '1.00' // default '1.00', probably shouldn't touch this
})

encoder.addFrame(imageData) // object with `width`, `height`, `data` properties, like a DOM ImageData object
encoder.addFrame(imageData2)

const buffer = encoder.encode()

It doesn't support streaming, because the SLP file header contains pointers to the start of every frame. So, before writing the header at the start of the file, we need to have encoded every frame. One could create a stream from an SLPEncoder object by doing fromBuffer(encoder.encode()) with from2-buffer if they'd like.

TODO:

  • Support player colours
  • _EX commands
  • Outlines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant