Import std.image.image
std.image.image
Image: a picture's pixels, in rows from the top, each RGBA, 8 bits a channel, its alpha
straight, in a Buffer<UInt8>, which C code can read and write through its Pointer, and which
the formats' Decodes give and their Encodes take. Image.Decode reads any format std.image
knows, by how its bytes start, but HDR's, whose pixels are an HdrImage's, and Image.Load a file
of one. Its transforms, Resize, Crop, the flips and turns, Draw, Paste, and Fill, change it in
place.
std/image/image.fb
Types
ImageFormat
enum
Public Enum ImageFormat
The formats std.image reads, which Image.FormatOf tells apart.
-
PNG.
-
JPEG.
-
Windows's BMP.
-
Truevision's TGA.
-
GIF, its first frame.
-
Radiance's HDR.
-
QOI, the Quite OK Image format.
-
WebP.
ResizeFilter
enum
Public Enum ResizeFilter
How Resize gives a pixel the colors of those under it, as Pillow resamples, the filter widened as the image shrinks.
-
The nearest one's.
-
A box's weighted sum, the average of what shrinks into a pixel.
-
A triangle's weighted sum.
-
Keys's cubic's weighted sum.
-
Lanczos's 3 lobes' weighted sum, the sharpest.
Image
class
Public Class Image
A picture's pixels, in rows from the top, each RGBA, 8 bits a channel, its alpha straight.
-
An image of
widthbyheightpixels, each transparent black. Panics when either is negative, or there'd be more pixels than an Image holds, 536870911. -
@PanicsAtCaller Public Static Method FromBytes(width: Int, height: Int, bytes: UInt8[]): Imagestatic method #An image of
widthbyheightpixels whose bytes, 4 for each pixel, red, green, blue, and alpha, are a copy ofbytes. Panics when there aren't that many, or the size is one New panics for. -
@PanicsAtCaller Public Static Method Over(width: Int, height: Int, pixels: Buffer<UInt8>): Imagestatic method #An image of
widthbyheightpixelswhose bytes, 4 for each pixel, red, green, blue, and alpha, are the Buffer's own, not a copy: what changes in one changes in the other, until a transform gives the image new ones. Panics when the Buffer doesn't have that many, or the size is one New panics for. -
Its pixels' bytes, 4 for each, red, green, blue, and alpha, in rows from the top: the image's own, not a copy, which C code can read and write through its Pointer. Resize, Crop, and the flips and turns give it new ones, which a Buffer from before doesn't see.
-
How many pixels wide it is.
-
How many pixels high it is.
-
The pixel
xfrom the left andyfrom the top. Panics when it's outside the image. -
Gives the pixel
xfrom the left andyfrom the top a color. Panics when it's outside the image. -
A copy of its pixels' bytes, 4 for each, red, green, blue, and alpha.
-
A new image of the same pixels, in a Buffer of its own.
-
@PanicsAtCaller Public Static Method Decode(data: UInt8[], limit: Int = MOST_PIXELS): Image Throws IOErrorstatic method #The image in
data, a PNG, JPEG, BMP, TGA, GIF's first frame, QOI, or WebP, by how its bytes start. Throws an IOError of INVALID_DATA when they're none of those, or broken, UNEXPECTED_END when they end too soon, and OTHER when they're an HDR image, which Hdr.Decode reads, or use what isn't supported, or the image has more pixels thanlimit. Panics when thelimitis negative. -
@PanicsAtCaller Public Static Method Load(path: Path, limit: Int = MOST_PIXELS): Image Throws IOErrorstatic method #The image in the file at
path, which Decode reads from its bytes. Throws the IOError File.ReadBytes does for a file that can't be read, and Decode's, its Path the file's, for one it can't read an image of. Panics when thelimitis negative. -
@PanicsAtCaller Public Static Async Method LoadAsync(path: Path, limit: Int = MOST_PIXELS): Image Throws IOErrorstatic method #Load's Async twin, which reads the file on libuv's thread pool while the thread that called it goes on, and decodes it there once the Await resumes.
-
The format the
data's bytes start as, or Null when they start as none of std.image's. A TGA has no signature, so it's what starts as a TGA's header does once no other format matches. -
@PanicsAtCaller Public Method Resize(width: Int, height: Int, filter: ResizeFilter = ResizeFilter.LANCZOS)method #Makes it
widthbyheightpixels, each one the colors under it by thefilter, weighted by their alpha, so a transparent pixel's color counts for nothing. Panics when the size is one New panics for, or the image has no pixels and the new size does. -
Keeps only its width by
heightpixels from (x,y). Panics when they aren't all in it. -
Flips it across, so its left is its right.
-
Flips it down, so its top is its bottom.
-
Turns it a quarter clockwise, so its height is its width.
-
Turns it a quarter counterclockwise, so its height is its width.
-
Turns it a half.
-
Draws
imageon it, its top-left pixel at (x,y), over these by its alpha, as "over" does with straight alpha; what falls outside is left out. -
Puts
image's pixels in place of these, alpha too, its top-left pixel at (x,y); what falls outside is left out. -
Gives every pixel the
color.
Report an issue with this page or with FutureBlitz on GitHub.