DrawImage() public abstract method

public abstract DrawImage ( Image image, RectangleF dest ) : void
image Image
dest RectangleF
return void
コード例 #1
0
        protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
        {
            // canvas.FillRectangle(Color.White, 0, 0, this.Width, this.Height);
            if (needUpdate)
            {
                //default bg => transparent !, 
                //gfx2d.Clear(ColorRGBA.White);//if want opaque bg
                ReleaseUnmanagedResources();
                if (bmp != null)
                {
                    bmp.Dispose();
                }

                this.bmp = this.actualImage;// new Bitmap(this.Width, this.Height, this.actualImage.GetBuffer(), false);
                // canvas.Platform.CreatePlatformBitmap(this.Width, this.Height, this.actualImage.GetBuffer(), false);
                Image.SetCacheInnerImage(bmp, null);
                needUpdate = false;
            }
            //canvas.FillRectangle(this.BackColor, 0, 0, this.Width, this.Height);

            if (bmp != null)
            {
                canvas.DrawImage(this.bmp, new RectangleF(0, 0, this.Width, this.Height));
            }
            //---------------------



#if DEBUG
            //canvasPage.dbug_DrawCrossRect(PixelFarm.Drawing.Color.Black,
            //    new Rectangle(0, 0, this.Width, this.Height));
#endif
        }
コード例 #2
0
        protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
        {
            if (this.imageBinder != null)
            {
                switch (imageBinder.State)
                {
                    case ImageBinderState.Loaded:
                        {
                            canvas.DrawImage(imageBinder.Image,
                                new RectangleF(0, 0, this.Width, this.Height));
                        }
                        break;
                    case ImageBinderState.Unload:
                        {
                            if (this.imageBinder.HasLazyFunc)
                            {
                                this.imageBinder.LazyLoadImage();
                            }
                        }
                        break;
                }
            }
            else
            {
                //when no image
                //canvasPage.FillRectangle(BackColor, updateArea._left, updateArea._top, updateArea.Width, updateArea.Height);
            }
#if DEBUG
            //canvasPage.dbug_DrawCrossRect(PixelFarm.Drawing.Color.Black,
            //    new Rectangle(0, 0, this.Width, this.Height));
#endif
        }
コード例 #3
0
        /// <summary>
        /// Draw the background image of the given box in the given rectangle.<br/>
        /// Handle background-repeat and background-position values.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="box">the box to draw its background image</param>
        /// <param name="imageLoadHandler">the handler that loads image to draw</param>
        /// <param name="rectangle">the rectangle to draw image in</param>
        public static void DrawBackgroundImage(Canvas g, CssBox box, ImageBinder imageBinder, RectangleF rectangle)
        {
            var image = imageBinder.Image;
            //temporary comment image scale code 
            var imgSize = image.Size;
            //new Size(imageLoadHandler.Rectangle == Rectangle.Empty ? imageLoadHandler.Image.Width : imageLoadHandler.Rectangle.Width,
            //                 imageLoadHandler.Rectangle == Rectangle.Empty ? imageLoadHandler.Image.Height : imageLoadHandler.Rectangle.Height);

            // get the location by BackgroundPosition value
            var location = GetLocation(box.BackgroundPositionX, box.BackgroundPositionY, rectangle, imgSize);
            //var srcRect = imageLoadHandler.Rectangle == Rectangle.Empty
            //                  ? new Rectangle(0, 0, imgSize.Width, imgSize.Height)
            //                  : new Rectangle(imageLoadHandler.Rectangle.Left, imageLoadHandler.Rectangle.Top, imgSize.Width, imgSize.Height);
            var srcRect = new Rectangle(0, 0, image.Width, image.Height);
            // initial image destination rectangle
            var destRect = new Rectangle(location, imgSize);
            // need to clip so repeated image will be cut on rectangle

            var prevClip = g.CurrentClipRect;
            PixelFarm.Drawing.Rectangle copyRect = new PixelFarm.Drawing.Rectangle(
               (int)rectangle.X,
               (int)rectangle.Y,
               (int)rectangle.Width,
               (int)rectangle.Height);
            copyRect.Intersect(prevClip);
            g.SetClipRect(copyRect);
            switch (box.BackgroundRepeat)
            {
                case CssBackgroundRepeat.NoRepeat:
                    g.DrawImage(image, new RectangleF(location, imgSize), new RectangleF(0, 0, image.Width, image.Height));
                    break;
                case CssBackgroundRepeat.RepeatX:
                    DrawRepeatX(g, image, rectangle, srcRect, destRect, imgSize);
                    break;
                case CssBackgroundRepeat.RepeatY:
                    DrawRepeatY(g, image, rectangle, srcRect, destRect, imgSize);
                    break;
                default:
                    DrawRepeat(g, image, rectangle, srcRect, destRect, imgSize);
                    break;
            }

            g.SetClipRect(prevClip);
        }
コード例 #4
0
        protected override void DrawBoxContent(Canvas canvas, Rectangle updateArea)
        {
            //if (this.image != null)
            //{
            //    canvas.DrawImage(this.image,
            //        new RectangleF(0, 0, this.Width, this.Height));
            //}
            //else
            //{
            //when no image
            //---------------------

            // canvas.FillRectangle(Color.White, 0, 0, this.Width, this.Height);
            if (needUpdate)
            {
                //default bg => transparent !,

                //gfx2d.Clear(ColorRGBA.White);//if want opaque bg
                ReleaseUnmanagedResources();
                int j = sprites.Count;
                for (int i = 0; i < j; ++i)
                {
                    sprites[i].OnDraw(gfx2d);
                }

                //this.bmp = new Bitmap(this.Width, this.Height, this.actualImage.GetBuffer(), true);
                needUpdate = false;
            }
            canvas.DrawImage(actualImage, new RectangleF(0, 0, this.Width, this.Height));
            //---------------------
            //copy data from actual image to canvas 

            //}
#if DEBUG
            //canvasPage.dbug_DrawCrossRect(PixelFarm.Drawing.Color.Black,
            //    new Rectangle(0, 0, this.Width, this.Height));
#endif
        }
コード例 #5
0
ファイル: RenderUtils.cs プロジェクト: prepare/HTML-Renderer
 /// <summary>
 /// Draw image failed to load icon.
 /// </summary>
 /// <param name="g">the device to draw into</param>
 /// <param name="r">the rectangle to draw icon in</param>
 public static void DrawImageErrorIcon(Canvas g, RectangleF r)
 {
     g.DrawRectangle(Color.LightGray, r.Left + 2, r.Top + 2, 15, 15);
     var image = GetErrorImage();
     g.DrawImage(image, new RectangleF(r.Left + 3, r.Top + 3, image.Width, image.Height));
 }
コード例 #6
0
ファイル: RenderUtils.cs プロジェクト: prepare/HTML-Renderer
        ///// <summary>
        ///// Get cached solid brush instance for the given color.
        ///// </summary>
        ///// <param name="color">the color to get brush for</param>
        ///// <returns>brush instance</returns>
        //public static Brush GetSolidBrush(Color color)
        //{

        //    if (color == Color.White)
        //    {
        //        return Brushes.White;
        //    }
        //    else if (color == Color.Black)
        //    {
        //        return Brushes.Black;
        //    }
        //    else if (!IsColorVisible(color))
        //    {
        //        return Brushes.Transparent;
        //    }
        //    else
        //    {
        //        Brush brush;
        //        if (!_brushesCache.TryGetValue(color, out brush))
        //        {

        //            _brushesCache[color] = brush = CurrentGraphicPlatform.CreateSolidBrush(color);

        //        }
        //        return brush;
        //    }
        //}

        ///// <summary>
        ///// Get cached pen instance for the given color.
        ///// </summary>
        ///// <param name="color">the color to get pen for</param>
        ///// <returns>pen instance</returns>
        //public static Pen GetPen(GraphicPlatform p, Color color)
        //{
        //    Pen pen;
        //    if (!_penCache.TryGetValue(color, out pen))
        //    {
        //        pen = p.CreateSolidPen(color); 
        //        _penCache[color] = pen;
        //    }
        //    else
        //    {
        //        pen.Width = 1;
        //    }
        //    return pen;
        //}
        /// <summary>
        /// Draw image loading icon.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="r">the rectangle to draw icon in</param>
        public static void DrawImageLoadingIcon(Canvas g, RectangleF r)
        {
            g.DrawRectangle(Color.LightGray, r.Left + 3, r.Top + 3, 13, 14);
            var image = GetLoadImage();
            g.DrawImage(image, new RectangleF(r.Left + 4, r.Top + 4, image.Width, image.Height));
        }