spic

package module
v0.0.0-...-f88d22c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

README

spic - small picture

Tools

sview

View spic file.

sview [FILE]

sconv

Utility for converting to and from spic. Default output format is spic. If output file end's with extension, format option isn't necessary. If input and output arguments aren't provided, standard input or output will be used.

sconv [OPTION] [INPUT] [OUTPUT]

  • -d disable dithering
  • -f output format: spic / png / jpg / gif
sedit

Modify spic files. sedit reads commands from stdin. If input file is not provided editing will start with blank picture and default color palette. sedit was ment to be combined with shell scripts.

sedit [OPTION] [INPUT] [OUTPUT]

  • -x enable graphical preview
commands
  • set [x] [y] [i] - set pixel
  • rec [x] [y] [width] [height] - draw rectangle
  • col [i] [0-4095] - set color in palette
  • off - offset colors in palette by 1
example

Following script will create 16 vertical bars:

` #!/bin/sh

x=0

for i in {0..15} do echo "rec $x 0 40 400 $i" ((x+=40)) done `

./script.sh | sedit > image.spic

File structure

File consists three sections.

Section Content
Header 0x83 0x80 0x73 0x67
Palette 16 colors, 12-bit per color
Pixels Pixels defined by color index, compressed by gzip

Width and height are fixed to 640x400.

Palette is list of 16 colors that can be used in image. Colors are 12-bit RGB. 4 bits for each value. There is 4096 colors that can be defined. Colors IDs are same as position in palette.

R    G    B      R    G    B
0xF  0xF  0xF    0x3  0xC  0xA
1111 1111 1111 | 0011 1100 1010 
|-------| |--- - ---| |-------|
  byte       by  te     byte

12 bits for each color 12*16 = 192 bits for palette 192/8 = 24 bytes for palette

Pixel information is stored as consecutive index numbers. This section is compressed by gzip algorithm. One byte store two pixels.

3    15
0011 1111
|-------|
  byte

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SPIC_M  = []byte{0x53, 0x50, 0x49, 0x43}
	Palette = color.Palette{
		NToColor(0x000),
		NToColor(0x800),
		NToColor(0x080),
		NToColor(0x880),
		NToColor(0x008),
		NToColor(0x808),
		NToColor(0x088),
		NToColor(0xccc),
		NToColor(0x888),
		NToColor(0xf00),
		NToColor(0x0f0),
		NToColor(0xff0),
		NToColor(0x00f),
		NToColor(0xf0f),
		NToColor(0x0ff),
		NToColor(0xfff),
	}
)

Functions

func Decode

func Decode(r io.Reader) (image.Image, error)

func DecodeConfig

func DecodeConfig(r io.Reader) (image.Config, error)

func DecodePaletted

func DecodePaletted(r io.Reader) (*image.Paletted, error)

func Encode

func Encode(w io.Writer, src image.Image, enableDi bool) error

func NToColor

func NToColor(val int) color.RGBA

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL