Esempio n. 1
0
        static public Bitmap CreateImageFromRGB(int width, int height, byte[] data)
        {
            Bitmap pic = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            //convert to 3d array to represent the image
            //outer bound  length represents the height
            //mid bound length represents the width
            //inner bound represents rgb value
            byte [,,] imageData = DataStructureConverter.Convert1dArrayTo3d <byte>(data, height, width, 3);

            for (int y = 0; y < imageData.GetLength(0); y++)
            {
                for (int x = 0; x < imageData.GetLength(1); x++)
                {
                    List <byte> rgbValues = new List <byte>();
                    //get rgb value
                    for (int k = 0; k < imageData.GetLength(2); k++)
                    {
                        rgbValues.Add(imageData[y, x, k]);
                    }

                    Color color = Color.FromArgb(
                        255,
                        rgbValues[0],
                        rgbValues[1],
                        rgbValues[2]
                        );


                    //draw pixel on coordinate x,y
                    pic.SetPixel(x, y, color);
                }
            }
            return(pic);
        }
Esempio n. 2
0
        static public async Task <Bitmap> CreateLineOrMarkerPlot(LineOrMarkerAttributes attributes)
        {
            await FlaskApi.PutRequest(ApiEndpointConfigurations.lineOrMarkerPlotterApiEndPoint, attributes.PlotToKeyAndArguments());

            Dictionary <string, object> result = await FlaskApi.GetRequest(ApiEndpointConfigurations.lineOrMarkerPlotterApiEndPoint, printResponse : false);



            string imageDataInString      = result[ApiEndpointConfigurations.plotImageData_key] as string;
            string imageDimensionInString = result[ApiEndpointConfigurations.plotImageShape_key] as string;

            #region getting image Shape
            //(height,width ,3)
            int[] imageShape = DataStructureConverter.ConvertArrayInStringToArrayOfInt(imageDimensionInString);
            int   height     = imageShape[0];
            int   width      = imageShape[1];

            #endregion

            #region getting bitmap

            byte[] imageData = DataStructureConverter.ConvertArrayInStringToArrayOfByte(imageDataInString);

            //make bitmap
            Bitmap bitmap = MyImageLibrary.CreateImageFromRGB(width, height, imageData);
            #endregion


            return(bitmap);
        }
Esempio n. 3
0
        static public async Task <Bitmap> CreateScatterPlot(ScatterAttributes attributes)
        {
            await FlaskApi.PutRequest(ApiEndpointConfigurations.scatterPlotterApiEndPoint, new Dictionary <string, string>
            {
                { "xColumnName", attributes.XColumnName },
                { "yColumnName", attributes.YColumnName },
                { "plotName", attributes.PlotName },
                { "xLabel", attributes.XLabel },
                { "xAxisLabelColor", JsonConvert.SerializeObject(MyImageLibrary.ConvertColorToRGBA(attributes.XAxisLabelColor)) },
                { "barColor", JsonConvert.SerializeObject(MyImageLibrary.ConvertColorToRGBA(attributes.DotColor)) },
                { "yLabel", attributes.YLabel },
                { "yAxisLabelColor", JsonConvert.SerializeObject(MyImageLibrary.ConvertColorToRGBA(attributes.YAxisLabelColor)) },
                { "plotNameColor", JsonConvert.SerializeObject(MyImageLibrary.ConvertColorToRGBA(attributes.PlotNameColor)) },

                { "bottomSpineColor", JsonConvert.SerializeObject(MyImageLibrary.ConvertColorToRGBA(attributes.BottomSpineColor)) },
                { "topSpineColor", JsonConvert.SerializeObject(MyImageLibrary.ConvertColorToRGBA(attributes.TopSpineColor)) },
                { "leftSpineColor", JsonConvert.SerializeObject(MyImageLibrary.ConvertColorToRGBA(attributes.LeftSpineColor)) },
                { "rightSpineColor", JsonConvert.SerializeObject(MyImageLibrary.ConvertColorToRGBA(attributes.RightSpineColor)) },

                { "figureBackgroundColor", JsonConvert.SerializeObject(MyImageLibrary.ConvertColorToRGBA(attributes.FigureBackgroundColor)) },
                { "axesBackgroundColor", JsonConvert.SerializeObject(MyImageLibrary.ConvertColorToRGBA(attributes.AxesBackgroundColor)) },
            });

            Dictionary <string, object> result = await FlaskApi.GetRequest(ApiEndpointConfigurations.scatterPlotterApiEndPoint, printResponse : false);



            string imageDataInString      = result[ApiEndpointConfigurations.plotImageData_key] as string;
            string imageDimensionInString = result[ApiEndpointConfigurations.plotImageShape_key] as string;

            #region getting image Shape
            //(height,width ,3)
            int[] imageShape = DataStructureConverter.ConvertArrayInStringToArrayOfInt(imageDimensionInString);
            int   height     = imageShape[0];
            int   width      = imageShape[1];

            #endregion

            #region getting bitmap

            byte[] imageData = DataStructureConverter.ConvertArrayInStringToArrayOfByte(imageDataInString);

            //make bitmap
            Bitmap bitmap = MyImageLibrary.CreateImageFromRGB(width, height, imageData);
            #endregion


            return(bitmap);
        }
Esempio n. 4
0
        static public async Task ReadAndInitializeCsv(string csvFilePath)
        {
            CsvReader.csvFilePath = csvFilePath;



            await FlaskApi.PutRequest(ApiEndpointConfigurations.csvReaderApiEndPoint, new Dictionary <string, string>
            {
                { "csvFilePath", csvFilePath },
            });


            Dictionary <string, object> result = await FlaskApi.GetRequest(ApiEndpointConfigurations.csvReaderApiEndPoint);



            //result should be an array of the columns in string data types
            string columnsString = result[ApiEndpointConfigurations.csvColumn_key] as string;

            CsvReader.columns = DataStructureConverter.ConvertStringToArrayOfString(columnsString);
        }