Esempio n. 1
0
        public void SetupTransition(int code)
        {
            if (Task == 100)
            {
                Task   = -1;
                Result = 0;

                EraseTransition();
                if (Transition == null)
                {
                    Transition = new Bitmap[Steps + 1];
                }
                for (int i = 0; i <= Steps; ++i)
                {
                    Transition[i] = new Bitmap(Width, Height);
                    ImageOps.SetOpacity(LogoScreen, LogoScreen, ref Transition[i], 0, Width, Height);
                }

                return;
            }

            if (Task == 4 && Stage == TaskStage.TS_ANSWER)
            {
                Bitmap startingBitmap = new Bitmap(Transition.Last());
                ImageOps.SetupTransition(startingBitmap, Results[Result], ref Transition, Steps, Width, Height);
                Task = 100;
                startingBitmap.Dispose();
                return;
            }

            if (Task == -1 || Stage == TaskStage.TS_ANSWER)
            {
                NextRandomTask();
                Bitmap startingBitmap = new Bitmap(Transition.Last());
                ImageOps.SetupTransition(startingBitmap, TasksStorage.AllTasks[Task][SubTask].TaskImage, ref Transition, Steps, Width, Height);
                Stage = TaskStage.TS_DESCRIPTION;
                startingBitmap.Dispose();
                return;
            }

            if (Stage == TaskStage.TS_DESCRIPTION)
            {
                if (TasksStorage.AllTasks[Task][SubTask].RightAnswer == code)
                {
                    ++Result;
                }

                Stage = TaskStage.TS_ANSWER;
                TasksStorage.AllTasks[Task][SubTask].GetTransition(code - 1, ref Transition);
                return;
            }
        }
        public async Task <IActionResult> UploadSegmentation([FromBody] JObject postdata)
        {
            var prefix   = JsonUtils.GetString(Constants.PrefixEntry, postdata);
            var metadata = await GetMetadata(prefix);

            var name = JsonUtils.GetString("name", postdata);
            var ret  = ValidateName(postdata, metadata, name);

            if (!Object.ReferenceEquals(ret, null))
            {
                return(ret);
            }
            var overlayBase64 = JsonUtils.GetString("overlay", postdata);
            var segBase64     = JsonUtils.GetString("seg", postdata);

            overlayBase64 = overlayBase64.FromJSBase64();
            segBase64     = segBase64.FromJSBase64();

            var container = CloudStorage.GetContainer(null);
            var dirPath   = container.GetDirectoryReference(prefix);

            var segBytes = Convert.FromBase64String(segBase64);
            var basename = name.Split('.')[0];
            var segBlob  = dirPath.GetBlockBlobReference("seg_" + basename + ".png");
            await segBlob.UploadFromByteArrayAsync(segBytes, 0, segBytes.Length);

            var overlayBlob = dirPath.GetBlockBlobReference("overlay_" + name);

            var overlayImage = ImageOps.FromBase64(overlayBase64, _logger);
            var overlayJpeg  = overlayImage.ToJPEG();

            await overlayBlob.UploadFromByteArrayAsync(overlayJpeg, 0, overlayJpeg.Length);

            _logger.LogInformation($"UploadSegmentation update segment {segBytes.Length} && overlay image {overlayJpeg.Length}");



            return(Ok());
        }
Esempio n. 3
0
        private void ConvertImageFiles()
        {
            ImageFormat format = null;

            string[] inputFileMasks = null;
            int      totalFiles     = 0;

            //Make sure we have all the information we need to proceed and that it's valid.  If not, bail.
            if (!OKToProceed())
            {
                return;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;

                //Disable input controls
                ToggleInputEnable(false);

                //If the input path ends with a backslash, remove it
                txtImageDirectory.Text = txtImageDirectory.Text.Trim();
                if (txtImageDirectory.Text.EndsWith("\\"))
                {
                    txtImageDirectory.Text.TrimEnd('\\');
                }

                //Get the selected image format and associated filemasks
                format         = GetSelectedOutputImageFormat();
                inputFileMasks = ImageOps.GetFileMasks(cboSourceTypes.Text);

                //Get the total number of files we will be converting

                totalFiles = GetFileCount(txtImageDirectory.Text, inputFileMasks, chkIncludeSubDirs.Checked);

                //If there are no files to convert, alert the user and bail.  Otherwise, set up the progress bar.
                if (totalFiles == 0)
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("There are no files of the type you specified in the chosen directory.",
                                    "No files to convert", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    prgStatus.Value   = 0;
                    prgStatus.Maximum = totalFiles;
                }

                lblStatus.Text = "Beginning conversion";

                ImageOps.ConvertImages(txtImageDirectory.Text,
                                       chkIncludeSubDirs.Checked,
                                       inputFileMasks,
                                       format,
                                       chkDeleteAfterConvert.Checked);

                prgStatus.Value = prgStatus.Maximum;

                this.Cursor    = Cursors.Default;
                lblStatus.Text = "Conversion complete";
                MessageBox.Show("Done!", "Conversion complete!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                lblStatus.Text = "ERROR";
                this.Cursor    = Cursors.Default;
                MessageBox.Show("An error has occurred:\n\n" + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                ToggleInputEnable(true);
            }
        }