示例#1
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string       email = txtEmail.Text;
                ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_email == email);
                if (f != null)
                {
                    int    id       = f.CC_Id;
                    string name     = txtname.Text;
                    string password = txtPassword.Text;
                    var    path     = MapPath("~/pic/profile/");
                    string phone    = txtPhoneNumber.Text;
                    int    n        = Convert.ToInt32(phone);
                    if (fuImage.HasFile)
                    {
                        File.Delete(path + id + ".jpg");
                        var img = new SimpleImage(fuImage.FileContent);
                        img.SaveAs(path + id + ".jpg");
                    }


                    f.CC_NickName = txtname.Text;
                    f.CC_hash     = Security.GetHash(password);
                    //f.CC_email = email;
                    f.CC_phone = phone;
                    db.SubmitChanges();
                }
                ;



                Response.Redirect("~/home.aspx");
            }
        }
示例#2
0
        void L1opticalFlowforPictures()
        {
            int i = 0;

            opticalFlow.Height   = inputImage_1.ImageHeight;
            opticalFlow.Width    = inputImage_1.ImageWidth;
            opticalFlow.Array    = new float[2][];
            opticalFlow.Array[0] = new float[opticalFlow.Width * opticalFlow.Height];
            opticalFlow.Array[1] = new float[opticalFlow.Width * opticalFlow.Height];

            sw.Start();
            opticalFlow = L1flow.TV_L1_opticalFlow(inputImage_1.Bitmap, inputImage_2.Bitmap, out i);
            sw.Stop();
            label10.Text    = String.Format("Run time: {0} [s]", Convert.ToString(sw.Elapsed.TotalSeconds));
            label10.Visible = true;
            float[] length = _CLProcessor.calcFlowLength(opticalFlow);
            label11.Text      = String.Format("Max value: {0} [pixel/frame transition]", Convert.ToString(length.Max()));
            OutputImage       = _CLProcessor.decorateFlowColor(inputImage_1.Bitmap, opticalFlow, L1flow.flowInterval, L1flow.threshold);
            pictureBox3.Image = OutputImage.Bitmap;
            sw.Reset();

            // label12.Text = String.Format(Convert.ToString(i));
            //label11.Visible = true;
            //label12.Visible = true;
            saveToolStripMenuItem.Enabled = true;
        }
示例#3
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string email = txtEmail.Text;
                admin  f     = db.admins.SingleOrDefault(x => x.A_email == email);
                if (f != null)
                {
                    int    id       = f.A_Id;
                    var    path     = MapPath("~/pic/profile/");
                    string password = txtPassword.Text;


                    if (fuImage.HasFile)
                    {
                        File.Delete(path + id + ".jpg");
                        var img = new SimpleImage(fuImage.FileContent);
                        img.SaveAs(path + id + ".jpg");
                    }

                    f.A_Nickname = txtname.Text;
                    f.A_hash     = Security.GetHash(password);
                    //f.A_email = email;
                    f.A_gender = Char.Parse(rblGender.SelectedValue);

                    db.SubmitChanges();
                }
                ;



                Response.Redirect("../home.aspx");
            }
        }
示例#4
0
        private void connection_OnMapReceived(SimpleImage mapImage)
        {
            try
            {
                var map = mapImage.Bytes.ToImage();

                // Since we received a new map, we'll automatically black out everything with fog until the Server tells us otherwise.
                this.fog = new Bitmap(map.Width, map.Height);
                using (var g = Graphics.FromImage(this.fog))
                    g.Clear(fogColor);

                this.receivedMap = map;
                this.assignedMap = new Bitmap(map, (int)(map.Width * assignedScaleFactor),
                                              (int)(map.Height * assignedScaleFactor));
                this.receivedMapWidth  = this.receivedMap.Width;
                this.receivedMapHeight = this.receivedMap.Height;

                pbxMap.BeginInvoke((new Action(() =>
                {
                    pbxMap.Image = this.assignedMap;
                    pbxMap.Refresh();
                })));
            }
            catch (Exception e)
            {
                Logger.LogError("Map Received Failure", e);
            }
        }
 protected void btnUpload_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         int    randomId = 0;
         Random random   = new Random();
         bool   repeatId = false;
         var    path     = MapPath("~/pic/slideshow/");
         do
         {
             randomId = random.Next(10000, 9999999);
             var pro = db.slideshows.SingleOrDefault(
                 b => b.S_Id == randomId);
             if (pro == null)
             {
                 repeatId = true;
             }
         } while (repeatId == false);
         var img = new SimpleImage(fuPicture.FileContent);
         img.SaveAs(path + randomId + ".jpg");
         slideshow s = new slideshow
         {
             S_Id    = randomId,
             S_Title = txtTitle.Text,
             S_link  = txtLink.Text
         };
         db.slideshows.InsertOnSubmit(s);
         db.SubmitChanges();
     }
 }
        protected void AddBtn_Click(object sender, EventArgs e)
        {
            if (Prod_ImgValidation.IsValid && NameValidator.IsValid && DescValidator.IsValid && QtyEmptyValidator.IsValid && QtyValidator.IsValid && PriceEmptyValidator.IsValid && PriceValidator.IsValid)
            {
                Product p = new Product
                {
                    Id          = Security.GenerateNewID('P'),
                    Name        = Name.Text,
                    Description = LineBreaksConvert.LineBreaksTextToDB(Description.Text),
                    Quantity    = int.Parse(Qty.Text),
                    Price       = decimal.Parse(Price.Text),
                    Active      = true,
                    Seller_Id   = UserInfo.Id
                };

                Global.db.Products.InsertOnSubmit(p);
                Global.db.SubmitChanges();

                var path = MapPath("~/Broadcaster/Product_Image/");
                var img  = new SimpleImage(Img_File.FileContent);
                img.SaveAs(path + p.Id + ".jpg");

                Response.RedirectPermanent("~/Broadcaster/ProductInfo.aspx?id=" + p.Id);
            }
        }
示例#7
0
        public List <RecognitionResult> RecognizeImage(Bitmap image)
        {
            recognitionProgress = 0;
            isRecognizing       = true;

            var imageToRecognize = new SimpleImage(image);

            recognitionProgress = 0.05;

            var regions = new List <Rectangle>();
            var samples = new List <TextureSample>();

            SplitImage(imageToRecognize, samples, regions);

            var matches = new List <RecognitionResult>();

            for (int i = 0; i < samples.Count; ++i)
            {
                var answer = GetBestMatch(samples[i], regions[i]);
                matches.Add(answer);
                recognitionProgress = 0.95 + (0.05 * i) / samples.Count;
            }

            recognitionProgress = 1;
            isRecognizing       = false;
            return(matches);
        }
示例#8
0
        public MainScreen(IDictionary <Type, object> managers)
            : base(managers)
        {
            _background           = ResourceManager.GetSprite("mainbg_filler");
            _background.Smoothing = Smoothing.Smooth;

            _btnConnect = new ImageButton
            {
                ImageNormal = "connect_norm",
                ImageHover  = "connect_hover"
            };
            _btnConnect.Clicked += _buttConnect_Clicked;

            _btnOptions = new ImageButton
            {
                ImageNormal = "options_norm",
                ImageHover  = "options_hover"
            };
            _btnOptions.Clicked += _buttOptions_Clicked;

            _btnExit = new ImageButton
            {
                ImageNormal = "exit_norm",
                ImageHover  = "exit_hover"
            };
            _btnExit.Clicked += _buttExit_Clicked;

            _txtConnect = new Textbox(100, ResourceManager)
            {
                Text = ConfigurationManager.GetServerAddress()
            };
            _txtConnect.OnSubmit += ConnectTextboxOnSubmit;

            Assembly        assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);

            _lblVersion            = new Label("v. " + fvi.FileVersion, "CALIBRI", ResourceManager);
            _lblVersion.Text.Color = Color.WhiteSmoke;
            _lblVersion.Position   = new Point(Gorgon.Screen.Width - _lblVersion.ClientArea.Width - 3,
                                               Gorgon.Screen.Height - _lblVersion.ClientArea.Height - 3);

            _imgTitle = new SimpleImage
            {
                Sprite   = "SpaceStationLogoColor",
                Position = new Point(Gorgon.Screen.Width - 550, 100)
            };

            _lblVersion.Update(0);
            _imgTitle.Update(0);
            _txtConnect.Position = new Point(_imgTitle.ClientArea.Left + 40, _imgTitle.ClientArea.Bottom + 50);
            _txtConnect.Update(0);
            _btnConnect.Position = new Point(_txtConnect.Position.X, _txtConnect.ClientArea.Bottom + 20);
            _btnConnect.Update(0);
            _btnOptions.Position = new Point(_btnConnect.Position.X, _btnConnect.ClientArea.Bottom + 20);
            _btnOptions.Update(0);
            _btnExit.Position = new Point(_btnOptions.Position.X, _btnOptions.ClientArea.Bottom + 20);
            _btnExit.Update(0);
        }
示例#9
0
 public SplitImageThreadParameter(SimpleImage image, int from, int to, List <Rectangle> regions,
                                  List <TextureSample> samples, ManualResetEvent resetEvent)
 {
     Image         = image;
     From          = from;
     To            = to;
     ResultRegions = regions;
     ResultSamples = samples;
     ResetEvent    = resetEvent;
 }
示例#10
0
 private void connection_OnFogReceived(SimpleImage fogImage)
 {
     try
     {
         var newFog = fogImage.Bytes.ToImage();
         this.ctlDnDMap.SetFogAsync(newFog);
     }
     catch (Exception e)
     {
         Logger.LogError("Fog received failure.", e);
     }
 }
示例#11
0
        public FlowArray calcOpticalFlow(Bitmap image0, Bitmap image1, out int realiteration)

        {
            SimpleImage Image0      = new SimpleImage(image0);
            SimpleImage Image1      = new SimpleImage(image1);
            FlowArray   opticalFlow = new FlowArray();

            opticalFlow.Height   = Image1.ImageHeight;
            opticalFlow.Width    = Image1.ImageWidth;
            opticalFlow.Array    = new float[2][];
            opticalFlow.Array[0] = new float[opticalFlow.Width * opticalFlow.Height];
            opticalFlow.Array[1] = new float[opticalFlow.Width * opticalFlow.Height];


            float[][] J = new float[6][];
            J[0] = new float[opticalFlow.Width * opticalFlow.Height];
            J[1] = new float[opticalFlow.Width * opticalFlow.Height];
            J[2] = new float[opticalFlow.Width * opticalFlow.Height];
            J[3] = new float[opticalFlow.Width * opticalFlow.Height];
            J[4] = new float[opticalFlow.Width * opticalFlow.Height];



            float errorValue = threshold;
            int   i          = 0;

            if (sigma == 0)
            {
                while (!((i == iteration)))
                {
                    opticalFlow = calcLocalGlobalOpticalFlow(Image0, Image1, opticalFlow);

                    i++;
                }
            }

            if (sigma != 0)
            {
                J = calc_J(Image0, Image1);
                J = Gauss_J(J, Image0.ImageWidth, Image0.ImageHeight);


                while (!((i == iteration)))
                {
                    opticalFlow = calcLocalGlobalOpticalFlow_withSmoothed_J(J, opticalFlow);


                    i++;
                }
            }
            realiteration = i;
            return(opticalFlow);
        }
示例#12
0
 private void connection_OnMapReceived(SimpleImage mapImage)
 {
     try
     {
         // Since we received a new map, we'll automatically black out everything with fog until the Server tells us otherwise.
         var newMap = mapImage.Bytes.ToImage();
         this.ctlDnDMap.SetMapAsync(newMap);
     }
     catch (Exception e)
     {
         Logger.LogError("Map Received Failure", e);
     }
 }
示例#13
0
        public MainScreen(IDictionary <Type, object> managers) : base(managers)
        {
            _Width      = (int)CluwneLib.Screen.Size.X;
            _Height     = (int)CluwneLib.Screen.Size.Y;
            _background = ResourceCache.GetSprite("ss14_logo_background");

            _btnConnect = new ImageButton
            {
                ImageNormal = "connect_norm",
                ImageHover  = "connect_hover"
            };
            _btnConnect.Clicked += _buttConnect_Clicked;

            _btnOptions = new ImageButton
            {
                ImageNormal = "options_norm",
                ImageHover  = "options_hover"
            };
            _btnOptions.Clicked += _buttOptions_Clicked;

            _btnExit = new ImageButton
            {
                ImageNormal = "exit_norm",
                ImageHover  = "exit_hover"
            };
            _btnExit.Clicked += _buttExit_Clicked;

            _txtConnect = new Textbox(100, ResourceCache)
            {
                Text = ConfigurationManager.GetCVar <string>("net.server")
            };
            _txtConnect.Position  = new Vector2i(_Width / 3, _Height / 2);
            _txtConnect.OnSubmit += ConnectTextboxOnSubmit;

            Assembly        assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);

            _lblVersion            = new Label("v. " + fvi.FileVersion, "CALIBRI", ResourceCache);
            _lblVersion.Text.Color = new Color4(245, 245, 245, 255);

            _lblVersion.Position = new Vector2i(_Width - _lblVersion.ClientArea.Width - 3,
                                                _Height - _lblVersion.ClientArea.Height - 3);

            _imgTitle = new SimpleImage
            {
                Sprite = "ss14_logo",
            };

            FormResize();
        }
示例#14
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            int          randomId;
            Random       random   = new Random();
            bool         repeatId = false;
            string       email    = HttpContext.Current.User.Identity.Name;
            ComicCreator f        = db.ComicCreators.SingleOrDefault(x => x.CC_email.ToString() == email);
            int          id       = f.CC_Id;

            if (Page.IsValid)
            {
                do
                {
                    randomId = random.Next(100000, 99999999);
                    var b = db.Comics.SingleOrDefault(
                        cc => cc.C_Id == randomId);
                    if (b == null)
                    {
                        repeatId = true;
                    }
                } while (repeatId == false);

                string p      = "~/pic/comic/" + randomId + "/";
                var    folder = Server.MapPath(p);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                var img = new SimpleImage(fuImage.FileContent);
                img.SaveAs(folder + randomId + ".jpg");

                Comic c = new Comic
                {
                    C_Id           = randomId,
                    C_Title        = txtTitle.Text,
                    C_Description  = txtDescription.Text,
                    C_Price        = decimal.Parse(txtPrice.Text),
                    C_Publish_Date = DateTime.Now,
                    C_Status       = 'U',
                    C_category     = ddlCategory.SelectedValue,
                    C_AgeRestrict  = int.Parse(ddlAgeRestrt.SelectedValue),
                    C_IsForVip     = bool.Parse(rblVipView.SelectedValue),
                    CC_Id          = id
                };
                db.Comics.InsertOnSubmit(c);
                db.SubmitChanges();
                Response.Redirect("~/Comic.aspx");
            }
        }
示例#15
0
        private void Button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string imagePath;
                imagePath = ofd.FileName;

                Bitmap inputBitmap;
                inputBitmap       = _ImageFileHandler.GetImageFromFile(imagePath);
                inputImage_2      = new SimpleImage(inputBitmap);
                pictureBox2.Image = inputImage_2.Bitmap;
            }
        }
示例#16
0
        void HSopticalFlowwithPyramid()
        {
            sw.Start();
            opticalFlow = HornSchunck.HS_pyramidical_opticalFlow(inputImage_1, inputImage_2);
            sw.Stop();
            label9.Text    = String.Format("Run time: {0} [s]", Convert.ToString(sw.Elapsed.TotalSeconds));
            label9.Visible = true;
            float[] length = _CLProcessor.calcFlowLength(opticalFlow);
            label18.Text = String.Format("Max value: {0} [pixel/frame transition]", Convert.ToString(length.Max()));

            OutputImage       = _CLProcessor.decorateFlowColor(inputImage_1.Bitmap, opticalFlow, HornSchunck.flowInterval, HornSchunck.threshold);
            pictureBox3.Image = OutputImage.Bitmap;
            sw.Reset();
            saveToolStripMenuItem.Enabled = true;
        }
示例#17
0
        private void calcHornSchunck_video()
        {
            FlowArray opticalFlow = new FlowArray();

            opticalFlow.Height   = input1bitmap.Height;
            opticalFlow.Width    = input1bitmap.Width;
            opticalFlow.Array    = new float[2][];
            opticalFlow.Array[0] = new float[opticalFlow.Width * opticalFlow.Height];
            opticalFlow.Array[1] = new float[opticalFlow.Width * opticalFlow.Height];

            if (videoSelected)
            {
                while (!(image.Empty()))
                {
                    input1bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(image);
                    sw.Start();
                    for (int i = 0; i < 1; i++)
                    {
                        opticalFlow = HornSchunck.calculateOpticalFlow(input1bitmap, input2bitmap, out int k, opticalFlow);
                    }


                    OutputVideo = _CLProcessor.decorateFlowColor(input1bitmap, opticalFlow, HornSchunck.flowInterval, HornSchunck.threshold);
                    pictureBox4.Image.Dispose();
                    pictureBox5.Image.Dispose();

                    pictureBox4.Image = OutputVideo.Bitmap;
                    pictureBox5.Image = input1bitmap;

                    Application.DoEvents();
                    pictureBox4.Refresh();
                    pictureBox5.Refresh();
                    sw.Stop();
                    runTime        = 1 / (float)sw.Elapsed.TotalSeconds;
                    label9.Text    = String.Format("Frame rate: {0} [fps]", Convert.ToString(runTime));
                    label9.Visible = true;
                    sw.Reset();
                    input2bitmap = input1bitmap;
                    capture.Read(image);
                }
            }
            videoSelected = false;
            capture.Dispose();
            image.Dispose();
            pictureBox4.Image.Dispose();
            pictureBox5.Image.Dispose();
        }
        public override void receiveImage(SimpleImage theImage)
        {
            if (!m_isTextureInitialized)
            {
                m_imageWidth  = theImage.width;
                m_imageHeight = theImage.height;
                m_texWidth    = (int)Math.Pow(2, Math.Ceiling(Math.Log(m_imageWidth) / Math.Log(2)));
                m_texHeight   = (int)Math.Pow(2, Math.Ceiling(Math.Log(m_imageHeight) / Math.Log(2)));


                m_colorsCurrent = new Color32[m_texWidth * m_texHeight];
                m_colorsNext    = new Color32[m_texWidth * m_texHeight];

                m_textureInsetWidth  = ((float)m_screenWidth) / m_imageWidth * m_texWidth;
                m_textureInsetHeight = ((float)m_screenHeight) / m_imageHeight * m_texHeight;
                m_textureInsetX      = 0;
                m_textureInsetY      = 0;

                if (m_flipVertical)
                {
                    m_textureInsetHeight = -m_textureInsetHeight;
                    m_textureInsetY      = m_screenHeight;
                }

                if (m_flipHorizontal)
                {
                    m_textureInsetWidth = -m_textureInsetWidth;
                    m_textureInsetX     = m_screenWidth;
                }
            }

            //Profiler.StartProfile("updateTextureUsingPointer");

            //TextureUpdate.updateTextureUsingPointerFlipVertical(m_colorsNext, theImage, m_texWidth, m_texHeight, 255 );
            //TextureUpdate.updateTextureUsingPointer(m_colorsNext, theImage, m_texWidth, m_texHeight, 255 );

            //Profiler.EndProfile("updateTextureUsingPointer");

            lock (thisLock)
            {
                m_newImageData = true;
                Color32[] tmp = m_colorsCurrent;
                m_colorsCurrent = m_colorsNext;
                m_colorsNext    = tmp;
            }
        }
        private void connection_OnFogReceived(SimpleImage fogImage)
        {
            try
            {
                this.fog = fogImage.Bytes.ToImage();
                if (isBlackoutOn)
                {
                    return;
                }

                RefreshMapPictureBox();
            }
            catch (Exception e)
            {
                Logger.LogError("Fog received failure.", e);
            }
        }
示例#20
0
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            string  foodname  = txtfood.Text;
            decimal foodprice = decimal.Parse(txtfoodprice.Text);
            string  id;
            int     randomId;
            bool    repeatId = false;
            Random  random   = new Random();

            string path     = MapPath("~/Photos/");
            string filename = Guid.NewGuid().ToString("N") + ".jpeg";

            do
            {
                randomId = random.Next(10000, 999999);
                id       = "F" + randomId;
                var p = OneDB.Food_Lists.SingleOrDefault(
                    b => b.foodID == id);
                if (p == null)
                {
                    repeatId = true;
                }
            } while (repeatId == false);

            var img = new SimpleImage(FileUpload1.FileContent);

            img.Square();
            img.Resize(150);
            img.SaveAs(path + filename);

            Food_List fl = new Food_List
            {
                foodID     = id,
                foodName   = foodname,
                foodPrice  = foodprice,
                foodPhoto  = filename,
                foodStatus = "available"
            };

            OneDB.Food_Lists.InsertOnSubmit(fl);
            OneDB.SubmitChanges();

            displaystatus.Text = "The food has been added to food menu";
        }
示例#21
0
        void LGopticalFlowforPictures()
        {
            int i = 0;

            sw.Start();
            opticalFlow = LGflow.calcOpticalFlow(inputImage_1.Bitmap, inputImage_2.Bitmap, out i);
            sw.Stop();
            label9.Text    = String.Format("Run time: {0} [s]", Convert.ToString(sw.Elapsed.TotalSeconds));
            label9.Visible = true;
            float[] length = _CLProcessor.calcFlowLength(opticalFlow);
            label17.Text      = String.Format("Max value: {0} [pixel/frame transition]", Convert.ToString(length.Max()));
            OutputImage       = _CLProcessor.decorateFlowColor(inputImage_1.Bitmap, opticalFlow, LGflow.flowInterval, LGflow.threshold);
            pictureBox3.Image = OutputImage.Bitmap;
            sw.Reset();



            saveToolStripMenuItem.Enabled = true;
        }
示例#22
0
        private IObject <ObjectData> ProcessObjectTypeTag(ObjectTypeTag objectTypeTag)
        {
            IObject <ObjectData> newInstance;

            switch (objectTypeTag.Type)
            {
            case ObjectType.Image:
                newInstance = new Image(null);
                break;

            case ObjectType.Group:
                newInstance = new Group(null);
                break;

            case ObjectType.String:
                newInstance = new Text(null);
                break;

            case ObjectType.MultiImage:
                newInstance = new MultiImage(null);
                break;

            case ObjectType.ColoredImage:
                newInstance = new ColoredImage(null);
                break;

            case ObjectType.SimpleImage:
                newInstance = new SimpleImage(null);
                break;

            case ObjectType.Movie:
                newInstance = new Movie(null);
                break;

            default:
                throw new IndexOutOfRangeException($"cannot handle object type: {objectTypeTag.Type}");
            }

            newInstance.Type = objectTypeTag.Type;

            return(newInstance);
        }
示例#23
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string       email = HttpContext.Current.User.Identity.Name;
            ComicCreator f     = db.ComicCreators.SingleOrDefault(x => x.CC_email.ToString() == email);
            string       cid   = Request.QueryString["cId"];

            if (Page.IsValid)
            {
                if (!string.IsNullOrEmpty(cid))
                {
                    int    cId    = Int32.Parse(cid);
                    string p      = "~/pic/comic/" + cid + "/";
                    var    folder = Server.MapPath(p);
                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }
                    if (fuImage.HasFile)
                    {
                        File.Delete(folder + cid + ".jpg");
                        var img = new SimpleImage(fuImage.FileContent);
                        img.SaveAs(folder + cid + ".jpg");
                    }
                    Comic c = db.Comics.SingleOrDefault(a => a.C_Id == cId);
                    c.C_Title       = txtTitle.Text;
                    c.C_Description = txtDescription.Text;
                    c.C_Price       = decimal.Parse(txtPrice.Text);
                    c.C_category    = ddlCategory.SelectedValue;
                    c.C_AgeRestrict = Int32.Parse(ddlAgeRestrt.SelectedValue);
                    c.C_IsForVip    = bool.Parse(rblVipView.SelectedValue);

                    db.SubmitChanges();
                    Response.Redirect("~/DisplayComic.aspx?cId=" + cid);
                }
                else
                {
                    Response.Redirect("~/error.aspx?err=The result cant be found");

                    //redirect to the error page
                }
            }
        }
示例#24
0
        public List <RecognitionResult> RecognizeImages(List <Bitmap> images)
        {
            recognitionProgress = 0;
            isRecognizing       = true;

            var answers = new List <RecognitionResult>();

            for (int i = 0; i < images.Count; ++i)
            {
                var imageToRecognize = new SimpleImage(images[i]);
                var imageData        = imageToRecognize.GetGrayData(0, 0, imageToRecognize.Width, imageToRecognize.Height);
                var sample           = new TextureSample(imageData, false);
                answers.Add(GetBestMatch(sample, new Rectangle(0, 0, imageData.Width, imageData.Height)));
                recognitionProgress += 1.0 * i / images.Count;
            }

            recognitionProgress = 1;
            isRecognizing       = false;
            return(answers);
        }
示例#25
0
        public RecognitionResult RecognizeImage(Bitmap image, Rectangle region)
        {
            recognitionProgress = 0;
            isRecognizing       = true;

            var imageToRecognize = new SimpleImage(image);

            recognitionProgress = 0.2;

            var imageData = imageToRecognize.GetGrayData(region.X, region.Y,
                                                         region.X + region.Width, region.Y + region.Height);
            var sample = new TextureSample(imageData, false);

            recognitionProgress = 0.8;

            var answer = GetBestMatch(sample, region);

            recognitionProgress = 1;
            isRecognizing       = false;
            return(answer);
        }
示例#26
0
        private void connection_OnMapReceived(SimpleImage mapImage)
        {
            try
            {
                using (var stream = new MemoryStream(mapImage.Bytes))
                {
                    gameState.Map = Texture2D.FromStream(GraphicsDevice, stream);
                }

                //lock (newFogLock)
                //{
                //    // Since we received a new map, we'll automatically black out everything with fog until the Server tells us otherwise.
                //    this.newFog = new Texture2D(GraphicsDevice, newMap.Width, newMap.Height);
                //    this.newFog.SetData<Color>(Enumerable.Repeat(Color.Black, newMap.Width * newMap.Height).ToArray());
                //}
            }
            catch (Exception e)
            {
                Logger.LogError("Map Received Failure", e);
            }
        }
示例#27
0
        private void SplitImage(SimpleImage image, List <TextureSample> samples, List <Rectangle> regions)
        {
            int YCount           = image.Height / RecognitionParameters.RecognitionFragmentSize;
            int threadCount      = Math.Min(YCount, Environment.ProcessorCount * 2);
            int threadPart       = YCount / threadCount;
            var resetEvents      = new ManualResetEvent[threadCount + 1];
            var threadParameters = new SplitImageThreadParameter[threadCount + 1];

            for (int i = 0; i < threadCount; ++i)
            {
                resetEvents[i]      = new ManualResetEvent(false);
                threadParameters[i] = new SplitImageThreadParameter(
                    image, threadPart * i, ((i + 1) < threadCount) ? (threadPart * (i + 1)) : (YCount),
                    regions, samples, resetEvents[i]);
                ThreadPool.QueueUserWorkItem(new WaitCallback(SplitImageThread), threadParameters[i]);
            }
            resetEvents[threadCount]      = new ManualResetEvent(false);
            threadParameters[threadCount] = new SplitImageThreadParameter(
                image, 0, 0, regions, samples, resetEvents[threadCount]);
            ThreadPool.QueueUserWorkItem(new WaitCallback(SplitImageAdditionalThread), threadParameters[threadCount]);
            WaitHandle.WaitAll(resetEvents);
        }
示例#28
0
        public FlowArray LG_pyramidical_opticalFlow(SimpleImage Image0, SimpleImage Image1)
        {
            SimpleImage[][] pyramids     = cLProcessor.CreatePyramids(Image0, Image1, pyramidLevel);
            SimpleImage[]   leftPyramid  = pyramids[0];
            SimpleImage[]   rightPyramid = pyramids[1];

            FlowArray[] flows = new FlowArray[pyramidLevel];

            flows[pyramidLevel - 1] = calcOpticalFlow(leftPyramid[pyramidLevel - 1].Bitmap, rightPyramid[pyramidLevel - 1].Bitmap, out int k);

            SimpleImage warpImage = new SimpleImage();

            for (int i = 1; i < pyramidLevel; i++)
            {
                flows[pyramidLevel - (i + 1)] = FlowArray.Expand(flows[pyramidLevel - i], leftPyramid[pyramidLevel - (i + 1)].ImageWidth, leftPyramid[pyramidLevel - (i + 1)].ImageHeight);
                warpImage = cLProcessor.pushImagewithFlow(leftPyramid[pyramidLevel - (i + 1)], flows[pyramidLevel - (i + 1)]);
                FlowArray correction = calcOpticalFlow(warpImage.Bitmap, rightPyramid[pyramidLevel - (i + 1)].Bitmap, out k);
                flows[pyramidLevel - (i + 1)] = flows[pyramidLevel - (i + 1)] + correction;
            }

            return(flows[0]);
        }
示例#29
0
        private void calcL1_video()
        {
            if (videoSelected)
            {
                while (!(image.Empty()))
                {
                    input1bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(image);
                    sw.Start();

                    opticalFlow = L1flow.TV_L1_opticalFlow(input1bitmap, input2bitmap, out int k);



                    OutputVideo = _CLProcessor.decorateFlowColor(input1bitmap, opticalFlow, L1flow.flowInterval, L1flow.threshold);
                    pictureBox4.Image.Dispose();
                    pictureBox5.Image.Dispose();

                    pictureBox4.Image = OutputVideo.Bitmap;
                    pictureBox5.Image = input1bitmap;

                    Application.DoEvents();
                    pictureBox4.Refresh();
                    pictureBox5.Refresh();
                    sw.Stop();
                    runTime         = 1 / (float)sw.Elapsed.TotalSeconds;
                    label10.Text    = String.Format("Frame rate: {0} [fps]", Convert.ToString(runTime));
                    label10.Visible = true;
                    sw.Reset();
                    input2bitmap = input1bitmap;
                    capture.Read(image);
                }
            }
            videoSelected = false;
            capture.Dispose();
            image.Dispose();
            pictureBox4.Image.Dispose();
            pictureBox5.Image.Dispose();
        }
示例#30
0
        private void connection_OnFogReceived(SimpleImage fogSimpleImage)
        {
            try
            {
                using (var stream = new MemoryStream(fogSimpleImage.Bytes))
                {
                    var fogImage = System.Drawing.Image.FromStream(stream);

                    stream.Position = 0;

                    var fogTexture = Texture2D.FromStream(GraphicsDevice, stream);
                    // TODO: The Bitmap uses White to simulate Transparency. This is stupid but acceptable for now.
                    ReplaceNonBlackWithTransparent(fogTexture);

                    this.gameState.FogImage = fogImage;
                    this.gameState.Fog      = fogTexture;
                }
            }
            catch (Exception e)
            {
                Logger.LogError("Fog received failure.", e);
            }
        }
 public unsafe void FillCircle(SimpleImage img, uint clr, float circleCenterX, 
     float circleCenterY, float circleRadius)
 {
     FillCircle(img, clr, new Circle2D(circleCenterX, circleCenterY, circleRadius));
 }
 public unsafe void DrawRoundLine(SimpleImage image, Vector2D pt1, Vector2D pt2, float lineWidth,
     uint color)
 {
     DrawRoundLine_Composite(new Stadium(pt1, pt2, lineWidth / 2f), color, image.Pixels,
         image.Width, image.Height);
 }
        public void DrawArrowRoundStyle(SimpleImage img, uint clr, Vector2D start, Vector2D end,
            ArrowHeadStyle startHead, ArrowHeadStyle endHead, float hookLength, float lineThickness)
        {
            if (hookLength <= 0f)
            {
                DrawRoundLine(img, start, end, lineThickness, clr);
                return;
            }

            // If the start and end points are the same then it is a degenerate arrow. We'll just fill a
            // circle in this case.
            if (start.Equals(end))
            {
                FillCircle(img, clr, new Circle2D(start, lineThickness / 2f));
                return;
            }

            // For the round style arrows, we essentially just have to render a series of round lines.
            // What we DON'T want to do is draw one for the arrow "body" and then additional ones for
            // the hooks at the end. This is because there will be duplicate blending near the ends and
            // it won't look as good.

            Vector2D dirNorm = Vector2D.Normalize(end - start);
            Vector2D perpNorm = Vector2D.Normalize((start - end).GetPerpendicular());

            List<Stadium> slist = new List<Stadium>();
            // We always need the main line
            slist.Add(new Stadium(start, end, lineThickness / 2f));
            if (ArrowHeadStyle.BothHooks == startHead ||
                ArrowHeadStyle.UpperHookOnly == startHead)
            {
                slist.Add(new Stadium(start, start + (dirNorm * hookLength) + (perpNorm * hookLength),
                    lineThickness / 2f));
            }
            if (ArrowHeadStyle.BothHooks == startHead ||
                ArrowHeadStyle.LowerHookOnly == startHead)
            {
                slist.Add(new Stadium(start, start + (dirNorm * hookLength) - (perpNorm * hookLength),
                    lineThickness / 2f));
            }
            if (ArrowHeadStyle.BothHooks == endHead ||
                ArrowHeadStyle.UpperHookOnly == endHead)
            {
                slist.Add(new Stadium(end, end - (dirNorm * hookLength) + (perpNorm * hookLength),
                    lineThickness / 2f));
            }
            if (ArrowHeadStyle.BothHooks == endHead ||
                ArrowHeadStyle.LowerHookOnly == endHead)
            {
                slist.Add(new Stadium(end, end - (dirNorm * hookLength) - (perpNorm * hookLength),
                    lineThickness / 2f));
            }

            Stadium[] stads = slist.ToArray();

            // Soften radius, hard-coded for now
            float sr = 2f;

            FillStadiums(img, clr, stads, sr);
        }
示例#34
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // use this.Content to load game content here
            #region Label L2: content loading for what will appear in the application screen
            // Label L2a: Creates SimpleImage
            mBall = new BounceableImage(Content.Load<Texture2D>("BBall"), Content.Load<SoundEffect>("bounce"), 200, 400, 100, 100);

            mMarker1 = new SimpleImage(Content.Load<Texture2D>("TouchMarker"), 0, 0, 40, 40);
            mMarker2 = new SimpleImage(Content.Load<Texture2D>("TouchMarker"), 0, 0, 40, 40);
            mMarker1.IsVisible = false;
            mMarker2.IsVisible = false;

            // Label L2b: Loads the font
            //DrawFont.LoadFont(Content);
            #endregion

            #region Label L3 content loading for audio/sound effect support
            // Loads audio effets and start background music
            mBeep = Content.Load<SoundEffect>("Beep");
            #endregion
        }
 public void DrawArrowRoundStyle(SimpleImage img, uint clr, Vector2D start, Vector2D end,
     float hookLength, float lineThickness)
 {
     DrawArrowRoundStyle(img, clr, start, end, ArrowHeadStyle.NoHooks,
         ArrowHeadStyle.BothHooks, hookLength, lineThickness);
 }
        private unsafe void FillStadiums(SimpleImage img, uint clr, Stadium[] stads,
            float sr)
        {
            float clrAlphaFloat = (float)(clr >> 24) / 255f;

            // Find the start and end (inclusive) Y-values
            float minyFloat = float.MaxValue, maxyFloat = float.MinValue;
            foreach (Stadium sTemp in stads)
            {
                if (sTemp.MaxY > maxyFloat)
                {
                    maxyFloat = sTemp.MaxY;
                }
                if (sTemp.MinY < minyFloat)
                {
                    minyFloat = sTemp.MinY;
                }
            }
            int miny = (int)Math.Floor(minyFloat);
            if (miny >= img.Height)
            {
                // Content is completely off the image
                return;
            }
            miny = Math.Max(miny, 0);
            int maxy = Math.Min((int)Math.Ceiling(maxyFloat), img.Height - 1);

            // We need lists to keep track of minimum and maximum intersections per row
            List<float> mins = new List<float>();
            List<float> maxes = new List<float>();

            List<float> finals = new List<float>();

            // Loop through rows of pixels
            while (miny <= maxy)
            {
                // Clear intersection lists
                mins.Clear();
                maxes.Clear();
                finals.Clear();

                // Get all intersections for this row
                foreach (Stadium sTemp in stads)
                {
                    float tempMin, tempMax;
                    sTemp.HLineIntersection((float)miny, out tempMin, out tempMax);
                    if (!float.IsNaN(tempMin) && !float.IsNaN(tempMax))
                    {
                        mins.Add(tempMin);
                        maxes.Add(tempMax);
                    }
                }

                if (0 == mins.Count || 0 == maxes.Count)
                {
                    miny++;
                    continue;
                }

                // Sort the intersection lists
                mins.Sort();
                maxes.Sort();

                // Debug: plot a pixel at each intersection point
                //foreach (float f in mins)
                //{
                //    *img.GetRowAtX(miny, (int)f) = 0xFFFF0000;
                //}
                //foreach (float f in maxes)
                //{
                //    *img.GetRowAtX(miny, (int)f) = 0xFF00FF00;
                //}

                bool rowIsComplex = false;
                // When > 0, we're inside, otherwise we're outside the object. This gets incremented
                // when we hit a value in the "mins" list and decremented when we hit a value in
                // the "maxes" list.
                int in_out = 0;
                while (mins.Count > 0 || maxes.Count > 0)
                {
                    if (0 == mins.Count)
                    {
                        finals.Add(maxes[maxes.Count - 1]);
                        break;
                    }
                    else if (0 == maxes.Count)
                    {
                        // Should never occur
                        break;
                    }

                    if (mins[0] < maxes[0])
                    {
                        if (0 == in_out)
                        {
                            // 0 == in_out implies that we were outside and now we're entering
                            finals.Add(mins[0]);
                        }
                        else
                        {
                            // This means that in_out is > 0 and we've entered 2 stadiums (or
                            // more) at once. This implies a "complex" row, which gets rendered
                            // without certain optimizations.
                            rowIsComplex = true;
                        }
                        mins.RemoveAt(0);
                        in_out++;
                    }
                    else
                    {
                        in_out--;
                        if (0 == in_out)
                        {
                            // This is an exit point
                            finals.Add(maxes[0]);
                        }
                        maxes.RemoveAt(0);
                    }
                }

                int xstart, xend;

                // The "finals" list now contains pairs of enter-exit x-values
                for (int i = 0; i < finals.Count - 1; i += 2)
                {
                    xstart = Math.Max((int)Math.Floor(finals[i]), 0);
                    if (xstart >= img.Width)
                    {
                        continue;
                    }
                    xend = Math.Min((int)Math.Ceiling(finals[i + 1]), img.Width - 1);
                    if (xend < 0)
                    {
                        continue;
                    }
                    uint* row = &img.Pixels[miny * img.Width + xstart];

                    // Start by coming in from the left edge until we are no longer in the edge
                    // softening section
                    while (xstart <= xend)
                    {
                        float minDist = float.MaxValue;
                        Stadium minDistStadium = stads[0];
                        foreach (Stadium stadium in stads)
                        {
                            float dist = stadium.Axis.DistanceU(new Vector2D((float)xstart, (float)miny));
                            if (dist < minDist)
                            {
                                minDist = dist;
                                minDistStadium = stadium;
                            }
                        }

                        if (minDist < minDistStadium.Radius)
                        {
                            if (minDist > minDistStadium.Radius - sr)
                            {
                                float alpha = (minDistStadium.Radius - minDist) / sr;
                                alpha *= clrAlphaFloat;
                                uint newAlpha = (uint)(alpha * 255f);
                                newAlpha <<= 24;
                                BlendComposite((clr & 0x00FFffFF) | newAlpha, row);
                            }
                            else
                            {
                                if (rowIsComplex)
                                {
                                    BlendComposite(clr, row);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }

                        xstart++;
                        row++;
                    }

                    // It's possible that we completed this section in the above loop
                    if (xstart > xend)
                    {
                        continue;
                    }

                    // Get a pointer to pixels on the right edge
                    row = img.GetRowAtX(miny, xend);

                    // Now come in from the right edge until we are no longer in the edge
                    // softening section
                    while (xend >= xstart)
                    {
                        float minDist = float.MaxValue;
                        Stadium minDistStadium = stads[0];
                        foreach (Stadium stadium in stads)
                        {
                            float dist = stadium.Axis.DistanceU(new Vector2D((float)xend, (float)miny));
                            if (dist < minDist)
                            {
                                minDist = dist;
                                minDistStadium = stadium;
                            }
                        }

                        if (minDist < minDistStadium.Radius)
                        {
                            if (minDist > minDistStadium.Radius - sr)
                            {
                                float alpha = (minDistStadium.Radius - minDist) / sr;
                                alpha *= clrAlphaFloat;
                                uint newAlpha = (uint)(alpha * 255f);
                                newAlpha <<= 24;
                                BlendComposite((clr & 0x00FFffFF) | newAlpha, row);
                            }
                            else
                            {
                                break;
                            }
                        }

                        xend--;
                        row--;
                    }

                    // If there are remaining pixels between xstart and xend then render them
                    if (xstart <= xend)
                    {
                        DrawHorizontalLine(xstart, xend, miny, clr, img.Pixels, img.Width, img.Height,
                            BlendMode.AlphaComposite);
                    }
                }

                miny++;
            }
        }
示例#37
0
        private void ReadFrameColors(byte[] indices, byte[] colorTable, GifImageDescriptor descriptor)
        {
            int imageWidth = _logicalScreenDescriptor.Width;
            int imageHeight = _logicalScreenDescriptor.Height;

            if (_currentFrame == null)
            {
                _currentFrame = new byte[imageWidth * imageHeight * 4];
            }

            byte[] lastFrame = null;

            if (_graphicsControl != null &&
                _graphicsControl.DisposalMethod == DisposalMethod.RestoreToPrevious)
            {
                lastFrame = new byte[imageWidth * imageHeight * 4];

                Array.Copy(_currentFrame, lastFrame, lastFrame.Length);
            }

            int offset = 0, i = 0, index = -1;

            int iPass = 0; // the interlace pass
            int iInc = 8; // the interlacing line increment
            int iY = 0; // the current interlaced line
            int writeY = 0; // the target y offset to write to

            for (int y = descriptor.Top; y < descriptor.Top + descriptor.Height; y++)
            {
                // Check if this image is interlaced.
                if (descriptor.InterlaceFlag)
                {
                    // If so then we read lines at predetermined offsets.
                    // When an entire image height worth of offset lines has been read we consider this a pass.
                    // With each pass the number of offset lines changes and the starting line changes.
                    if (iY >= descriptor.Height)
                    {
                        iPass++;
                        switch (iPass)
                        {
                            case 1:
                                iY = 4;
                                break;
                            case 2:
                                iY = 2;
                                iInc = 4;
                                break;
                            case 3:
                                iY = 1;
                                iInc = 2;
                                break;
                        }
                    }

                    writeY = iY + descriptor.Top;

                    iY += iInc;
                }
                else
                {
                    writeY = y;
                }

                //TODO: review performance here

                for (int x = descriptor.Left; x < descriptor.Left + descriptor.Width; x++)
                {
                    offset = writeY * imageWidth + x;

                    index = indices[i];

                    if (_graphicsControl == null ||
                        _graphicsControl.TransparencyFlag == false ||
                        _graphicsControl.TransparencyIndex != index)
                    {
                        _currentFrame[offset * 4 + 0] = colorTable[index * 3 + 0];
                        _currentFrame[offset * 4 + 1] = colorTable[index * 3 + 1];
                        _currentFrame[offset * 4 + 2] = colorTable[index * 3 + 2];
                        _currentFrame[offset * 4 + 3] = (byte)255;
                    }

                    i++;
                }
            }

            byte[] pixels = new byte[imageWidth * imageHeight * 4];

            Array.Copy(_currentFrame, pixels, pixels.Length);

            SimpleImage currentImage = null;

            if (_image.Pixels == null)
            {
                currentImage = _image;
                currentImage.SetPixels(imageWidth, imageHeight, pixels);
            }
            else
            {
                SimpleImage frame = new SimpleImage();

                currentImage = frame;
                currentImage.SetPixels(imageWidth, imageHeight, pixels);

                _image.Frames.Add(frame);
            }

            if (_graphicsControl != null)
            {
                if (_graphicsControl.DelayTime > 0)
                {
                    ExtraImageInfo extraImgInfo = currentImage.ExtraImageInfo;
                    if (extraImgInfo == null)
                    {
                        currentImage.ExtraImageInfo = extraImgInfo = new ExtraImageInfo();
                    }
                    extraImgInfo.DelayTime = _graphicsControl.DelayTime;
                }

                if (_graphicsControl.DisposalMethod == DisposalMethod.RestoreToBackground)
                {
                    for (int y = descriptor.Top; y < descriptor.Top + descriptor.Height; y++)
                    {
                        for (int x = descriptor.Left; x < descriptor.Left + descriptor.Width; x++)
                        {
                            offset = y * imageWidth + x;

                            _currentFrame[offset * 4 + 0] = 0;
                            _currentFrame[offset * 4 + 1] = 0;
                            _currentFrame[offset * 4 + 2] = 0;
                            _currentFrame[offset * 4 + 3] = 0;
                        }
                    }
                }
                else if (_graphicsControl.DisposalMethod == DisposalMethod.RestoreToPrevious)
                {
                    _currentFrame = lastFrame;
                }
            }
        }
        public unsafe void FillCircle(SimpleImage img, uint clr, Circle2D circle)
        {
            // Optimization: For composite-blending, we don't have do draw anything if the
            // drawing color has an alpha value of zero
            if (0 == (clr & 0xFF000000))
            {
                return;
            }

            // Soften radius (hard-coded for now)
            float sr = 2.0f;

            // Compute the inclusive y-starting point
            int ystart = (int)Math.Floor(circle.MinY);
            // Compute the inclusive y-ending point
            int yend = (int)Math.Ceiling(circle.MaxY);

            // Do a quick check to see if we're completely off the image
            if (yend < 0 || ystart >= img.Height)
            {
                return;
            }

            // Constrain y-values, if needed
            if (ystart < 0)
            {
                ystart = 0;
            }
            if (yend > img.Height - 1)
            {
                yend = img.Height - 1;
            }

            // Compute a float alpha value in the range [0.0, 1.0]
            float alpha = (float)(clr >> 24) / 255.0f;

            // Loop through rows of pixels
            for (; ystart <= yend; ystart++)
            {
                // Compute intersections for this row
                float minx, maxx;
                circle.HLineIntersection((float)ystart, out minx, out maxx);

                // Skip to the next row if there was no intersection
                if (float.IsNaN(minx) || float.IsNaN(maxx))
                {
                    continue;
                }

                // Compute the starting point on the left edge of the circle
                int xLeft = (int)Math.Floor(minx);
                // Skip this row if it's off the image
                if (xLeft >= img.Width)
                {
                    continue;
                }
                // Constrain if necessary
                if (xLeft < 0)
                {
                    xLeft = 0;
                }

                // Now compute the starting point on the right edge of the circle
                int xRight = (int)Math.Ceiling(maxx);
                // Skip if we're completely off the image
                if (xRight < 0)
                {
                    continue;
                }
                // Constrain, if necessary
                if (xRight >= img.Width)
                {
                    xRight = img.Width - 1;
                }

                // Make a pointer to this row of pixels
                uint* row = &img.Pixels[ystart * img.Width + xLeft];

                // Draw from the left edge until we hit a point where we're no longer within
                // the softening radius distance from the edge
                while (xLeft <= xRight)
                {
                    float dist = circle.DistanceFromCenter((float)xLeft, (float)ystart);
                    if (dist >= circle.Radius)
                    {
                        // Advance to next pixel
                        row++;
                        xLeft++;
                        continue;
                    }
                    if (dist <= circle.Radius - sr)
                    {
                        break;
                    }

                    // Compute the alpha value
                    float newAFloat = (circle.Radius - dist) / sr * alpha * 255.0f;
                    // Blend
                    BlendComposite((clr & 0x00FFffFF) | (((uint)newAFloat) << 24), row);

                    // Advance to next pixel
                    row++;
                    xLeft++;

                    // See if we end up heading off the right edge of the image
                    if (xLeft >= img.Width)
                    {
                        break;
                    }
                }

                // If we drew pixels until we went off the image, then are done with this row
                if (xLeft >= img.Width)
                {
                    continue;
                }

                // It's possible, depending on the softening radius and which part of the circle we're
                // rendering, that the entire row has already been processed. Remember that xLeft at
                // this point is one to the right of the last pixel that was processed.
                if (xRight < xLeft)
                {
                    continue;
                }

                // Set the pointer to where we're starting
                row = &img.Pixels[ystart * img.Width + xRight];

                // Draw from the right edge until we hit a point where we're:
                //  a) no longer within the softening radius distance from the edge
                //  b) we're off the image (xRight < 0)
                //  or
                //  c) we're less than xLeft
                while (xRight >= 0)
                {
                    float dist = circle.DistanceFromCenter((float)xRight, (float)ystart);
                    if (dist >= circle.Radius)
                    {
                        // Advance to next pixel
                        row--;
                        xRight--;
                        continue;
                    }
                    if (dist <= circle.Radius - sr)
                    {
                        break;
                    }

                    // Compute the alpha value
                    float newAFloat = (circle.Radius - dist) / sr * alpha * 255.0f;
                    // Blend
                    BlendComposite((clr & 0x00FFffFF) | (((uint)newAFloat) << 24), row);

                    // Advance to next pixel
                    row--;
                    xRight--;

                    if (xRight < xLeft)
                    {
                        break;
                    }
                }

                // At this point we've processed from the left and right edges of the circle
                // on this row and have taken care of all pixels that need edge softening. All
                // that remains is filling pixels in between where we left off on the left and
                // right.
                if (xRight >= xLeft)
                {
                    DrawHorizontalLine(xLeft, xRight, ystart, clr, img.Pixels, img.Width, img.Height,
                        BlendMode.AlphaComposite);
                }
            }
        }