<> <> <> <> <<>> DIRECTORY Basics USING[BYTE], Terminal USING[Virtual], Atom USING[PropList], Rope USING[ROPE], Imager USING[Context], SampleMapOps USING[SubMap, Buffer]; Pixels: CEDAR DEFINITIONS ~ BEGIN <> BYTE: TYPE ~ Basics.BYTE; -- parts of a pixel will not exceed 8 bits in the forseeable future Extent: TYPE ~ RECORD[x, y, w, h: NAT]; SampleSet: TYPE ~ SampleMapOps.Buffer; <> SampleSetSequence: TYPE ~ RECORD[SEQUENCE length: NAT OF SampleSet]; SubMap: TYPE ~ RECORD[ subMap: SampleMapOps.SubMap, df: NAT _ 1]; <> SubMapSequence: TYPE ~ RECORD[SEQUENCE length: NAT OF SubMap]; PixelBuffer: TYPE ~ RECORD[ width: NAT _ 0, -- width, in pixels, of pixel grid height: NAT _ 0, -- height, in pixels, of pixel grid samplesPerPixel: NAT _ 0, -- number of samples representing each pixel (eg. RGB) pixels: REF SubMapSequence _ NIL, -- The bits. Each SubMap represents one sample from a pixel. Where an alpha buffer or depth buffer is used, its location is stored in the props under $Alpha or $Depth. props: Atom.PropList _ NIL ]; PixelsError: SIGNAL [reason: ErrorDesc]; ErrorDesc: TYPE ~ RECORD [code: ATOM, explanation: Rope.ROPE]; <> maxNoOfSamples: NAT ~ 6; -- rgb + alpha + depth + 1 expansion spot <> XfmMapPlace: PROC [ map: SubMap, x, y: INTEGER ] RETURNS [newX, newY: INTEGER]; ByteAvrgWgtd: PROC[ b1, b2, wgt: BYTE ] RETURNS[ bOut: BYTE ]; SumLessProd: PROC[ b1, b2: BYTE ] RETURNS[ bOut: BYTE ]; GetSampleSet: PROC[size: NAT] RETURNS[SampleSet]; GetTerminalYOffset: PROC[buf: PixelBuffer] RETURNS[NAT]; GetExtent: PROC[buf: PixelBuffer] RETURNS[Extent]; <> Create: PROC [width, height: NAT, pixelSizes: SampleSet] RETURNS[PixelBuffer]; <> GetFromImagerContext: PROC [context: Imager.Context] RETURNS[PixelBuffer]; <> GetFromTerminal: PROC [vt: Terminal.Virtual] RETURNS[PixelBuffer]; <> Interleave: PROC [pixels: REF SubMapSequence]; <> AddToBuffer: PROC [buf: PixelBuffer, pixelSizes: SampleSet] RETURNS[PixelBuffer]; <> <> TerminalFromBuffer: PROC [buf: PixelBuffer] RETURNS[vt: Terminal.Virtual]; <> ImagerContextFromBuffer: PROC [buf: PixelBuffer, type: ATOM _ NIL] RETURNS[ctx: Imager.Context]; <> Clip: PROC [buf: PixelBuffer, bounds: Extent]; <> Fill: PROC [buf: PixelBuffer, pixel: SampleSet _ NIL]; <> Transfer: PROC [dstBuf, srcBuf: PixelBuffer]; <> Copy: PROC [ destination, source: PixelBuffer, destArea, srcArea: Extent, op: ATOM _ $Write ]; <> ShowOnImagerContext: PROC [context: Imager.Context, buf: PixelBuffer]; <> <> <> GetPixel: PROC [buf: PixelBuffer, x, y: NAT, pixel: SampleSet _ NIL] RETURNS[ SampleSet ]; <> PutPixel: PROC [ buf: PixelBuffer, x, y: NAT, pixel: SampleSet ]; GetScanSeg: PROC [buf: PixelBuffer, x, y, length: NAT, pixels: REF SampleSetSequence _ NIL] RETURNS[ REF SampleSetSequence ]; PutScanSeg: PROC [ buf: PixelBuffer, x, y, length: NAT, pixels: REF SampleSetSequence, op: ATOM _ $Write ]; PixelOp: PROC [ buf: PixelBuffer, area: Extent, pixel: SampleSet, op: ATOM _ $Write ]; <> <<$AND = bitwise AND>> <<$OR = bitwise OR>> <<$XOR = bitwise XOR>> <<$Write = replace previous contents with new pixel (default)>> <<$WriteUnder = blend behind previously written pixels (using alpha buffer)>> <<$WriteOver = blend in front of previously written pixels (using alpha buffer)>> <> <> GetValue: PROC [buf: PixelBuffer, x, y: NAT, map: NAT _ 0] RETURNS[ value: CARDINAL ]; PutValue: PROC [ buf: PixelBuffer, x, y: NAT, value: CARDINAL, map: NAT _ 0 ]; ValueOp: PROC [ buf: PixelBuffer, area: Extent, value: CARDINAL, map: NAT _ 0, op: ATOM _ $Write ]; <> <<$AND = bitwise AND>> <<$OR = bitwise OR>> <<$XOR = bitwise XOR>> <<$Write = replace previous contents with new pixel (default)>> END.