项目作者: hectorm

项目描述 :
索引颜色PNG图像生成器。
高级语言: JavaScript
项目地址: git://github.com/hectorm/pzntg.git
创建时间: 2016-03-30T15:47:38Z
项目社区:https://github.com/hectorm/pzntg

开源协议:MIT License

下载


PZNTG

Indexed color PNG image generator.

Usage

  1. pzntg.create(options) String (base64) | Uint8Array
  • options (object, required).

Supported options:

  • pixels (matrix, required).
  • palette (matrix, required).
  • scale (positive integer, optional, default = 1).
  • asBase64 (boolean, optional, default = true).
  • zliblevel (integer from 0 to 9, optional, default = ZDEFAULT_COMPRESSION).
  • zlibstrategy (integer from 0 to 4, optional, default = ZRLE).
  • zlibmemlevel (integer from 1 to 9, optional, default = 8)_.
  • callback (function, optional).

If callback is not defined, value is returned.

Read this for more information about zlib options.

Example

Octocat

  1. pzntg.create({
  2. pixels: [
  3. [0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0],
  4. [0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0],
  5. [0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
  6. [0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
  7. [0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
  8. [0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
  9. [0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],
  10. [0,0,0,0,0,1,1,1,1,2,2,2,2,1,1,1,2,2,2,2,1,1,1,1,0,0,0,0,0],
  11. [0,0,0,0,0,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,0,0,0,0,0],
  12. [0,0,0,0,0,1,1,2,2,2,4,2,2,2,2,2,2,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0,0,0,0],
  29. [0,0,0,0,0,6,6,6,6,6,6,6,1,6,6,6,1,6,6,6,6,6,6,6,0,0,0,0,0],
  30. [0,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,0,0],
  31. [0,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,0]
  32. ],
  33. palette: [
  34. [0, 0, 0, 0, 0],
  35. [0, 32, 32, 32, 255],
  36. [0,244, 202, 177, 255],
  37. [0,172, 92, 81, 255],
  38. [0,255, 255, 255, 255],
  39. [0,148, 148, 148, 255],
  40. [0,156, 218, 240, 255]
  41. ],
  42. scale: 4
  43. });