IF CDBasics.NonEmpty[inter] THEN {
DrawToBitmapContext: PROC [] = {
proc[context, ob, layer];
};
CapturePixel: PROC [x, y: INT] = INLINE {
r: CD.Rect ← CDOrient.MapRect[itemInCell: [x1: x, y1: y, x2: x+1, y2: y+1], cellSize: ob.size, cellInstOrient: orient, cellInstPos: pos];
r ← CDBasics.Intersection[r, pr.interestClip];
IF CDBasics.NonEmpty[r] THEN pr.drawRect[r, layer, pr];
};
CaptureBitmap: PROC [bitmap: ImagerBackdoor.Bitmap, off: CD.Position] =
BEGIN
FOR y: CARDINAL IN [0..bitmap.height) DO
FOR x: CARDINAL IN [0..bitmap.width) DO
TRUSTED {
bitsRef: LONG POINTER TO CARDINAL
← LOOPHOLE[bitmap.base, LONG POINTER TO CARDINAL]
+ LONG[y]*bitmap.wordsPerLine
+ LONG[x/Basics.bitsPerWord];
IF Basics.BITAND[8000h, Basics.BITSHIFT[bitsRef^, x MOD Basics.bitsPerWord]]#0 THEN
CapturePixel[off.x+x, off.y+bitmap.height-y-1]
}
ENDLOOP;
ENDLOOP;
END;
bitmap: ImagerBackdoor.Bitmap ← ImagerBackdoor.NewBitmap[width: inter.x2-inter.x1, height: inter.y2-inter.y1];
context: Imager.Context ← ImagerBackdoor.BitmapContext[bitmap];
Imager.SetColor[context, Imager.white];
Imager.MaskRectangleI[context, 0, 0, bitmap.width, bitmap.height];
Imager.TranslateT[context, [-inter.x1, -inter.y1]];
Imager.SetColor[context, Imager.black];
Imager.DoSave[context, DrawToBitmapContext];
CaptureBitmap[bitmap, CDBasics.BaseOfRect[inter]];
bitmap ← NIL;
context ← NIL;
};