示例#1
0
        public IXLPicture Add(Stream stream, XLPictureFormat format, string name)
        {
            var picture = Add(stream, format);

            picture.Name = name;
            return(picture);
        }
示例#2
0
        internal XLPicture(IXLWorksheet worksheet, Stream stream, XLPictureFormat format)
            : this(worksheet)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            this.Format = format;

            this.ImageStream = new MemoryStream();
            {
                stream.Position = 0;
                stream.CopyTo(ImageStream);
                ImageStream.Seek(0, SeekOrigin.Begin);

                using (var bitmap = new Bitmap(ImageStream))
                {
                    if (FormatMap.ContainsKey(this.Format))
                    {
                        if (FormatMap[this.Format].Guid != bitmap.RawFormat.Guid)
                        {
                            throw new ArgumentException("The picture format in the stream and the parameter don't match");
                        }
                    }

                    DeduceDimensionsFromBitmap(bitmap);
                }
                ImageStream.Seek(0, SeekOrigin.Begin);
            }
        }
示例#3
0
 public IXLPicture Add(Stream stream, XLPictureFormat format)
 {
     var picture = new XLPicture(_worksheet, stream, format);
     _pictures.Add(picture);
     picture.Name = GetNextPictureName();
     return picture;
 }