HomeForumSourceResearchGuide
Sign in to contribute to source. how it works
Type definition file media.image.ImageTransform by barry
expand copy to clipboardexpand
/* {"description" : "This API supports common transform functions for images." } */

uses media.PixelMap
uses media.PixelMapYUV

data ChromaKeySpec {
	byte r
	byte g
	byte b
	byte fgTolerance
	byte bgTolerance
}

interface ImageTransform {

	ImageTransform(WH outputSize)

	/* {"@description" : "Convert an RGBA image to YUV." } */
	PixelMapYUV rgbaToYUV(PixelMap p, opt byte pixelFormat)

	/* {"@description" : "Convert a YUV image to RGBA." } */
	PixelMap yuvToRGBA(PixelMapYUV p, opt ChromaKeySpec spec)
	
	/* {"@description" : "Crop an image, by identifying a rectangle within that image. The identified rectangle is extracted as a new image and returned." } */
	PixelMap crop(PixelMap p, int x, int y)

	/* {"@description" : "Set pixels matching the given colour to be transparent." } */
	PixelMap chromaKey(PixelMap p, ChromaKeySpec spec, opt byte pixelFormat)

	/* {"@description" : "Apply a run-length-encoded mask to the pixels." } */
	PixelMap runAlphaMask(PixelMap p, byte mask[], opt byte pixelFormat)

	}
Revision history
To propose a new revision to this entity, use dana source put -ut your/new/version.dn -n media.image.ImageTransform -m "reason for update" -u yourUsername
Version 5 by barry
Version 4 (this version) by barry
Notes for this version: Improves performance by pre-allocating a storage area for return values, adds a run-length alpha mask function
Version 3 by barry
Version 2 by barry
Version 1 by barry