Exemplo n.º 1
0
        public void SavePicture(Bitmap picture, int person_id, string filename)
        {
            Bitmap       thumbnailImage       = SmartResize(picture, PICTURE_THUMBNAIL_SIZE);
            Bitmap       resizedImage         = SmartResize(picture, PICTURE_MAX_BORDER);
            MemoryStream resizedImageStream   = new MemoryStream();
            MemoryStream thumbnailImageStream = new MemoryStream();

            thumbnailImage.Save(thumbnailImageStream, ImageFormat.Png);
            resizedImage.Save(resizedImageStream, ImageFormat.Png);
            filename = Path.GetFileNameWithoutExtension(filename);
            int subId = 0;

            _manager.SavePicture(resizedImageStream.ToArray(), thumbnailImageStream.ToArray(), person_id, filename, subId);
        }
Exemplo n.º 2
0
        /**
         * This method shall store image bytes in external file and convert it if
         * necessary. Images shall be stored using PNG format. Other formats may be
         * not supported by user browser.
         * <p>
         * Please note the {@link #processImage(XmlElement, boolean, Picture, String)}.
         *
         * @param currentBlock
         *            currently processed HTML element, like <tt>p</tt>. Shall be
         *            used as parent of newly created <tt>img</tt>
         * @param inlined
         *            if image is inlined
         * @param picture
         *            HWPF object, contained picture data and properties
         */
        protected override void ProcessImage(XmlElement currentBlock, bool inlined, Picture picture)
        {
            PicturesManager fileManager = GetPicturesManager();

            if (fileManager != null)
            {
                String url = fileManager
                             .SavePicture(picture.GetContent(),
                                          picture.SuggestPictureType(),
                                          picture.SuggestFullFileName());

                if (!string.IsNullOrEmpty(url))
                {
                    ProcessImage(currentBlock, inlined, picture, url);
                    return;
                }
            }

            // no default implementation -- skip
            currentBlock.AppendChild(htmlDocumentFacade.Document
                                     .CreateComment("Image link to '"
                                                    + picture.SuggestFullFileName() + "' can be here"));
        }