コード例 #1
0
        /// <summary>
        /// Roates a Gallery image
        /// </summary>
        /// <param name="member"></param>
        /// <param name="WebPhotoID"></param>
        /// <param name="RootPath"></param>
        /// <returns></returns>
        public static bool RotateGalleryImage(Member member, string WebPhotoID, string RootPath, int Rotation)
        {
            // seems a bit overcomplicated but you cannot save to an image that is open as its locked.. so open it from a file
            // stream and then dispose the filestream
            //try
            //{
            Photo photo = Photo.GetPhotoByWebPhotoIDWithJoin(WebPhotoID);

            string FullPath       = RootPath + member.NickName;
            string LargeFullPath  = FullPath + @"\plrge\" + photo.PhotoResourceFile.FileName;
            string MediumFullPath = FullPath + @"\pmed\" + photo.PhotoResourceFile.FileName;
            string ThumbFullPath  = FullPath + @"\pthmb\" + photo.PhotoResourceFile.FileName;

            FileStream fsLarge = new FileStream(LargeFullPath, FileMode.Open);

            Image LargeImage = Bitmap.FromStream(fsLarge);

            fsLarge.Close();
            fsLarge.Dispose();

            if (Rotation == 1)
            {
                LargeImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
            }
            else if (Rotation == 2)
            {
                LargeImage.RotateFlip(RotateFlipType.Rotate180FlipNone);
            }
            else if (Rotation == 3)
            {
                LargeImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
            }

            SaveToDiskRelativePath(LargeImage, LargeFullPath);

            //resize medium and save
            System.Drawing.Image MediumImage = Photo.Resize480x480(LargeImage);
            SaveToDiskRelativePath(MediumImage, MediumFullPath);

            //resize thumbnail and save
            System.Drawing.Image ThumbnailImage = Photo.ResizeTo124x91(MediumImage);
            SaveToDiskRelativePath(ThumbnailImage, ThumbFullPath);

            LargeImage.Dispose();

            return(true);
            //}
            //catch (Exception ex)
            //{
            //    return false;
            //}
        }
コード例 #2
0
        public static void ProcessAAFPhoto(Member member, AskAFriend AAF, Image image, int IndexOrder)
        {
            string GlobalWebID = UniqueID.NewWebID();
            string FileName    = GlobalWebID + @".jpg";

            AskAFriendPhoto photo = new AskAFriendPhoto();

            photo.AskAFriendID = AAF.AskAFriendID;
            photo.IndexOrder   = IndexOrder;

            //create the medium
            ResourceFile PhotoResourceFile = new ResourceFile();

            PhotoResourceFile.WebResourceFileID = GlobalWebID;
            PhotoResourceFile.ResourceType      = (int)ResourceFileType.AAFLarge;
            PhotoResourceFile.Path     = member.NickName + "/" + "aaflrge" + "/";
            PhotoResourceFile.FileName = FileName;
            PhotoResourceFile.Save();
            System.Drawing.Image MediumImage = Photo.Resize480x480(image);
            Photo.SaveToDisk(MediumImage, PhotoResourceFile.SavePath);

            photo.PhotoResourceFileID = PhotoResourceFile.ResourceFileID;

            //create the thumbnail
            ResourceFile ThumbnailPhoto = new ResourceFile();

            ThumbnailPhoto.WebResourceFileID = GlobalWebID;
            ThumbnailPhoto.ResourceType      = (int)ResourceFileType.AAFThumbnail;
            ThumbnailPhoto.Path     = member.NickName + "/" + "aafthmb" + "/";
            ThumbnailPhoto.FileName = FileName;
            ThumbnailPhoto.Save();
            System.Drawing.Image ThumbnailImage = Photo.ResizeTo124x91(MediumImage);
            Photo.SaveToDisk(ThumbnailImage, ThumbnailPhoto.SavePath);

            photo.Save();

            if (IndexOrder == 1)
            {
                AAF.DefaultPhotoResourceFileID = ThumbnailPhoto.ResourceFileID;
            }

            AAF.Save();
        }
コード例 #3
0
        /// <summary>
        /// Sets the thumbnail for a Video
        /// </summary>
        /// <param name="Thumbnail"></param>
        public void SetLiveThumbnail(Image Thumbnail)
        {
            Image  Resized = Photo.ResizeTo124x91(Thumbnail);
            Member member  = new Member(this.MemberID);

            ResourceFile thumbnailRes = new ResourceFile();

            thumbnailRes.WebResourceFileID = Misc.UniqueID.NewWebID();
            thumbnailRes.ResourceType      = (int)ResourceFileType.VideoThumbnail;
            thumbnailRes.FileName          = member.NickName + "/" + thumbnailRes.WebResourceFileID + ".jpg";

            string ThumbnailSaveLocation = member.NickName + @"\vthmb\" + thumbnailRes.WebResourceFileID + ".jpg";

            Photo.SaveToDisk(Resized, ThumbnailSaveLocation);

            thumbnailRes.Save();

            //need to add this to the LiveBroadcast table
            this.ThumbnailResourceFileID = thumbnailRes.ResourceFileID;
            this.Save();
        }
コード例 #4
0
        public static NSpot ProcessNSpotPhoto(Member member, NSpot nSpot, Image image)
        {
            Database      db          = DatabaseFactory.CreateDatabase();
            DbConnection  conn        = db.CreateConnection();
            DbTransaction Transaction = null;

            try
            {
                conn.Open();
                Transaction = conn.BeginTransaction();

                string GlobalWebID = UniqueID.NewWebID();
                string FileName    = GlobalWebID + @".jpg";

                // create the large photo
                // just store the large image.. dont make a resource record
                System.Drawing.Image MainImage = Photo.Resize480x480(image);
                string Savepath = member.NickName + @"\" + "nslrge" + @"\" + FileName;
                Photo.SaveToDisk(MainImage, Savepath);

                //create the medium
                ResourceFile PhotoResourceFile = new ResourceFile();
                PhotoResourceFile.CreatedDT         = DateTime.Now;
                PhotoResourceFile.WebResourceFileID = GlobalWebID;
                PhotoResourceFile.ResourceType      = (int)ResourceFileType.NspotPhoto;
                PhotoResourceFile.Path     = member.NickName + "/" + "nsmed" + "/";
                PhotoResourceFile.FileName = FileName;
                PhotoResourceFile.Save(db);
                System.Drawing.Image MediumImage = Photo.Resize190x130(MainImage);
                Photo.SaveToDisk(MediumImage, PhotoResourceFile.SavePath);

                //create the thumbnail
                ResourceFile ThumbnailResourceFile = new ResourceFile();
                ThumbnailResourceFile.CreatedDT         = DateTime.Now;
                ThumbnailResourceFile.WebResourceFileID = GlobalWebID;
                ThumbnailResourceFile.ResourceType      = (int)ResourceFileType.NspotThumbnail;
                ThumbnailResourceFile.Path     = member.NickName + "/" + "nsthmb" + "/";
                ThumbnailResourceFile.FileName = FileName;
                ThumbnailResourceFile.Save(db);
                System.Drawing.Image ThumbnailImage = Photo.ResizeTo124x91(MediumImage);
                Photo.SaveToDisk(ThumbnailImage, ThumbnailResourceFile.SavePath);

                // attached the resource ids to the photos
                nSpot.ThumbnailResourceFileID = ThumbnailResourceFile.ResourceFileID;
                nSpot.PhotoResourceFileID     = PhotoResourceFile.ResourceFileID;

                nSpot.Save(db);

                Transaction.Commit();
            }
            catch (Exception ex)
            {
                Transaction.Rollback();
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(nSpot);
        }