The cl-netpbm Reference Manual

This is the cl-netpbm Reference Manual, version 1.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 15:30:05 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 cl-netpbm

Common Lisp support for reading/writing the netpbm image formats (PPM, PGM, and PBM).

Author

Steve Losh <>

Home Page

https://docs.stevelosh.com/cl-netpbm/

License

MIT/X11

Version

1.0.0

Source

cl-netpbm.asd.

Child Components

3 Modules

Modules are listed depth-first from the system components tree.


3.1 cl-netpbm/vendor

Source

cl-netpbm.asd.

Parent Component

cl-netpbm (system).

Child Components

3.2 cl-netpbm/src

Dependency

package.lisp (file).

Source

cl-netpbm.asd.

Parent Component

cl-netpbm (system).

Child Component

main.lisp (file).


4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


4.1 Lisp


4.1.1 cl-netpbm/cl-netpbm.asd

Source

cl-netpbm.asd.

Parent Component

cl-netpbm (system).

ASDF Systems

cl-netpbm.


4.1.2 cl-netpbm/vendor/quickutils-package.lisp

Source

cl-netpbm.asd.

Parent Component

vendor (module).

Packages

netpbm.quickutils.

Internals

*utilities* (special variable).


4.1.3 cl-netpbm/vendor/quickutils.lisp

Dependency

quickutils-package.lisp (file).

Source

cl-netpbm.asd.

Parent Component

vendor (module).

Public Interface
Internals

4.1.4 cl-netpbm/package.lisp

Dependency

vendor (module).

Source

cl-netpbm.asd.

Parent Component

cl-netpbm (system).

Packages

netpbm.


4.1.5 cl-netpbm/src/main.lisp

Source

cl-netpbm.asd.

Parent Component

src (module).

Public Interface
Internals

5 Packages

Packages are listed by definition order.


5.1 netpbm

Source

package.lisp.

Use List
Public Interface
Internals

5.2 netpbm.quickutils

Package that contains Quickutil utility functions.

Source

quickutils-package.lisp.

Use List

common-lisp.

Used By List

netpbm.

Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


6.1 Public Interface


6.1.1 Macros

Macro: with-gensyms (names &body forms)

Binds each variable named by a symbol in ‘names‘ to a unique symbol around ‘forms‘. Each of ‘names‘ must either be either a symbol, or of the form:

(symbol string-designator)

Bare symbols appearing in ‘names‘ are equivalent to:

(symbol symbol)

The string-designator is used as the argument to ‘gensym‘ when constructing the unique symbol the named variable will be bound to.

Package

netpbm.quickutils.

Source

quickutils.lisp.

Macro: with-unique-names (names &body forms)

Binds each variable named by a symbol in ‘names‘ to a unique symbol around ‘forms‘. Each of ‘names‘ must either be either a symbol, or of the form:

(symbol string-designator)

Bare symbols appearing in ‘names‘ are equivalent to:

(symbol symbol)

The string-designator is used as the argument to ‘gensym‘ when constructing the unique symbol the named variable will be bound to.

Package

netpbm.quickutils.

Source

quickutils.lisp.


6.1.2 Compiler macros

Compiler Macro: curry (function &rest arguments)
Package

netpbm.quickutils.

Source

quickutils.lisp.


6.1.3 Ordinary functions

Function: curry (function &rest arguments)

Returns a function that applies ‘arguments‘ and the arguments it is called with to ‘function‘.

Package

netpbm.quickutils.

Source

quickutils.lisp.

Function: read-from-file (path)

Read a PPM image file from ‘path‘, returning an array of pixels and more.

The primary return value will be a 2D array with dimensions ‘(width height)‘. Each element of the array will be a single pixel whose type depends on the image file format:

* PBM: ‘bit‘
* PGM: ‘(integer 0 maximum-value)‘
* PPM: ‘(simple-array (integer 0 maximum-value) (3))‘

Two other values are returned:

* The format of the image that was read (one of ‘:pbm‘, ‘:pgm‘, ‘:ppm‘). * The bit depth of the image.

Package

netpbm.

Source

main.lisp.

Function: read-from-stream (stream)

Read a PPM image file from ‘stream‘, returning an array of pixels and more.

‘stream‘ must be a binary input stream, specifically of ‘(unsigned-byte 8)‘s unless you *really* know what you’re doing.

The primary return value will be a 2D array with dimensions ‘(width height)‘. Each element of the array will be a single pixel whose type depends on the image file format:

* PBM: ‘bit‘
* PGM: ‘(integer 0 maximum-value)‘
* PPM: ‘(simple-array (integer 0 maximum-value) (3))‘

Two other values are returned:

* The format of the image that was read (one of ‘:pbm‘, ‘:pgm‘, ‘:ppm‘). * The bit depth of the image.

Package

netpbm.

Source

main.lisp.

Function: read-texture-from-file (path)

Read a PPM image file from ‘path‘, returning an OpenGL-style array and more.

The primary return value will be an OpenGL-style array of type:

(simple-array (single-float 0.0 1.0) (* width height 3))

The vertical axis of the image will be flipped, which is what OpenGL expects.

Three values are returned: the array, the width, and the height.

Package

netpbm.

Source

main.lisp.

Function: read-texture-from-stream (stream)

Read a PPM image file from ‘stream‘, returning an OpenGL-style array and more.

‘stream‘ must be a binary input stream, specifically of ‘(unsigned-byte 8)‘s unless you *really* know what you’re doing. The stream must contain a PPM formatted image — PBM and PGM images are not supported.

The primary return value will be an OpenGL-style array of type:

(simple-array (single-float 0.0 1.0) (* width height 3))

The vertical axis of the image will be flipped, which is what OpenGL expects.

Three values are returned: the array, the width, and the height.

Package

netpbm.

Source

main.lisp.

Function: symb (&rest args)

Receives any number of objects, concatenates all into one string with ‘#’mkstr‘ and converts them to symbol.

Extracted from _On Lisp_, chapter 4.

See also: ‘symbolicate‘

Package

netpbm.quickutils.

Source

quickutils.lisp.

Function: transpose (lists)

Analog to matrix transpose for a list of lists given by ‘lists‘.

Package

netpbm.quickutils.

Source

quickutils.lisp.

Function: write-to-file (path data &key if-exists format encoding maximum-value)

Write a PPM image array ‘data‘ to a file at ‘path‘.

Nothing is returned.

‘format‘ must be one of ‘:pbm‘, ‘:pgm‘, ‘:ppm‘.

‘encoding‘ must be one of ‘:binary‘, ‘:ascii‘.

‘maximum-value‘ must be the desired bit depth of the image (the maximum value any particular pixel can have). For PBM images it must be ‘1‘.

For PBM and PGM images, ‘data‘ must be a two dimensional array of integers between ‘0‘ and ‘maximum-value‘ inclusive.

For PPM images, ‘data‘ must be a two dimensional array of pixels, each of which must be a 3 element vector of integers between ‘0‘ and ‘maximum-value‘ inclusive.

Package

netpbm.

Source

main.lisp.

Function: write-to-stream (stream data &key format encoding maximum-value)

Write a PPM image array ‘data‘ to ‘stream‘.

Nothing is returned.

‘stream‘ must be a binary output stream, specifically of ‘(unsigned-byte 8)‘s unless you *really* know what you’re doing.

‘format‘ must be one of ‘:pbm‘, ‘:pgm‘, ‘:ppm‘.

‘encoding‘ must be one of ‘:binary‘, ‘:ascii‘.

‘maximum-value‘ must be the desired bit depth of the image (the maximum value any particular pixel can have). For PBM images it must be ‘1‘.

For PBM and PGM images, ‘data‘ must be a two dimensional array of integers between ‘0‘ and ‘maximum-value‘ inclusive.

For PPM images, ‘data‘ must be a two dimensional array of pixels, each of which must be a 3 element vector of integers between ‘0‘ and ‘maximum-value‘ inclusive.

Package

netpbm.

Source

main.lisp.


6.2 Internals


6.2.1 Constants

Constant: +carriage-return+
Package

netpbm.

Source

main.lisp.

Constant: +comment-char+
Package

netpbm.

Source

main.lisp.

Constant: +form-feed+
Package

netpbm.

Source

main.lisp.

Constant: +line-feed+
Package

netpbm.

Source

main.lisp.

Constant: +space+
Package

netpbm.

Source

main.lisp.

Constant: +tab+
Package

netpbm.

Source

main.lisp.

Constant: +vertical-tab+
Package

netpbm.

Source

main.lisp.


6.2.2 Special variables

Special Variable: *utilities*
Package

netpbm.quickutils.

Source

quickutils-package.lisp.


6.2.3 Macros

Macro: check-number (place maximum-value)
Package

netpbm.

Source

main.lisp.


6.2.4 Ordinary functions

Function: bits (byte)
Package

netpbm.

Source

main.lisp.

Function: byte-to-digit (byte)
Package

netpbm.

Source

main.lisp.

Function: copy-peekable-stream (instance)
Package

netpbm.

Source

main.lisp.

Function: ensure-function (function-designator)

Returns the function designated by ‘function-designator‘:
if ‘function-designator‘ is a function, it is returned, otherwise it must be a function name and its ‘fdefinition‘ is returned.

Package

netpbm.quickutils.

Source

quickutils.lisp.

Function: error-junk (section byte)
Package

netpbm.

Source

main.lisp.

Function: file-format (magic-byte)

Return ‘(values format binary?)‘ for the given magic byte character.

Package

netpbm.

Source

main.lisp.

Function: format-to-stream (stream &rest format-args)
Package

netpbm.

Source

main.lisp.

Function: line-terminator-p (byte)
Package

netpbm.

Source

main.lisp.

Function: magic-byte (file-format binary?)

Return the magic byte character to use for the given format/encoding combination.

Package

netpbm.

Source

main.lisp.

Function: make-color (r g b)
Package

netpbm.

Source

main.lisp.

Function: make-gensym-list (length &optional x)

Returns a list of ‘length‘ gensyms, each generated as if with a call to ‘make-gensym‘, using the second (optional, defaulting to ‘"G"‘) argument.

Package

netpbm.quickutils.

Source

quickutils.lisp.

Function: make-peekable-stream (s)
Package

netpbm.

Source

main.lisp.

Function: mkstr (&rest args)

Receives any number of objects (string, symbol, keyword, char, number), extracts all printed representations, and concatenates them all into one string.

Extracted from _On Lisp_, chapter 4.

Package

netpbm.quickutils.

Source

quickutils.lisp.

Reader: p (instance)
Writer: (setf p) (instance)
Package

netpbm.

Source

main.lisp.

Target Slot

p.

Function: peek-byte (stream)
Package

netpbm.

Source

main.lisp.

Function: peekable-stream-p (object)
Package

netpbm.

Source

main.lisp.

Function: pixel-type (format bit-depth)

Return the type specifier for a pixel of an image with the given ‘format‘ and ‘bit-depth‘.

Package

netpbm.

Source

main.lisp.

Function: read-bitmap-ascii (stream)
Package

netpbm.

Source

main.lisp.

Function: read-bitmap-binary (stream)
Package

netpbm.

Source

main.lisp.

Function: read-byte (stream &optional eof-error-p)
Package

netpbm.

Source

main.lisp.

Function: read-graymap (stream binary?)
Package

netpbm.

Source

main.lisp.

Function: read-header-number (stream)

Read the next ASCII-encoded number from ‘stream‘ (allows comments).

Package

netpbm.

Source

main.lisp.

Function: read-magic-byte (stream)

Read the initial ‘P#‘ from ‘stream‘, returning the magic ‘#‘ character.

Package

netpbm.

Source

main.lisp.

Function: read-netpbm (stream format binary? texture?)
Package

netpbm.

Source

main.lisp.

Function: read-pixmap (stream binary?)
Package

netpbm.

Source

main.lisp.

Function: read-raster-number (stream)

Read the next ASCII-encoded number from ‘stream‘ (does not allow comments).

Package

netpbm.

Source

main.lisp.

Function: read-texture (stream binary?)
Package

netpbm.

Source

main.lisp.

Reader: s (instance)
Writer: (setf s) (instance)
Package

netpbm.

Source

main.lisp.

Target Slot

s.

Function: skip-comment-body (stream)
Package

netpbm.

Source

main.lisp.

Function: skip-whitespace (stream)
Package

netpbm.

Source

main.lisp.

Function: unread-byte (stream byte)
Package

netpbm.

Source

main.lisp.

Function: white-space-p (byte)
Package

netpbm.

Source

main.lisp.

Function: write-bitmap-ascii (data stream)
Package

netpbm.

Source

main.lisp.

Function: write-bitmap-binary (data stream)
Package

netpbm.

Source

main.lisp.

Function: write-graymap (data stream binary? maximum-value)
Package

netpbm.

Source

main.lisp.

Function: write-line-feed (stream)
Package

netpbm.

Source

main.lisp.

Function: write-netpbm (data stream format binary? maximum-value)
Package

netpbm.

Source

main.lisp.

Function: write-number-ascii (value stream maximum-value)

Write ‘value‘ to stream as an ASCII-encoded number, with sanity check.

Package

netpbm.

Source

main.lisp.

Function: write-number-binary (value stream maximum-value)

Write ‘value‘ to ‘stream‘ as a binary value, with sanity check.

Package

netpbm.

Source

main.lisp.

Function: write-pixmap (data stream binary? maximum-value)
Package

netpbm.

Source

main.lisp.

Function: write-string-as-bytes (string stream)
Package

netpbm.

Source

main.lisp.


6.2.5 Structures

Structure: peekable-stream
Package

netpbm.

Source

main.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: p
Type

(or null (unsigned-byte 8))

Readers

p.

Writers

(setf p).

Slot: s
Type

stream

Initform

(error "required")

Readers

s.

Writers

(setf s).


6.2.6 Types

Type: string-designator ()

A string designator type. A string designator is either a string, a symbol, or a character.

Package

netpbm.quickutils.

Source

quickutils.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
B   C   E   F   L   M   P   R   S   T   U   W  
Index Entry  Section

(
(setf p): Private ordinary functions
(setf s): Private ordinary functions

B
bits: Private ordinary functions
byte-to-digit: Private ordinary functions

C
check-number: Private macros
Compiler Macro, curry: Public compiler macros
copy-peekable-stream: Private ordinary functions
curry: Public compiler macros
curry: Public ordinary functions

E
ensure-function: Private ordinary functions
error-junk: Private ordinary functions

F
file-format: Private ordinary functions
format-to-stream: Private ordinary functions
Function, (setf p): Private ordinary functions
Function, (setf s): Private ordinary functions
Function, bits: Private ordinary functions
Function, byte-to-digit: Private ordinary functions
Function, copy-peekable-stream: Private ordinary functions
Function, curry: Public ordinary functions
Function, ensure-function: Private ordinary functions
Function, error-junk: Private ordinary functions
Function, file-format: Private ordinary functions
Function, format-to-stream: Private ordinary functions
Function, line-terminator-p: Private ordinary functions
Function, magic-byte: Private ordinary functions
Function, make-color: Private ordinary functions
Function, make-gensym-list: Private ordinary functions
Function, make-peekable-stream: Private ordinary functions
Function, mkstr: Private ordinary functions
Function, p: Private ordinary functions
Function, peek-byte: Private ordinary functions
Function, peekable-stream-p: Private ordinary functions
Function, pixel-type: Private ordinary functions
Function, read-bitmap-ascii: Private ordinary functions
Function, read-bitmap-binary: Private ordinary functions
Function, read-byte: Private ordinary functions
Function, read-from-file: Public ordinary functions
Function, read-from-stream: Public ordinary functions
Function, read-graymap: Private ordinary functions
Function, read-header-number: Private ordinary functions
Function, read-magic-byte: Private ordinary functions
Function, read-netpbm: Private ordinary functions
Function, read-pixmap: Private ordinary functions
Function, read-raster-number: Private ordinary functions
Function, read-texture: Private ordinary functions
Function, read-texture-from-file: Public ordinary functions
Function, read-texture-from-stream: Public ordinary functions
Function, s: Private ordinary functions
Function, skip-comment-body: Private ordinary functions
Function, skip-whitespace: Private ordinary functions
Function, symb: Public ordinary functions
Function, transpose: Public ordinary functions
Function, unread-byte: Private ordinary functions
Function, white-space-p: Private ordinary functions
Function, write-bitmap-ascii: Private ordinary functions
Function, write-bitmap-binary: Private ordinary functions
Function, write-graymap: Private ordinary functions
Function, write-line-feed: Private ordinary functions
Function, write-netpbm: Private ordinary functions
Function, write-number-ascii: Private ordinary functions
Function, write-number-binary: Private ordinary functions
Function, write-pixmap: Private ordinary functions
Function, write-string-as-bytes: Private ordinary functions
Function, write-to-file: Public ordinary functions
Function, write-to-stream: Public ordinary functions

L
line-terminator-p: Private ordinary functions

M
Macro, check-number: Private macros
Macro, with-gensyms: Public macros
Macro, with-unique-names: Public macros
magic-byte: Private ordinary functions
make-color: Private ordinary functions
make-gensym-list: Private ordinary functions
make-peekable-stream: Private ordinary functions
mkstr: Private ordinary functions

P
p: Private ordinary functions
peek-byte: Private ordinary functions
peekable-stream-p: Private ordinary functions
pixel-type: Private ordinary functions

R
read-bitmap-ascii: Private ordinary functions
read-bitmap-binary: Private ordinary functions
read-byte: Private ordinary functions
read-from-file: Public ordinary functions
read-from-stream: Public ordinary functions
read-graymap: Private ordinary functions
read-header-number: Private ordinary functions
read-magic-byte: Private ordinary functions
read-netpbm: Private ordinary functions
read-pixmap: Private ordinary functions
read-raster-number: Private ordinary functions
read-texture: Private ordinary functions
read-texture-from-file: Public ordinary functions
read-texture-from-stream: Public ordinary functions

S
s: Private ordinary functions
skip-comment-body: Private ordinary functions
skip-whitespace: Private ordinary functions
symb: Public ordinary functions

T
transpose: Public ordinary functions

U
unread-byte: Private ordinary functions

W
white-space-p: Private ordinary functions
with-gensyms: Public macros
with-unique-names: Public macros
write-bitmap-ascii: Private ordinary functions
write-bitmap-binary: Private ordinary functions
write-graymap: Private ordinary functions
write-line-feed: Private ordinary functions
write-netpbm: Private ordinary functions
write-number-ascii: Private ordinary functions
write-number-binary: Private ordinary functions
write-pixmap: Private ordinary functions
write-string-as-bytes: Private ordinary functions
write-to-file: Public ordinary functions
write-to-stream: Public ordinary functions