public override void VisitImage(ShapeImage shape) { try { if (string.IsNullOrEmpty(shape.ImageUrl)) { return; } var _image = shape.Image; var _imageUrl = shape.ImageUrl; if (_image == null) { _image = IOHelper.GetImageFromFile(_imageUrl); } if (_image == null) { _image = Image.FromFile(_imageUrl); var fd = new FrameDimension(_image.FrameDimensionsList[0]); _image.SelectActiveFrame(fd, 0); } shape.UpdateDestBounds(); if (shape.DestBounds == Rectangle.Empty) { shape.DestBounds = shape.VirtualBounds; } int desWidth = shape.DestBounds.Width / shape.Zoom; int desHeight = shape.DestBounds.Height / shape.Zoom; var desImg = new Bitmap(desWidth, desHeight); using (Graphics g = Graphics.FromImage(desImg)) { g.Clear(Color.Transparent); g.DrawImage(_image, new Rectangle(0, 0, desWidth, desHeight), new Rectangle(0, 0, _image.Width, _image.Height), GraphicsUnit.Pixel); } if (desImg != null) { IOHelper.SaveImage(desImg, ImageFile, ImageFormat.Png); } if (desImg != _image) { desImg.Dispose(); } } catch (Exception ex) { Log.Error(ex.Message, ex); ImageFile = null; } }
public override void VisitImage(ShapeImage shape) { if (shape.DestBounds.Size == SizeF.Empty) { return; } if (shape._Image == null) { shape._Image = IOHelper.GetImageFromFile(shape.ImageUrl); } if (shape._Image != null) { shape.UpdateDestBounds(); shape.DestBounds = new Rectangle(shape.DestBounds.X, shape.DestBounds.Y, shape.DestBounds.Width + 2, shape.DestBounds.Height); shape.InnerImage = shape.FormatImage(shape._Image, shape.DestBounds, GetFrameBounds(shape)); } using (var g = Graphics.FromImage(shape.InnerImage)) SignTypeHandler.SetOutChannel(g, shape.InnerImage, shape.SignType, new RectangleF(PointF.Empty, new SizeF(shape.InnerImage.Width, shape.InnerImage.Height)), new RectangleF(PointF.Empty, new SizeF(shape.InnerImage.Width, shape.InnerImage.Height))); shape.InnerImagePath = shape.SaveImage(shape.InnerImage); }