コード例 #1
0
 public GdiPlusCanvasViewport(RootGraphic rootgfx,
     Size viewportSize, int cachedPageNum)
     : base(rootgfx, viewportSize, cachedPageNum)
 {
     quadPages = new QuadPages( cachedPageNum, viewportSize.Width, viewportSize.Height * 2);
     this.CalculateCanvasPages();
 }
コード例 #2
0
        /// <summary>
        /// Measure the width and height of string <paramref name="str"/> when drawn on device context HDC
        /// using the given font <paramref name="font"/>.<br/>
        /// Restrict the width of the string and get the number of characters able to fit in the restriction and
        /// the width those characters take.
        /// </summary>
        /// <param name="str">the string to measure</param>
        /// <param name="font">the font to measure string with</param>
        /// <param name="maxWidth">the max width to render the string in</param>
        /// <param name="charFit">the number of characters that will fit under <see cref="maxWidth"/> restriction</param>
        /// <param name="charFitWidth"></param>
        /// <returns>the size of the string</returns>
        public static Size MeasureString(char[] buff, int startAt, int len, RequestFont font, float maxWidth, out int charFit, out int charFitWidth)
        {
            //if (_useGdiPlusTextRendering)
            //{
            //    ReleaseHdc();
            //    throw new NotSupportedException("Char fit string measuring is not supported for GDI+ text rendering");
            //}
            //else
            //{
            SetFont(font);
            if (buff.Length == 0)
            {
                charFit      = 0;
                charFitWidth = 0;
                return(Size.Empty);
            }
            var size = new PixelFarm.Drawing.Size();

            unsafe
            {
                fixed(char *startAddr = &buff[0])
                {
                    NativeTextWin32.UnsafeGetTextExtentExPoint(
                        win32MemDc.DC, startAddr + startAt, len,
                        (int)Math.Round(maxWidth), _charFit, _charFitWidth, ref size);
                }
            }
            charFit      = _charFit[0];
            charFitWidth = charFit > 0 ? _charFitWidth[charFit - 1] : 0;
            return(size);
            //}
        }
コード例 #3
0
 bool isClosed;//is this viewport closed
 public CanvasViewport(RootGraphic rootgfx,
     Size viewportSize, int cachedPageNum)
 {
     this.rootGraphics = rootgfx;
     this.topWindowBox = rootgfx.TopWindowRenderBox;
     this.viewportWidth = viewportSize.Width;
     this.viewportHeight = viewportSize.Height;
     canvasSizeChangedHandler = Canvas_SizeChanged;
     viewportX = 0;
     viewportY = 0;
 }
コード例 #4
0
        public SkiaCanvasViewport(RootGraphic rootgfx,
            Size viewportSize, int cachedPageNum)
            : base(rootgfx, viewportSize, cachedPageNum)
        {

            this.CalculateCanvasPages();
            mySkCanvas = new PixelFarm.Drawing.Skia.MySkiaCanvas(0, 0, 0, 0, internalSizeW, internalSizwH);
            //TODO: review performance here
            //review how to move data from unmanged(skia) to unmanaged(hdc's bitmap)
            tmpBmp = new System.Drawing.Bitmap(internalSizeW, internalSizwH);
            var bmpdata = tmpBmp.LockBits(
                new System.Drawing.Rectangle(0, 0, internalSizeW, internalSizwH),
                 System.Drawing.Imaging.ImageLockMode.ReadOnly, tmpBmp.PixelFormat);
            tmpBuffer = new byte[bmpdata.Stride * bmpdata.Height];
            tmpBmp.UnlockBits(bmpdata);
        }
コード例 #5
0
 protected void SetPostCalculateLayerContentSize(Size s)
 {
     ValidateCalculateContentSize();
     postCalculateContentWidth = s.Width;
     postCalculateContentHeight = s.Height;
 }
コード例 #6
0
ファイル: Rectangle.cs プロジェクト: prepare/HTML-Renderer
        // -----------------------
        // Public Constructors
        // -----------------------

        /// <summary>
        ///	Rectangle Constructor
        /// </summary>
        ///
        /// <remarks>
        ///	Creates a Rectangle from Point and Size values.
        /// </remarks>

        public Rectangle(Point location, Size size)
        {
            x = location.X;
            y = location.Y;
            width = size.Width;
            height = size.Height;
        }
コード例 #7
0
ファイル: Rectangle.cs プロジェクト: prepare/HTML-Renderer
        /// <summary>
        ///	Inflate Method
        /// </summary>
        ///
        /// <remarks>
        ///	Inflates the Rectangle by a specified Size.
        /// </remarks>

        public void Inflate(Size size)
        {
            x -= size.Width;
            y -= size.Height;
            Width += size.Width * 2;
            Height += size.Height * 2;
        }
コード例 #8
0
ファイル: WinGdiFont.cs プロジェクト: prepare/HTML-Renderer
 /// <summary>
 /// Measure the width and height of string <paramref name="str"/> when drawn on device context HDC
 /// using the given font <paramref name="font"/>.<br/>
 /// Restrict the width of the string and get the number of characters able to fit in the restriction and
 /// the width those characters take.
 /// </summary>
 /// <param name="str">the string to measure</param>
 /// <param name="font">the font to measure string with</param>
 /// <param name="maxWidth">the max width to render the string in</param>
 /// <param name="charFit">the number of characters that will fit under <see cref="maxWidth"/> restriction</param>
 /// <param name="charFitWidth"></param>
 /// <returns>the size of the string</returns>
 public static Size MeasureString(char[] buff, int startAt, int len, RequestFont font, float maxWidth, out int charFit, out int charFitWidth)
 {
     //if (_useGdiPlusTextRendering)
     //{
     //    ReleaseHdc();
     //    throw new NotSupportedException("Char fit string measuring is not supported for GDI+ text rendering");
     //}
     //else
     //{
     SetFont(font);
     if (buff.Length == 0)
     {
         charFit = 0;
         charFitWidth = 0;
         return Size.Empty;
     }
     var size = new PixelFarm.Drawing.Size();
     unsafe
     {
         fixed (char* startAddr = &buff[0])
         {
             NativeTextWin32.UnsafeGetTextExtentExPoint(
                 win32MemDc.DC, startAddr + startAt, len,
                 (int)Math.Round(maxWidth), _charFit, _charFitWidth, ref size);
         }
     }
     charFit = _charFit[0];
     charFitWidth = charFit > 0 ? _charFitWidth[charFit - 1] : 0;
     return size;
     //}
 }
コード例 #9
0
 /// <summary>
 /// Get top-left location to start drawing the image at depending on background-position value.
 /// </summary>
 /// <param name="backgroundPosition">the background-position value</param>
 /// <param name="rectangle">the rectangle to position image in</param>
 /// <param name="imgSize">the size of the image</param>
 /// <returns>the top-left location</returns>
 static Point GetLocation(CssLength posX, CssLength posY, RectangleF rectangle, Size imgSize)
 {
     int left = (int)rectangle.Left;
     int top = (int)rectangle.Top;
     if (posX.IsBackgroundPositionName)
     {
         switch (posX.UnitOrNames)
         {
             case CssUnitOrNames.LEFT:
                 {
                     left = (int)(rectangle.Left + .5f);
                 }
                 break;
             case CssUnitOrNames.RIGHT:
                 {
                     left = (int)rectangle.Right - imgSize.Width;
                 }
                 break;
         }
     }
     else
     {
         //not complete !
         left = (int)(rectangle.Left + (rectangle.Width - imgSize.Width) / 2 + .5f);
     }
     if (posY.IsBackgroundPositionName)
     {
         switch (posY.UnitOrNames)
         {
             case CssUnitOrNames.TOP:
                 {
                     top = (int)rectangle.Top;
                 }
                 break;
             case CssUnitOrNames.BOTTOM:
                 {
                     top = (int)rectangle.Bottom - imgSize.Height;
                 }
                 break;
         }
     }
     else
     {   //not complete !
         top = (int)(rectangle.Top + (rectangle.Height - imgSize.Height) / 2 + .5f);
     }
     return new Point(left, top);
 }
コード例 #10
0
 /// <summary>
 /// Draw the background image at the required location repeating it over the X and Y axis.<br/>
 /// Adjust location to left-top if starting location doesn't include all the range (adjusted to center or bottom/right).
 /// </summary>
 private static void DrawRepeat(Canvas g, Image img, RectangleF rectangle, Rectangle srcRect, Rectangle destRect, Size imgSize)
 {
     while (destRect.X > rectangle.X)
         destRect.X -= imgSize.Width;
     while (destRect.Y > rectangle.Y)
         destRect.Y -= imgSize.Height;
     //TODO: reimplement this again
     //using (var brush = g.Platform.CreateTextureBrush(img, srcRect))
     //{
     //    brush.TranslateTransform(destRect.X, destRect.Y);
     //    g.FillRectangle(brush, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
     //}
 }