2.5.17 image-snip%

► |  | GUI: Racket Graphics Toolkit

1 | Overview
2 | Reference
3 | Configuration
4 | Dynamic Loading
| Bibliography
| Index

► | 2 | Reference

2.1 | Windowing Classes
2.2 | Windowing Functions
2.3 | Drawing Classes
2.4 | Drawing Functions
2.5 | Editor Classes
2.6 | Editor Functions
2.7 | WXME Decoding

▼ | 2.5 | Editor Classes

2.5.1 | add-color<%>
2.5.2 | editor<%>
2.5.3 | editor-admin%
2.5.4 | editor-canvas%
2.5.5 | editor-data%
2.5.6 | editor-data-class%
2.5.7 | editor-data-class-list<%>
2.5.8 | editor-snip-editor-admin<%>
2.5.9 | editor-snip%
2.5.10 | editor-stream-in%
2.5.11 | editor-stream-in-base%
2.5.12 | editor-stream-in-bytes-base%
2.5.13 | editor-stream-out%
2.5.14 | editor-stream-out-base%
2.5.15 | editor-stream-out-bytes-base%
2.5.16 | editor-wordbreak-map%
2.5.17 | image-snip%
2.5.18 | keymap%
2.5.19 | mult-color<%>
2.5.20 | pasteboard%
2.5.21 | readable-snip<%>
2.5.22 | snip%
2.5.23 | snip-admin%
2.5.24 | snip-class%
2.5.25 | snip-class-list<%>
2.5.26 | string-snip%
2.5.27 | style<%>
2.5.28 | style-delta%
2.5.29 | style-list%
2.5.30 | tab-snip%
2.5.31 | text%

On this page:

equal-hash-code
equal-secondary-hash-code
equal-to?
get-bitmap
get-bitmap-mask
get-filename
get-filetype
load-file
other-equal-to?
resize
set-bitmap
set-offset

Inherited methods:
from snip%
adjust-cursor
blink-caret
can-do-edit-operation?
copy
do-edit-operation
draw
find-scroll-step
get-admin
get-count
get-extent
get-flags
get-num-scroll-steps
get-scroll-step-offset
get-snipclass
get-style
get-text
get-text!
is-owned?
match?
merge-with
next
on-char
on-event
own-caret
partial-offset
previous
release-from-owner
set-admin
set-count
set-flags
set-snipclass
set-style
set-unmodified
size-cache-invalid
split
write

top← prev up next →

image-snip% : class?
superclass: snip%

extends: | equal<%>

An image-snip% is a snip that can display bitmap images (usually loaded from a file). When the image file cannot be found, a box containing an “X” is drawn.

( make-object image-snip% | [ | filename |
|  | kind |
|  | relative-path? |
|  | inline?]) |

→ ( is-a?/c image-snip%)
filename : ( or/c path-string? false/c) = #f

kind

:

( one-of/c 'unknown 'unknown/mask
'gif 'gif/mask
'jpeg 'png 'png/mask
'xbm 'xpm 'bmp 'pict)

=

'unknown

relative-path? : any/c = #f
inline? : any/c = #t
( make-object image-snip% bitmap [mask]) → ( is-a?/c image-snip%)
bitmap : ( is-a?/c bitmap%)
mask : ( or/c ( is-a?/c bitmap%) false/c) = #f

Creates an image snip, loading the image filename if specified (see also load-file), or using the given bitmap.

( send an-image-snip equal-hash-code hash-code) → exact-integer?
hash-code : ( any/c . -> . exact-integer?)

Returns an integer that can be used as a equal?-based hash code for an-image-snip (using the same notion of equal? as other-equal-to?).

See also equal<%>.

( send an-image-snip equal-secondary-hash-code hash-code)
→ exact-integer?
hash-code : ( any/c . -> . exact-integer?)

Returns an integer that can be used as a equal?-based secondary hash code for an-image-snip (using the same notion of equal? as other-equal-to?).

See also equal<%>.

( send an-image-snip equal-to? snip equal?) → boolean?
snip : ( is-a?/c image-snip%)
equal? : ( any/c any/c . -> . boolean?)

Calls the other-equal-to? method of snip (to simulate multi-method dispatch) in case snip provides a more specific equivalence comparison.

See also equal<%>.

( send an-image-snip get-bitmap)
→ ( or/c ( is-a?/c bitmap%) false/c)

Returns the bitmap that is displayed by the snip, whether set through set-bitmap or load-file. If no bitmap is displayed, the result is #f.

The returned bitmap cannot be selected into a bitmap-dc% as long as it belongs to the snip, but it can be used as a pen or brush stipple.

( send an-image-snip get-bitmap-mask)
→ ( or/c ( is-a?/c bitmap%) false/c)

Returns the mask bitmap that is used for displaying by the snip, if one was installed with set-bitmap. If no mask is used, the result is #f.

The returned bitmap cannot be selected into a bitmap-dc% as long as it belongs to the snip, but it can be used as a pen or brush stipple.

( send an-image-snip get-filename [relative-path])
→ ( or/c path-string? false/c)
relative-path : ( or/c ( box/c any/c) false/c) = #f

Returns the name of the currently loaded, non-inlined file, or #f if a file is not loaded or if a file was loaded with inlining (the default).

The relative-path box is filled with #t if the loaded file’s path is relative to the owning editor’s path, unless relative-path is #f.

( send an-image-snip get-filetype)

→

( one-of/c 'unknown 'unknwon/mask
'gif 'gif/mask
'jpeg 'png 'png/mask 'xbm 'xpm 'bmp 'pict)

Returns the kind used to load the currently loaded, non-inlined file, or 'unknown if a file is not loaded or if a file was loaded with inlining (the default).

( send an-image-snip load-file |  | filename |  |  |  |
| [ | kind |  |  |  |
|  | relative-path? |  |  |  |
|  | inline?]) |  | → |  | void?

filename : ( or/c path-string? false/c)

kind

:

( one-of/c 'unknown 'unknown/mask
'gif 'gif/mask
'jpeg 'png 'png/mask
'xbm 'xpm 'bmp 'pict)

=

'unknown

relative-path? : any/c = #f
inline? : any/c = #t

Loads the file by passing filename and kind to load-file If a bitmap had previously been specified with set-bitmap, that bitmap (and mask) will no longer be used. If filename is #f, then the current image is cleared.

When 'unknown/mask, 'gif/mask, or 'png/mask is specified and the loaded bitmap object includes a mask (see get-loaded-mask), the mask is used for drawing the bitmap (see draw-bitmap).

If relative-path? is not #f and filename is a relative path, then the file will be read using the path of the owning editor’s filename. If the image is not inlined, it will be saved as a relative pathname.

If inline? is not #f, the image data will be saved directly to the file or clipboard when the image is saved or copied (preserving the bitmap’s mask, if any). The source filename and kind is no longer relevant.

( send an-image-snip other-equal-to? |  | snip |  |  |  |
|  | equal?) |  | → |  | boolean?

snip : ( is-a?/c image-snip%)
equal? : ( any/c any/c . -> . boolean?)

Returns #t if an-image-snip and snip both have bitmaps and the bitmaps are the same dimensions. If either has a mask bitmap with the same dimensions as the main bitmap, then the masks must be the same (or if only one mask is present, it must correspond to a solid mask).

The given equal? function (for recursive comparisons) is not used.

( send an-image-snip resize w h) → boolean?
w : ( and/c real? ( not/c negative?))
h : ( and/c real? ( not/c negative?))

Overrides resize in snip%.
The bitmap will be cropped to fit in the given dimensions.

( send an-image-snip set-bitmap bm [mask]) → void?
bm : ( is-a?/c bitmap%)
mask : ( or/c ( is-a?/c bitmap%) false/c) = #f

Sets the bitmap that is displayed by the snip. This method also accepts an optional mask to be used when drawing the bitmap (see draw-bitmap), but supplying the mask directly is now deprecated. Instead, if no mask is supplied but the bitmap’s get-loaded-mask method produces a bitmap of the same dimensions, it is used as the mask. Furthermore, such a mask is saved with the snip when it is saved to a file or copied (whereas a directly supplied mask is not saved).

The supplied bitmap must not be selected into a bitmap-dc% object, otherwise an exn:fail:contract exception is raised, and it cannot be selected into a bitmap-dc% as long as it belongs to the snip, but it can be used as a pen or brush stipple.

( send an-image-snip set-offset dx dy) → void?
dx : real?
dy : real?

Sets a graphical offset for the bitmap within the image snip.
top← prev up next →