► |  | Images

1 | Icons
2 | Logos
3 | Embedding Bitmaps in Compiled Files
4 | Floating-Point Bitmaps

▼ | 4 | Floating-Point Bitmaps

4.1 | Overview
4.2 | Struct Type and Accessors
4.3 | Conversion and Construction
4.4 | Component Operations
4.5 | Pointwise Operations
4.6 | Gradients and Normals
4.7 | Blur
4.8 | Resizing
4.9 | Compositing
4.10 | Spatial Transformations
4.11 | Effects

On this page:

flomap
flomap-size
flomap-ref
flomap-ref*
flomap-bilinear-ref
flomap-bilinear-ref*
flomap-min-value
flomap-max-value
flomap-extreme-values
flomap-nonzero-rect
coords->index
unsafe-flomap-ref
unsafe-flomap-ref*

top ← prev up next →

#### 4.2`` Struct Type and Accessors

> struct (struct flomap (values components width height))
> values : FlVector
> components : Integer
> width : Integer
> height : Integer

Represents a width×height floating-point bitmap with components color components. The values vector contains the flattened image data (see Data Layout).

A guard ensures that the values field has length (* components width height), and that each size field is a nonnegative fixnum.

Examples:

> > (require racket/flonum)
> > (flomap (flvector 0.0 0.0 0.0 0.0) 4 1 1)
> (flomap (flvector 0.0 0.0 0.0 0.0) 4 1 1)
> > (flomap (flvector) 0 0 0)
> (flomap (flvector) 0 0 0)
> > (flomap (flvector 0.0) 2 1 1)
> flomap: expected flvector of length 2; given one of length 1

The default flomap constructor is perhaps the hardest to use. Instead, to construct a flomap from scratch, you should generally use make-flomap, make-flomap*, build-flomap or draw-flomap.

> > procedure
> > (flomap-size fm) |  | → |  |
> > Nonnegative-Fixnum |  | Nonnegative-Fixnum
> fm : flomap

Returns the width and height of fm as nonnegative fixnums.

> procedure (flomap-ref fm k x y) → Float
> fm : flomap
> k : Integer
> x : Integer
> y : Integer

Returns fm’s value at k x y.

If x or y is out of bounds, this function returns 0.0. If k is out of bounds, it raises an error. The Conceptual Model section explains why k is treated differently.

> procedure (flomap-ref* fm x y) → FlVector
> fm : flomap
> x : Integer
> y : Integer

Returns fm’s component values at x y as an flvector.

If x or y is out of bounds, this function returns an flvector filled with 0.0. It always returns an flvector of length (flomap-components fm).

> procedure (flomap-bilinear-ref fm k x y) → Float
> fm : flomap
> k : Integer
> x : Real
> y : Real

Returns an estimated value at any given k x y coordinate, calculated from known values in fm.

Like all other flomap functions that operate on real-valued coordinates, flomap-bilinear-ref regards known values as being at half-integer coordinates. Mathematically, if x = (+ i 0.5) and y = (+ j 0.5) for any integers i and j, then (flomap-bilinear-ref fm k x y) = (flomap-ref fm k i j).

Suppose fm is size w×h. If x ≤ -0.5 or x ≥ (+ w 0.5), this function returns 0.0; similarly for y and h. If k is out of bounds, it raises an error. The Conceptual Model section explains why k is treated differently.

> procedure (flomap-bilinear-ref* fm x y) → FlVector
> fm : flomap
> x : Real
> y : Real

Like flomap-bilinear-ref, but returns an flvector containing estimates of all the components at x y.

> procedure (flomap-min-value fm) → Float
> fm : flomap

> procedure (flomap-max-value fm) → Float
> fm : flomap

These return the minimum and maximum values in fm.

> > procedure
> > (flomap-extreme-values fm) |  | → |  |
> > Float |  | Float
> fm : flomap

Equivalent to (values (flomap-min-value fm) (flomap-max-value fm)), but faster.

> > procedure
> > (flomap-nonzero-rect fm) |  | → |  |
> > Nonnegative-Fixnum
> > Nonnegative-Fixnum
> > Nonnegative-Fixnum
> > Nonnegative-Fixnum
> fm : flomap

Returns the smallest rectangle containing every nonzero value (in any component) in fm. The values returned are x minimum, y minimum, x maximum + 1, and y maximum + 1.

The values returned by flomap-nonzero-rect can be sent to subflomap to trim away zero values. But see flomap-trim, which is faster for alpha-multiplied flomaps.

> procedure (coords->index c w k x y) → Fixnum
> c : Integer
> w : Integer
> k : Integer
> x : Integer
> y : Integer

Returns the index of the value at coordinates k x y of a flomap with c color components and width w. This function does not check any coordinates against their bounds.

> procedure (unsafe-flomap-ref vs c w h k x y) → Float
> vs : FlVector
> c : Integer
> w : Integer
> h : Integer
> k : Integer
> x : Integer
> y : Integer

If fm = (flomap vs c w h), returns fm’s value at k x y. If x or y is out of bounds, this returns 0.0. It is unsafe because k is unchecked, as well as indexing into vs.

This function is used by some library functions, such as flomap-bilinear-ref, to index into already-destructured flomaps. From untyped code, applying this function is likely no faster than applying flomap-ref, because of extra contract checks.

> procedure (unsafe-flomap-ref* vs c w h x y) → FlVector
> vs : FlVector
> c : Integer
> w : Integer
> h : Integer
> x : Integer
> y : Integer

Like unsafe-flomap-ref, but returns an flvector containing all the component values at x y.
top ← prev up next →