Example #1
0
        /// <summary>
        ///     Renders an image, clipping it as specified.
        /// </summary>
        /// <param name="x">The x position of left edge in millipoints.</param>
        /// <param name="y">The y position of top edge in millipoints.</param>
        /// <param name="clipX">The left edge of the clip in millipoints.</param>
        /// <param name="clipY">The top edge of the clip in millipoints.</param>
        /// <param name="clipW">The clip width in millipoints.</param>
        /// <param name="clipH">The clip height in millipoints.</param>
        /// <param name="image">The image to be rendered.</param>
        private void DrawImageClipped(
            int x, int y, int clipX, int clipY,
            int clipW, int clipH, FonetImage image)
        {
            float cx1 = ((float)x) / 1000f;
            float cy1 = ((float)y - clipH) / 1000f;

            float cx2 = ((float)x + clipW) / 1000f;
            float cy2 = ((float)y) / 1000f;

            int imgX = x - clipX;
            int imgY = y - clipY;

            int imgW = image.Width * 1000;
            int imgH = image.Height * 1000;

            PdfXObject xobj = this.pdfCreator.AddImage(image);

            CloseText();

            currentStream.ClipImage(
                cx1, cy1, cx2, cy2,
                imgX, imgY, imgW, imgH, xobj);
        }