PaintPMImpl.Mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Last Edited by: Spreitzer, December 20, 1985 2:05:23 pm PST
DIRECTORY Imager, ImagerColorOperator, ImagerOps, ImagerPixelMap, ImagerSample, ImagerTransformation, PaintPM, Rope;
PaintPMImpl: CEDAR PROGRAM
IMPORTS Imager, ImagerColorOperator, ImagerOps, ImagerPixelMap, ImagerTransformation
EXPORTS PaintPM
=
{OPEN PaintPM;
rasterToXY: ImagerTransformation.Transformation ← ImagerTransformation.Rotate[-90];
PaintPixelMap: PUBLIC PROC [context: Context, pm: PixelMap, cm: ColorMap, clearValue: CARDINAL] = {
mask: PixelMap = MakeMask[pm, clearValue];
MapValueToColor: PROC [value: ImagerSample.Sample] RETURNS [cc: ConstantColor] = {
cc ← cm[value];
};
Imager.SetSampledColor[
context: context,
pa: ImagerOps.PixelArrayFromPixelMaps[
pms: LIST[pm],
um: rasterToXY
],
colorOperator: ImagerColorOperator.MapColorModel[
maxSampleValue: cm.length-1,
map: MapValueToColor]
];
Imager.MaskBits[
context: context,
base: mask.refRep.pointer,
wordsPerLine: mask.refRep.rast,
sMin: mask.sMin,
fMin: mask.fMin,
sSize: mask.sSize,
fSize: mask.fSize,
tx: 0,
ty: mask.sSize
];
};
opaque: CARDINAL ← 1;
clear: CARDINAL ← 0;
MakeMask: PROC [pm: PixelMap, clearValue: CARDINAL] RETURNS [mask: PixelMap] = {
mask ← ImagerPixelMap.Create[
lgBitsPerPixel: 0,
bounds: [sMin: pm.sOrigin, fMin: pm.fOrigin, sSize: pm.sMin+pm.sSize, fSize: pm.fMin+pm.fSize]
];
mask ← mask.SetWindow[pm.Window[]];
FOR s: INTEGER IN [pm.sOrigin+pm.sMin .. pm.sOrigin+pm.sMin+pm.sSize) DO
FOR f: INTEGER IN [pm.fOrigin+pm.fMin .. pm.fOrigin+pm.fMin+pm.fSize) DO
mask.PutPixel[s, f, IF pm.GetPixel[s, f]=clearValue THEN clear ELSE opaque];
ENDLOOP;
ENDLOOP;
pm ← pm;
};
}.