const class gfx::Image
sys::Obj gfx::Image
@Js
@Serializable { simple=true }
Image represents a graphical image.
- dispose
-
Void dispose()
Free any operating system resources used by this image. Dispose is required if this image has been used in an operation such as FWT onPaint which allocated a system resource to represent this instance.
- equals
-
virtual override Bool equals(Obj? that)
Equality is based on uri.
- file
-
const File? file
The file referenced by this image's uri. This field is null if this image represents a buffered image in memory.
- fromStr
-
static new fromStr(Str uri, Bool checked := true)
Convenience for
make(uri.toUri, checked)
. - hash
-
virtual override Int hash()
Return
uri.hash
. - make
-
static new make(Uri uri, Bool checked := true)
Convenience for
makeFile
to create an image which is loaded from the file referenced byUri.get
. - makeFile
-
static new makeFile(File f, Bool checked := true)
Create an image to load from file. If checked is true and the file doesn't exist then throw an exception. If checked is false then return null. The supported file formats are based on the target graphics environment, but typically include PNG, GIF, and JPEG.
Note: since the image is loaded asynchronously upon demand, there is no guarantee that the file actually stores a valid image once this method completes successfully. Completion of this method is based only on file existence.
- makePainted
-
static new makePainted(Size size, |Graphics| f)
Create a new image which is painted by the given function.
Example:
Image.makePainted(Size(100, 100)) |g| { g.brush = Color.green g.fillRect(0, 0, 100, 100) }
- resize
-
Resize this image into a new image. Also see
Graphics.copyImage
. - size
-
Size size()
Get the size of the image or 0,0 if not loaded yet.
- toStr
-
virtual override Str toStr()
Return
uri.toStr
. - uri
-
const Uri uri
The uri which identifies this image. If this image maps to an image file, then this is the file's uri.
- write
-
Void write(MimeType type, OutStream out)
Write this image to the output stream as the given as a mime type. The following mime types are supported:
- image/png
- image/jpeg
- image/gif