16 Image Core

▼ |  | Mr Lib: Extra GUI Libraries

1 | Aligned Pasteboard
2 | Arrow Toggle Snip
3 | Bitmap Label
4 | Cache-image Snip
5 | Close Icon
6 | Expandable Snip
7 | GIF and Animated GIF Writing
8 | Graphs
9 | Hierarchical List Control
10 | Include Bitmap
11 | Interactive Value Port
12 | Name Message
13 | Path Dialog
14 | Plot
15 | Switchable Button
16 | Image Core
17 | Matrix Snip
18 | Snip Canvases
19 | Syntax Browser
20 | Te X Table
21 | Terminal Window
22 | White on Black Panel Predicate
23 | Acknowledgments
| Index

On this page:

render-image
image?
un/ cache-image
compute-image-cache
definitely-same-image?
snip-class

Racket
top contents ← prev up next →

## 16 Image Core🔗ℹ

(require mrlib/image-core) | package: gui-lib

This library is the core part of the 2htdp/image library that DrRacket links into the namespace of all languages that it runs. This ensures that minimal support for these images are the same in all languages, specifically including support for printing the images and constructing the core data structures making up an image.

> procedure (render-image image dc dx dy) → void?
> image : image?
> dc : (is-a?/c dc<%>)
> dx : real?
> dy : real?

Draws image in dc at the position (dx,dy).

> procedure (image? v) → boolean?
> v : any/c

Recognizes the images that library handles.

> procedure (un/cache-image image b) → image?
> image : image?
> b : any/c

Returns an image that either caches its drawing in the snip draw method or doesn’t, depending on b.

Not all image? values have special caching capabilities; in those cases, this returns a copy of the value if it is a snip%; otherwise it returns the value itself (if it isn’t a snip%).

> procedure (compute-image-cache image) → void?
> image : image?

When the image has a bitmap-cache (which it does by default, although un/cache-image can disable it), this function fills in the bitmap, doing the work to draw image into the bitmap.

Ordinarily, the image’s bitmap cache is computed the first time the image is actually rendered.

> procedure (definitely-same-image? i1 i2) → boolean?
> i1 : image?
> i2 : image?

Returns #t if i1 and i2 draw identically and #f if they may draw the same or may draw differently.

This test is intended to be cheaper than a full equality comparison. It is also used by the implementation of equal? on images to short-circuit the full check. (The full check draws the two images and then compares the resulting bitmaps.)

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

The snipclass used by images (which are snip%s) created by this library.

Not all image? values are snip%s, but those that are use this as their snip-class%.

top contents ← prev up next →