HTTPS SSH

PCX.go

PCX Image Encoder / Decoder for Go-Language.

Usage

Decoding from PCX

package main

import "image"
import "log"
import "os"
import _ "bitbucket.org/chiku2gonzalez/pcx.go"

func main() {
    if file, err := os.Open("input.pcx"); err != nil {
        log.Println(err)
    } else {
        defer func() {
            file.Close()
        }()
        if img, _, err := image.Decode(file); err != nil {
            log.Println(err)
        } else {
            // Do something...
        }
    }
}

Encoding to PCX

package main

import "image"
import "log"
import "os"
import "bitbucket.org/chiku2gonzalez/pcx.go"

func main() {
    img := image.NewRGBA(image.Rect(0, 0, 256, 256))
    // Do something...

    if file, err := os.Create("output.pcx"); err != nil {
        log.Println(err)
    } else {
        defer func() {
            file.Close()
        }()

        if err := pcx.Encode(file, img); err != nil {
            log.Println(err)
        }

    }
}

Limitations

  • Supports only 8-BIT PCX.
    • 8-BIT Grayscale
    • 8-BIT Paletted
    • 3 x 8-BIT (24-BIT) RGB
    • 4 x 8-BIT (32-BIT) RGBx (Decoding only)
  • Encode to 3.0 PCX only.
  • Encode to non-compressed PCX is not implemented.

License

MIT License

Author

TANAKA Kenichi a.k.a chikuchikugonzalez