Beispiel #1
0
            internal static Bitmap GetImage(string code, int width, int height, HatchBrush hatchBrush)
            {
                if (string.IsNullOrEmpty(code))
                {
                    throw new ArgumentException("code can not be null or empty.");
                }
                var cim = new CaptchaImageMaker(code, width, height, hatchBrush);

                return(cim.GetImage());
            }
Beispiel #2
0
            public Bitmap GetImage()
            {
                _code = CaptchaHelper.GetCode(this.CharCount, CharSet);

                var onRemove = new CacheItemRemovedCallback(this.RemovedCallback);


                if (HttpRuntime.Cache.Get(Guid) != null)
                {
                    HttpRuntime.Cache.Remove(Guid);
                }

                HttpRuntime.Cache.Add(Guid, _code, null, DateTime.Now.AddMinutes(10), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, onRemove);

                var hatchBrush = new HatchBrush(HatchStyle.LargeConfetti, Color.Gray, Color.DarkGray);

                return(CaptchaImageMaker.GetImage(_code, (int)this.Width.Value, (int)this.Height.Value, hatchBrush));
            }