Skip to content

A png decoder based on DelusionalLogic's but made a lot cleaner and compacted into a single file, designed for CC:T with a saner object system

License

Notifications You must be signed in to change notification settings

9551-Dev/pngLua

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pngLua logo

Png decoder implementation designed to be used in the computercraft minecraft mod. The main goal of this is to refactor and clean up the original library and make it nicer to use.

Usage

To initialize a new png image:

local img = pngImage(<path to image>, custom_stream_data, newRowCallback)

so that would be

local pngImage = require("png")
local img      = pngImage("Example.png")
print(("pixel 1,1 has the colors r:%d g:%d b:%d"):format(img:get_pixel(1,1):unpack()))

You can use custom_stream_data to directly pipe a string of bytes into the decoder like this

local img = pngImage(nil,{input="epic data string"},newRowCallback)

The decoded image provides these fields:

img.width = 0
img.height = 0
img.depth = 0
img.colorType = 0

img:get_pixel(x, y)

Decoding the image is synchronous, and will take a long time for large images.

Support

The supported colortypes are as follows:

  • Grayscale
  • Truecolor
  • Indexed
  • Greyscale/alpha
  • Truecolor/alpha

So far the module only supports 256 Colors in png-8, png-24 as well as png-32 files. and no ancillary chunks.

More than 256 colors might be supported (Bit-depths over 8) as long as they align with whole bytes. These have not been tested.

Multiple IDAT chunks of arbitrary lengths are supported, as well as all filters.

Errors

So far no error-checking has been implemented. No crc32 checks are done.

About

A png decoder based on DelusionalLogic's but made a lot cleaner and compacted into a single file, designed for CC:T with a saner object system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%