Пример #1
0
        private async void OnSaveFileButtonClick(object sender, RoutedEventArgs eventArgs)
        {
            if (CurrentBitmap == null || Working)
            {
                return;
            }
            string path = await GetSaveImagePath();

            if (path != null && path != "")
            {
                if (!path.Contains("."))
                {
                    path += ".png";
                }
                CurrentBitmap.Save(path);
            }
        }
Пример #2
0
        /// <summary>
        /// Reads the stream to the end, providing progress information along the way
        /// </summary>
        /// <param name="progressCallback">a callback that will be called each time there is a new frame available</param>
        /// <returns>The complete video in its in fully expanded in memory structure</returns>
        public InMemoryConsoleBitmapVideo ReadToEnd(Action <InMemoryConsoleBitmapVideo> progressCallback = null)
        {
            var ret = new InMemoryConsoleBitmapVideo();

            while (ReadFrame().CurrentFrame != null)
            {
                ret.Frames.Add(new InMemoryConsoleBitmapFrame()
                {
                    Bitmap    = CurrentBitmap.Clone(), // clone the current frame since we paint over it every time
                    FrameTime = CurrentFrame.Timestamp,
                });

                // Duration will be set after the first frame is read so no need to check HasValue
                ret.LoadProgress = CurrentFrame.Timestamp.TotalSeconds / Duration.Value.TotalSeconds;
                ret.Duration     = Duration.Value; // proxy the known duration to the video object so the progress callback can get at it
                progressCallback?.Invoke(ret);
            }

            return(ret);
        }
Пример #3
0
        public Bitmap loadBitmap(string filename, out OGL.PixelInternalFormat pif, out OGL.PixelFormat pf, out OGL.PixelType pt)
        {
            filename = Path.GetFullPath(filename);
            if (File.Exists(filename) == false)
            {
                throw new Exception("File " + filename + " does not exist");
            }

            Bitmap CurrentBitmap = null;

            try // Exceptions will be thrown if any Problem occurs while working on the file.
            {
                if (Path.GetExtension(filename) == ".pcx")
                {
                    CurrentBitmap = PCX.load(filename);
                }
                else
                {
                    CurrentBitmap = new Bitmap(filename);
                }

                evalBitmap(CurrentBitmap, out pif, out pf, out pt);

                //flip the image since it's backwards from what opengl expects
                if (myFlip == true)
                {
                    CurrentBitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
                }

                return(CurrentBitmap);
            }

            catch (Exception e)
            {
                throw new Exception("Texture Loading Error: Failed to read file " + filename + ": " + e.Message);
            }
        }