1 Aligned Pasteboard
2 Bitmap Label
3 Cache-image Snip
4 GIF and Animated GFI Writing
5 Graphs
6 Hierarchical List Control
7 Include Bitmap
8 Interactive Value Port
9 Name Message
10 Path Dialog
11 Plot
12 Switchable Button
13 Acknowledgments
Index
On this page:
cache-image-snip%
get-argb
get-argb-proc
get-argb/ no-compute
get-bitmap
get-dc-proc
get-pinhole
get-size
snip-class
make-argb
argb-vector
argb-width
argb?
overlay-bitmap
build-bitmap
flatten-bitmap
argb->cache-image-snip
argb->bitmap
Version: 4.0.2

 

3 Cache-image Snip

 (require mrlib/cache-image-snip)

The mrlib/cache-image-snip library provides the core data structure for DrScheme’s "image.ss" teachpack. Images in the "image.ss" teachpack are instances of the cache-image-snip% class.

The library also defines a new type, argb, that represents a bitmap, but with alpha values. It has a maker, two selectors, and a predicate.

cache-image-snip% : class?

  superclass: snip%

(send a-cache-image-snip get-argb)  argb?

Returns a pixel array for this image, forcing it to be computed.

(send a-cache-image-snip get-argb-proc)

  (argb? exact-integer? exact-integer? . -> . void?)

Returns a procedure that fills in an argb with the contents of this image at the given offset

(send a-cache-image-snip get-argb/no-compute)

  (or/c false/c argb?)

Returns a pixel array for this image or #f if it has not been computed yet.

(send a-cache-image-snip get-bitmap)  (is-a?/c bitmap%)

Builds (if not yet built) a bitmap corresponding to this snip and returns it.

(send a-cache-image-snip get-dc-proc)

  (or/c false/c ((is-a?/c dc<%>) real? real? -> void?))

Either returns false, or a procedure that draws the contents of this snip into a dc.

(send a-cache-image-snip get-pinhole)

 

 

real?

 

real?

Returns the pinhole coordinates for this image, counting from the top-left of the image.

(send a-cache-image-snip get-size)

 

 

exact-nonnegative-integer?

exact-nonnegative-integer?

Returns the width and height for the image.

snip-class : (is-a?/c snip-class%)

This snipclass is used for saved cache image snips.

(make-argb vectorof width)  argb?

  vectorof : (integer-in 0 255)

  width : exact-nonnegative-integer?

Constructs a new argb value. The vector has four entries for each pixel, an alpha, red, green, and blue value. The int specifies the width of the image; the height is the size of the vector, divided by 4, divided by the width.

(argb-vector argb)  (vectorof (integer-in 0 255))

  argb : argb?

Extracts the vector from argb.

(argb-width argb)  exact-nonnegative-integer?

  argb : argb?

Extracts the width from argb.

(argb? v)  boolean?

  v : any/c

Returns #t if v is an argb, #f otherwise.

(overlay-bitmap dest dx dy img mask)  void?

  dest : argb?

  dx : exact-integer?

  dy : exact-integer?

  img : (is-a?/c bitmap%)

  mask : (is-a?/c bitmap%)

Changes argb, overlaying img with masking based on mask at (dx, dy) from the top-left.

(build-bitmap draw width height)  (is-a?/c bitmap%)

  draw : ((is-a?/c dc<%>) . -> . any)

  width : (integer-in 1 10000)

  height : (integer-in 1 10000)

Builds a bitmap of size width by height, using the procedure draw to render the bitmap content into the given dc<%>.

(flatten-bitmap bitmap)  (is-a?/c bitmap%)

  bitmap : (is-a?/c bitmap%)

Builds a new bitmap that flattens the original bitmap with its mask (as determined by get-loaded-mask in bitmap%), producing a bitmap that has no mask, and looks the way that bitmap would draw (when drawn with the mask) onto a white background.

(argb->cache-image-snip argb dx dy)  (is-a?/c cache-image-snip%)

  argb : argb?

  dx : real?

  dy : real?

Builds a new cache-image-snip% based on the contents of argb, using dx and dy as the pinhole.

(argb->bitmap argb)  (is-a?/c bitmap%)

  argb : argb?

Builds a bitmap that draws the same way as argb; the alpha pixels are put into the bitmap’s get-loaded-mask bitmap.