The OpenD Programming Language

MemoryImage

This provides two image classes and a bunch of functions that work on them.

Why are they separate classes? I think the operations on the two of them are necessarily different. There's a whole bunch of operations that only really work on truecolor (blurs, gradients), and a few that only work on indexed images (palette swaps).

Even putpixel is pretty different. On indexed, it is a palette entry's index number. On truecolor, it is the actual color.

A greyscale image is the weird thing in the middle. It is truecolor, but fits in the same size as indexed. Still, I'd say it is a specialization of truecolor.

There is a subset that works on both

An image in memory

Members

Aliases

fromImageFile
alias fromImageFile = fromImage

Convenient alias for fromImage

Functions

clone
MemoryImage clone()

Returns a copy of the image

getAsTrueColorImage
TrueColorImage getAsTrueColorImage()

gets it as a TrueColorImage. May return this or may do a conversion and return a new image

getPixel
Color getPixel(int x, int y)

Get image pixel. Slow, but returns valid RGBA color (completely transparent for off-image pixels).

height
int height()

Image height, in pixels

setPixel
void setPixel(int x, int y, Color clr)

Set image pixel.

width
int width()

Image width, in pixels

Static functions

fromImage
MemoryImage fromImage(T filename)

Load image from file. This will import arsd.image to do the actual work, and cost nothing if you don't use it.

Meta