/// <summary> /// Renders an area's background. /// </summary> /// <param name="area">The area whose background is to be rendered.</param> /// <param name="x">The x position of the left edge in millipoints.</param> /// <param name="y">The y position of top edge in millipoints.</param> /// <param name="w">The width in millipoints.</param> /// <param name="h">The height in millipoints.</param> private void DoBackground(Area area, int x, int y, int w, int h) { if (h == 0 || w == 0) { return; } BackgroundProps props = area.getBackground(); if (props == null) { return; } if (props.backColor.Alpha == 0) { AddFilledRect(x, y, w, -h, new PdfColor(props.backColor)); } if (props.backImage != null) { int imgW = props.backImage.Width*1000; int imgH = props.backImage.Height*1000; int dx = x; int dy = y; int endX = x + w; int endY = y - h; int clipW = w%imgW; int clipH = h%imgH; bool repeatX = true; bool repeatY = true; switch (props.backRepeat) { case BackgroundRepeat.REPEAT: break; case BackgroundRepeat.REPEAT_X: repeatY = false; break; case BackgroundRepeat.REPEAT_Y: repeatX = false; break; case BackgroundRepeat.NO_REPEAT: repeatX = false; repeatY = false; break; case BackgroundRepeat.INHERIT: break; default: FonetDriver.ActiveDriver.FireFonetWarning("Ignoring invalid background-repeat property"); break; } while (dy > endY) { // looping through rows while (dx < endX) { // looping through cols if (dx + imgW <= endX) { // no x clipping if (dy - imgH >= endY) { // no x clipping, no y clipping DrawImageScaled(dx, dy, imgW, imgH, props.backImage); } else { // no x clipping, y clipping DrawImageClipped(dx, dy, 0, 0, imgW, clipH, props.backImage); } } else { // x clipping if (dy - imgH >= endY) { // x clipping, no y clipping DrawImageClipped(dx, dy, 0, 0, clipW, imgH, props.backImage); } else { // x clipping, y clipping DrawImageClipped(dx, dy, 0, 0, clipW, clipH, props.backImage); } } if (repeatX) { dx += imgW; } else { break; } } // end looping through cols dx = x; if (repeatY) { dy -= imgH; } else { break; } } // end looping through rows } }