Beispiel #1
0
        /// <summary>
        /// Used to save image, produced by R
        /// </summary>
        /// <param name="fileName">Specify image name</param>
        /// <param name="width">Image width</param>
        /// <param name="height">Image height</param>
        /// <param name="dpi">Dots per inch</param>
        public static async Task <bool> SavePlotImage(IRHostSession session, string fileName, int width, int height, int dpi)
        {
            byte[] dataImgArray = await session.PlotAsync("forec", width, height, dpi);

            Bitmap dataImgFile;

            using (MemoryStream memoryStream = new MemoryStream(dataImgArray))
            {
                dataImgFile = new Bitmap(memoryStream);
            }
            dataImgFile.Save(fileName);
            return(true);
        }
Beispiel #2
0
        private async void plotButton_Click(object sender, EventArgs e)
        {
            try {
                await _sessionStartTask;
                var   data = await _session.PlotAsync(codeBox.Text, 640, 480, 96);

                var pb = new PictureBox();
                pb.SizeMode = PictureBoxSizeMode.StretchImage;
                pb.Image    = new Bitmap(new MemoryStream(data));
                DisplayResult(pb);
            } catch (Exception ex) {
                DisplayResult(ex.Message);
            }
        }
Beispiel #3
0
        public async Task PlotAsync()
        {
            var data = await _session.PlotAsync("c(1:10)", 480, 480, 72);

            data.Length.Should().BeGreaterThan(0);
        }