Exemplo n.º 1
0
        public ActionResult Thumbnail(string id)
        {
            var repository = new TagRepository();
            var tag        = repository.GetTag(id);
            var photoList  = repository.GetPhotoList(id);

            if (tag != null && photoList.Count > 0)
            {
                using (MultiThumbnailGenerator generator = new MultiThumbnailGenerator())
                {
                    foreach (var photo in photoList)
                    {
                        using (var imageStream = new System.IO.MemoryStream(photo.FileContents))
                        {
                            using (var image = System.Drawing.Image.FromStream(imageStream))
                            {
                                generator.AddImage(image);
                            }
                        }
                    }

                    using (var outStream = new System.IO.MemoryStream())
                    {
                        generator.WritePngToStream(outStream);
                        var image = new WebImage(outStream);
                        image.Write();
                    }
                }

                return(null);
            }

            return(Redirect("~/Content/Images/gallery-empty.png"));
        }
Exemplo n.º 2
0
        public ActionResult Thumbnail(string id)
        {
            var repository = new TagRepository();
            var tag = repository.GetTag(id);
            var photoList = repository.GetPhotoList(id);

            if (tag != null && photoList.Count > 0)
            {
                using (MultiThumbnailGenerator generator = new MultiThumbnailGenerator())
                {
                    foreach (var photo in photoList)
                    {
                        using (var imageStream = new System.IO.MemoryStream(photo.FileContents))
                        {
                            using (var image = System.Drawing.Image.FromStream(imageStream))
                            {
                                generator.AddImage(image);
                            }
                        }
                    }

                    using (var outStream = new System.IO.MemoryStream())
                    {
                        generator.WritePngToStream(outStream);
                        var image = new WebImage(outStream);
                        image.Write();
                    }
                }

                return null;
            }

            return Redirect("~/Content/Images/gallery-empty.png");
        }
        private string CreateThumbanils(string p, IEnumerable<string> enumerable)
        {
            using (MultiThumbnailGenerator generator = new MultiThumbnailGenerator())
            {
                foreach (string imagePath in enumerable)
                {
                    Image img = Image.FromFile(imagePath);
                    generator.AddImage(img);
                }

                string resultName = p + "_result.jpg";
                using (FileStream fs = File.OpenWrite(resultName))
                {
                    generator.WriteJpgToStream(fs);
                }

                return resultName;
            }
        }
        private string CreateThumbanils(string p, IEnumerable <string> enumerable)
        {
            using (MultiThumbnailGenerator generator = new MultiThumbnailGenerator())
            {
                foreach (string imagePath in enumerable)
                {
                    Image img = Image.FromFile(imagePath);
                    generator.AddImage(img);
                }

                string resultName = p + "_result.jpg";
                using (FileStream fs = File.OpenWrite(resultName))
                {
                    generator.WriteJpgToStream(fs);
                }

                return(resultName);
            }
        }
Exemplo n.º 5
0
        public ActionResult Thumbnail(int id)
        {
            var db = new PhotoGalleryRepository();

            var gallery = db.GetGallery(id);

            if (gallery == null)
            {
                return(HttpNotFound());
            }

            var photos = db.GetTopPhotosForGallery(id);

            if (photos.Count == 0)
            {
                return(File(Server.MapPath("~/Content/Images/gallery-empty.png"), "image/jpeg"));
            }

            using (var generator = new MultiThumbnailGenerator())
            {
                foreach (var photo in photos)
                {
                    using (var imageStream = new MemoryStream(photo.FileContents))
                    {
                        using (var image = System.Drawing.Image.FromStream(imageStream))
                        {
                            generator.AddImage(image);
                        }
                    }
                }
                using (var outStream = new MemoryStream())
                {
                    generator.WritePngToStream(outStream);
                    var image = new WebImage(outStream);
                    image.Write();

                    return(null);
                }
            }
        }
Exemplo n.º 6
0
        public ActionResult Thumbnail(int id)
        {
            var db = new PhotoGalleryRepository();

            var gallery = db.GetGallery(id);
            if (gallery == null)
            {
                return HttpNotFound();
            }

            var photos = db.GetTopPhotosForGallery(id);
            if (photos.Count == 0)
            {
                return File(Server.MapPath("~/Content/Images/gallery-empty.png"), "image/jpeg");
            }

            using (var generator = new MultiThumbnailGenerator())
            {
                foreach (var photo in photos)
                {
                    using (var imageStream = new MemoryStream(photo.FileContents))
                    {
                        using (var image = System.Drawing.Image.FromStream(imageStream))
                        {
                            generator.AddImage(image);
                        }
                    }
                }
                using (var outStream = new MemoryStream())
                {
                    generator.WritePngToStream(outStream);
                    var image = new WebImage(outStream);
                    image.Write();

                    return null;
                }
            }
        }