async private void submitAdjustment(object o)
        {
            if (Adjustment.AdjustmentID == 0)
            {
                if ((ErrorMessage = await new ServiceLayer().AddAdjustment(Adjustment.toDTO())) != null)
                {
                    return;
                }

                Adjustment = new Adjustment(ServiceLayer.Adjustment);

                if (Adjustments != null)
                {
                    Adjustments.Add(Adjustment);
                }
            }
            else
            {
                if ((ErrorMessage = await new ServiceLayer().UpdateAdjustment(Adjustment.toDTO())) != null)
                {
                    return;
                }
                Adjustment = new Adjustment(ServiceLayer.Adjustment);
            }

            Adjuster   = null;
            Adjustment = null;

            OnRequestClose(this, new EventArgs());
        }
Esempio n. 2
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Bitmap newImage = null;
            Image  image    = factory.Image;

            try
            {
                int threshold = (int)this.DynamicParameter;
                newImage = new Bitmap(image);
                newImage = Adjustments.Brightness(newImage, threshold);

                image.Dispose();
                image = newImage;
            }
            catch (Exception ex)
            {
                if (newImage != null)
                {
                    newImage.Dispose();
                }

                throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
            }

            return(image);
        }
Esempio n. 3
0
        internal void AdjustPrice(AdjustPrice adjustPrice)
        {
            var adjustment = new PriceAdjustment(adjustPrice, Price);

            Adjustments.Add(adjustment);
            Price = adjustment.NewPrice;
        }
Esempio n. 4
0
        /// <summary>
        /// Gets an image resized using the linear color space with gamma correction adjustments.
        /// </summary>
        /// <param name="source">The source image.</param>
        /// <param name="width">The width to resize to.</param>
        /// <param name="height">The height to resize to.</param>
        /// <param name="destination">The destination rectangle.</param>
        /// <param name="animationProcessMode">The process mode for frames in animated images.</param>
        /// <returns>
        /// The <see cref="Bitmap"/>.
        /// </returns>
        protected virtual Bitmap ResizeLinear(Image source, int width, int height, Rectangle destination, AnimationProcessMode animationProcessMode)
        {
            // Adjust the gamma value so that the image is in the linear color space.
            var linear = Adjustments.ToLinear(source.Copy(animationProcessMode));

            var resized = new Bitmap(width, height, PixelFormat.Format32bppPArgb);

            resized.SetResolution(source.HorizontalResolution, source.VerticalResolution);

            using (var graphics = Graphics.FromImage(resized))
            {
                GraphicsHelper.SetGraphicsOptions(graphics);
                using (var attributes = new ImageAttributes())
                {
                    attributes.SetWrapMode(WrapMode.TileFlipXY);
                    graphics.DrawImage(linear, destination, 0, 0, source.Width, source.Height, GraphicsUnit.Pixel, attributes);
                }
            }

            // Return to composite color space.
            resized = Adjustments.ToSRGB(resized);

            linear.Dispose();
            return(resized);
        }
Esempio n. 5
0
        public async Task Discover()
        {
            try
            {
                const string source = "portal2_cm_coop.dem";

                var parser = new SourceParser();
                var demo   = await parser.ParseFromFileAsync(Paths.Demos + source);

                Console.WriteLine("Before: " + demo.PlaybackTicks);

                // Load automatically from assembly
#if !DISCOVER_2
                await Adjustments.DiscoverAsync();
#else
                await Adjustments.DiscoverAsync(System.Reflection.Assembly.GetEntryAssembly());
#endif
                await demo.AdjustAsync();

                Console.WriteLine("After: " + demo.PlaybackTicks);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Esempio n. 6
0
        private Adjustments LoadGlyph(uint index)
        {
            Adjustments adjustments;

            mEscapements.TryGetValue(index, out adjustments);
            if (adjustments != null)
            {
                return(adjustments);
            }

            //Application.GetInstance().DebugTimeToConsole("--> LoadGlyph (" + index + "):");
            {
                Glyph rv;
                mGlyphDictionary.TryGetValue(index, out rv);

                if (rv == null)
                {
                    return(null);
                }

                adjustments = new Adjustments(rv.escapement[0], rv.escapement[1]);
                mEscapements.Add(rv.glyphIndex, adjustments);

                var glyphPath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);
                VG.vgAppendPathData(glyphPath, rv.commands.Length, rv.commands, rv.coordinates);
                VG.vgSetGlyphToPath(mFont, rv.glyphIndex, glyphPath, VGboolean.VG_TRUE, rv.origin, rv.escapement);
                VG.vgDestroyPath(glyphPath);
            }

            return(adjustments);
            //Application.GetInstance().DebugTimeToConsole("<-- LoadGlyph (" + index + "):");
        }
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="source">The current image to process</param>
        /// <param name="destination">The new Image to return</param>
        /// <returns>
        /// The processed <see cref="System.Drawing.Bitmap"/>.
        /// </returns>
        public override Bitmap TransformImage(Image source, Image destination)
        {
            using (Graphics graphics = Graphics.FromImage(destination))
            {
                using (ImageAttributes attributes = new ImageAttributes())
                {
                    attributes.SetColorMatrix(this.Matrix);

                    Rectangle rectangle = new Rectangle(0, 0, source.Width, source.Height);

                    graphics.DrawImage(source, rectangle, 0, 0, source.Width, source.Height, GraphicsUnit.Pixel, attributes);
                }
            }

            // Fade the contrast
            destination = Adjustments.Contrast(destination, -25);

            // Add a glow to the image.
            destination = Effects.Glow(destination, Color.FromArgb(70, 255, 153, 102));

            // Add a vignette to finish the effect.
            destination = Effects.Vignette(destination, Color.FromArgb(220, 102, 34, 0));

            return((Bitmap)destination);
        }
Esempio n. 8
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Bitmap newImage = null;
            Image  image    = factory.Image;

            try
            {
                int percentage = this.DynamicParameter;

                newImage = new Bitmap(image);
                newImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
                newImage = Adjustments.Alpha(newImage, percentage);

                image.Dispose();
                image = newImage;
            }
            catch (Exception ex)
            {
                if (newImage != null)
                {
                    newImage.Dispose();
                }

                throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
            }

            return(image);
        }
Esempio n. 9
0
        public void AdjustPrice(AdjustPrice adjustPrice)
        {
            var adjustment = new PriceAdjustment(adjustPrice, this.Price);

            Adjustments.Add(adjustment);
            Price = adjustPrice.NewPrice;
        }
Esempio n. 10
0
        public ActionResult DeleteConfirmed(int id)
        {
            Adjustments adjustments = db.Adjustments.Find(id);

            db.Adjustments.Remove(adjustments);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 11
0
        private APIGatewayProxyResponse HandleInsert(APIGatewayProxyRequest pRequest, ILambdaContext pContext, CognitoUser pCognitoUser, opendkpContext pDatabase)
        {
            var vResponse = HttpHelper.HandleError("[InsertOrUpdateAdjustment] Unknown error backend...", 500);
            //We need to retrieve the ClientId for multitenancy purposes
            var vClientId = pRequest.Headers["clientid"];

            try
            {
                //Populate Model
                dynamic vModel           = JsonConvert.DeserializeObject(pRequest.Body);
                string  vInputCharacters = (string)vModel.Character;
                vInputCharacters = vInputCharacters.Trim();

                string[] vCharacterList = vInputCharacters.Split(',');

                using (var dbContextTransaction = pDatabase.Database.BeginTransaction())
                {
                    foreach (string vCharacter in vCharacterList)
                    {
                        //Create our Adjustment for each Character
                        Adjustments vAdjustment = new Adjustments
                        {
                            Name        = vModel.Name,
                            Description = vModel.Description,
                            Value       = vModel.Value,
                            Timestamp   = vModel.Timestamp,
                            ClientId    = vClientId
                        };

                        //Convert Character Name to Character Id
                        vAdjustment.IdCharacter = DkpConverters.CharacterNameToId(pDatabase, vClientId, vCharacter);
                        if (vAdjustment != null && vAdjustment.IdCharacter > -1)
                        {
                            pDatabase.Add(vAdjustment);
                            pDatabase.SaveChanges();
                        }
                    }
                    //Commit changes to DB
                    dbContextTransaction.Commit();
                    //Create success response
                    vResponse = HttpHelper.HandleResponse(vModel, 200);

                    //Audit
                    AuditHelper.InsertAudit(pDatabase, vClientId, string.Empty, vModel, pCognitoUser.Username, Audit.ACTION_ADJUST_INSERT);

                    //Update Caches
                    int vStatus = CacheManager.UpdateSummaryCacheAsync(vClientId).GetAwaiter().GetResult();
                    Console.WriteLine("StatusCode for CacheUpdate=" + vStatus);
                }
            }
            catch (Exception vException)
            {
                vResponse = HttpHelper.HandleError(vException.Message, 500);
            }

            return(vResponse);
        }
Esempio n. 12
0
 public AdjustmentModel(Adjustments pAdjustment)
 {
     this.Id          = pAdjustment.IdAdjustment;
     this.Name        = pAdjustment.Name;
     this.Description = pAdjustment.Description;
     this.Value       = pAdjustment.Value;
     this.Timestamp   = pAdjustment.Timestamp;
     this.Character   = new CharacterModel(pAdjustment.IdCharacterNavigation);
 }
Esempio n. 13
0
 public ActionResult Edit([Bind(Include = "AdjustmentID,LeagueName,StartDate,EndDate,Team,AdjustmentType,AdjustmentAmount,Player,Description,TS")] Adjustments adjustments)
 {
     if (ModelState.IsValid)
     {
         db.Entry(adjustments).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(adjustments));
 }
Esempio n. 14
0
        public void CreateMainMenu(Gtk.MenuBar menu)
        {
            // File menu
            ImageMenuItem file = (ImageMenuItem)menu.Children[0];

            file.Submenu = new Menu();
            File.CreateMainMenu((Menu)file.Submenu);

            //Edit menu
            ImageMenuItem edit = (ImageMenuItem)menu.Children[1];

            edit.Submenu = new Menu();
            Edit.CreateMainMenu((Menu)edit.Submenu);

            // View menu
            ImageMenuItem view = (ImageMenuItem)menu.Children[2];

            View.CreateMainMenu((Menu)view.Submenu);

            // Image menu
            ImageMenuItem image = (ImageMenuItem)menu.Children[3];

            image.Submenu = new Menu();
            Image.CreateMainMenu((Menu)image.Submenu);

            //Layers menu
            ImageMenuItem layer = (ImageMenuItem)menu.Children[4];

            layer.Submenu = new Menu();
            Layers.CreateMainMenu((Menu)layer.Submenu);

            //Adjustments menu
            ImageMenuItem adj = (ImageMenuItem)menu.Children[5];

            adj.Submenu = new Menu();
            Adjustments.CreateMainMenu((Menu)adj.Submenu);

            // Effects menu
            ImageMenuItem eff = (ImageMenuItem)menu.Children[6];

            eff.Submenu = new Menu();
            Effects.CreateMainMenu((Menu)eff.Submenu);

            // Window menu
            ImageMenuItem window = (ImageMenuItem)menu.Children[7];

            window.Submenu = new Menu();
            Window.CreateMainMenu((Menu)window.Submenu);

            //Help menu
            ImageMenuItem help = (ImageMenuItem)menu.Children[8];

            help.Submenu = new Menu();
            Help.CreateMainMenu((Menu)help.Submenu);
        }
        public void Validate()
        {
            var atLeastOneVoidAdjustmentExist = Adjustments.Any(adjustment => adjustment.Voided == true);

            if (atLeastOneVoidAdjustmentExist)
            {
                var showErrorOnPersist = JointPayeePaymentDataProvider
                                         .GetCurrentJointPayeePaymentsByVendorGroups(Graph, Graph.Document.Current)
                                         .Select(ValidateReversedJointPayeePayments).Any(isValid => !isValid);
                ShowErrorOnPersistIfRequired(Graph.Caches[typeof(JointPayeePayment)], showErrorOnPersist);
            }
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            bool done = false;

            Console.ForegroundColor = ConsoleColor.Green; // Font Green
            Console.WriteLine("Hello! This program will set your font adjustment.");
            Adjustments c = Adjustments.None;

            Console.WriteLine("Current font adjustment: " + c.ToString());
            while (!done)
            {
                Console.WriteLine("Enter a value: \n \t 1: Bold \n \t 2: Italic " +
                                  "\n \t 3: Underline \n \t 0: Clear adjustment");
                string v = Console.ReadLine();

                if (v == "1")
                {
                    c = c | Adjustments.Bold;
                }
                else if (v == "2")
                {
                    c = c | Adjustments.Italic;
                }
                else if (v == "3")
                {
                    c = c | Adjustments.Underline;
                }
                else if (v == "0")
                {
                    c = Adjustments.None;
                }
                else
                {
                    Console.WriteLine("The value you entered is incorrect. Try again!");
                }
                Console.WriteLine("Your current font adjustment: " + c.ToString());

                Console.Write("Type 'yes' if you want to continue or something else to break: ");
                string ans = Console.ReadLine();
                if (ans == "yes" || ans == "y")
                {
                    continue;
                }
                else
                {
                    done = true;
                }
                Console.WriteLine("Press any key to exit the program.");
                Console.ReadKey();
            }
        }
Esempio n. 17
0
        // GET: Adjustments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Adjustments adjustments = db.Adjustments.Find(id);

            if (adjustments == null)
            {
                return(HttpNotFound());
            }
            return(View(adjustments));
        }
Esempio n. 18
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Image image = factory.Image;

            try
            {
                int threshold = (int)this.DynamicParameter;
                return(Adjustments.Brightness(image, threshold));
            }
            catch (Exception ex)
            {
                throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            var image = factory.Image;

            try
            {
                var threshold = (int)DynamicParameter;
                return(Adjustments.Contrast(image, threshold));
            }
            catch (Exception ex)
            {
                throw new ImageProcessingException("Error processing image with " + GetType().Name, ex);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            var image = factory.Image;

            try
            {
                float value = DynamicParameter;
                return(Adjustments.Gamma(image, value));
            }
            catch (Exception ex)
            {
                throw new ImageProcessingException("Error processing image with " + GetType().Name, ex);
            }
        }
Esempio n. 21
0
        public void AdjustmentGet()
        {
            var account = CreateNewAccountWithBillingInfo();

            var adjustment = account.NewAdjustment("USD", 1234);

            adjustment.Create();

            adjustment.Uuid.Should().NotBeNullOrEmpty();

            var fromService = Adjustments.Get(adjustment.Uuid);

            fromService.Uuid.Should().NotBeNull();
        }
Esempio n. 22
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Image image = factory.Image;

            try
            {
                int percentage = this.DynamicParameter;
                return(Adjustments.Alpha(image, percentage));
            }
            catch (Exception ex)
            {
                throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
            }
        }
Esempio n. 23
0
        private APIGatewayProxyResponse HandleUpdateAsync(APIGatewayProxyRequest pRequest, ILambdaContext pContext, CognitoUser pCognitoUser, opendkpContext pDatabase)
        {
            var vResponse = HttpHelper.HandleError("[InsertOrUpdateAdjustment] Unknown error backend...", 500);
            //We need to retrieve the ClientId for multitenancy purposes
            var vClientId = pRequest.Headers["clientid"];

            try
            {
                //Populate Model
                dynamic     vModel      = JsonConvert.DeserializeObject(pRequest.Body);
                Adjustments vAdjustment = new Adjustments()
                {
                    Name         = vModel.Name,
                    Description  = vModel.Description,
                    Value        = vModel.Value,
                    Timestamp    = vModel.Timestamp,
                    IdAdjustment = vModel.Id,
                    ClientId     = vClientId
                };
                int vId = vModel.Id;
                if (vAdjustment != null)
                {
                    Adjustments vExists = pDatabase.Adjustments
                                          .FirstOrDefault(x => x.ClientId.Equals(vClientId) && x.IdAdjustment == vId);
                    string vOld = JsonConvert.SerializeObject(vExists, new JsonSerializerSettings {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    });

                    vAdjustment.IdCharacter = vExists.IdCharacter;
                    pDatabase.Entry(vExists).CurrentValues.SetValues(vAdjustment);
                    pDatabase.SaveChanges();
                    vResponse = HttpHelper.HandleResponse(vModel, 200);

                    //Audit
                    AuditHelper.InsertAudit(pDatabase, vClientId, vOld, pRequest.Body, pCognitoUser.Username, Audit.ACTION_ADJUST_UPDATE);

                    //Update Caches
                    int vStatus = CacheManager.UpdateSummaryCacheAsync(vClientId).GetAwaiter().GetResult();
                    Console.WriteLine("StatusCode for CacheUpdate=" + vStatus);
                }
            }
            catch (Exception vException)
            {
                Console.WriteLine("1 Exception: " + vException);
                vResponse = HttpHelper.HandleError(vException.Message, 500);
            }
            return(vResponse);
        }
Esempio n. 24
0
        /// <summary>
        /// "writes off" anyoutstanding balance as a variance
        /// </summary>
        public MLFSDebtorAdjustment ClearToVariance(MLFSReportingPeriod period)
        {
            MLFSDebtorAdjustment variance = new MLFSDebtorAdjustment()
            {
                ReportingPeriodId = period.Id,
                ReportingPeriod   = period,
                Debtor            = this,
                DebtorId          = (int)Id,
                Amount            = Outstanding * -1,
                IsVariance        = true,
                NotTakenUp        = false
            };

            Adjustments.Add(variance);
            return(variance);
        }
Esempio n. 25
0
        /// <summary>
        /// Creates an NTU adjustment to reverse out a debtor when the transaction never happens
        /// </summary>
        /// <param name="period">the period in which the plan is marked as NTU</param>
        /// <returns></returns>
        public MLFSDebtorAdjustment CreateNTU(MLFSReportingPeriod period)
        {
            MLFSDebtorAdjustment adj = new MLFSDebtorAdjustment
            {
                DebtorId          = (int)Id,
                Amount            = GrossAmount * -1,
                Debtor            = this,
                IsVariance        = false,
                NotTakenUp        = true,
                ReportingPeriod   = period,
                ReportingPeriodId = period.Id
            };

            Adjustments.Add(adj);
            return(adj);
        }
Esempio n. 26
0
        public void AdjustmentDelete()
        {
            var account = CreateNewAccountWithBillingInfo();

            var adjustment = account.NewAdjustment("USD", 1234);

            adjustment.Create();

            adjustment.Uuid.Should().NotBeNullOrEmpty();

            adjustment.Delete();

            Action get = () => Adjustments.Get(adjustment.Uuid);

            get.ShouldThrow <NotFoundException>();
        }
Esempio n. 27
0
        /// <summary>
        /// Traces the edges of a given <see cref="Image"/>.
        /// TODO: Move this to another class.
        /// </summary>
        /// <param name="source">
        /// The source <see cref="Image"/>.
        /// </param>
        /// <param name="destination">
        /// The destination <see cref="Image"/>.
        /// </param>
        /// <param name="threshold">
        /// The threshold (between 0 and 255).
        /// </param>
        /// <returns>
        /// The a new instance of <see cref="Bitmap"/> traced.
        /// </returns>
        private static Bitmap Trace(Image source, Image destination, byte threshold = 0)
        {
            int width  = source.Width;
            int height = source.Height;

            // Grab the edges converting to greyscale, and invert the colors.
            ConvolutionFilter filter = new ConvolutionFilter(new SobelEdgeFilter(), true);

            using (Bitmap temp = filter.Process2DFilter(source))
            {
                destination = new InvertMatrixFilter().TransformImage(temp, destination);

                // Darken it slightly to aid detection
                destination = Adjustments.Brightness(destination, -5);
            }

            // Loop through and replace any colors more white than the threshold
            // with a transparent one.
            using (FastBitmap destinationBitmap = new FastBitmap(destination))
            {
                Parallel.For(
                    0,
                    height,
                    y =>
                {
                    for (int x = 0; x < width; x++)
                    {
                        // ReSharper disable AccessToDisposedClosure
                        Color color = destinationBitmap.GetPixel(x, y);
                        if (color.B >= threshold)
                        {
                            destinationBitmap.SetPixel(x, y, Color.Transparent);
                        }
                        // ReSharper restore AccessToDisposedClosure
                    }
                });
            }

            // Darken it again to average out the color.
            destination = Adjustments.Brightness(destination, -5);
            return((Bitmap)destination);
        }
Esempio n. 28
0
        /// <summary>
        /// Gets an image resized using the linear color space with gamma correction adjustments.
        /// </summary>
        /// <param name="source">The source image.</param>
        /// <param name="width">The width to resize to.</param>
        /// <param name="height">The height to resize to.</param>
        /// <param name="destination">The destination rectangle.</param>
        /// <returns>
        /// The <see cref="Bitmap"/>.
        /// </returns>
        protected virtual Bitmap ResizeLinear(Image source, int width, int height, Rectangle destination)
        {
            // Adjust the gamma value so that the image is in the linear color space.
            Bitmap linear = Adjustments.ToLinear(source.Copy());

            Bitmap resized = new Bitmap(width, height, PixelFormat.Format32bppPArgb);

            resized.SetResolution(source.HorizontalResolution, source.VerticalResolution);

            using (Graphics graphics = Graphics.FromImage(resized))
            {
                // We want to use two different blending algorithms for enlargement/shrinking.
                if (source.Width < width || source.Height < height)
                {
                    // We are making it larger.
                    graphics.SmoothingMode = SmoothingMode.AntiAlias;
                }
                else
                {
                    // We are making it smaller.
                    graphics.SmoothingMode = SmoothingMode.None;
                }

                graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                graphics.CompositingQuality = CompositingQuality.HighQuality;

                using (ImageAttributes attributes = new ImageAttributes())
                {
                    attributes.SetWrapMode(WrapMode.TileFlipXY);
                    graphics.DrawImage(linear, destination, 0, 0, source.Width, source.Height, GraphicsUnit.Pixel, attributes);
                }
            }

            // Return to composite color space.
            resized = Adjustments.ToSRGB(resized);

            linear.Dispose();
            return(resized);
        }
Esempio n. 29
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="source">The current image to process</param>
        /// <param name="destination">The new Image to return</param>
        /// <returns>
        /// The processed <see cref="Bitmap"/>.
        /// </returns>
        public override Bitmap TransformImage(Image source, Image destination)
        {
            using (var graphics = Graphics.FromImage(destination))
            {
                using (var attributes = new ImageAttributes())
                {
                    attributes.SetColorMatrix(this.Matrix);

                    var rectangle = new Rectangle(0, 0, source.Width, source.Height);

                    graphics.DrawImage(source, rectangle, 0, 0, source.Width, source.Height, GraphicsUnit.Pixel, attributes);

                    // Overlay the image with some semi-transparent colors to finish the effect.
                    using (var path = new GraphicsPath())
                    {
                        path.AddRectangle(rectangle);

                        // Paint a burgundy rectangle with a transparency of ~30% over the image.
                        // Paint a blue rectangle with a transparency of 20% over the image.
                        using (var brush = new SolidBrush(Color.FromArgb(77, 38, 14, 28)))
                        {
                            Region oldClip = graphics.Clip;
                            graphics.Clip = new Region(rectangle);
                            graphics.FillRectangle(brush, rectangle);

                            // Fill the blue.
                            brush.Color = Color.FromArgb(51, 29, 32, 59);
                            graphics.FillRectangle(brush, rectangle);
                            graphics.Clip = oldClip;
                        }
                    }
                }
            }

            // Add brightness and contrast to finish the effect.
            destination = Adjustments.Brightness(destination, 5);
            destination = Adjustments.Contrast(destination, 85);

            return((Bitmap)destination);
        }
Esempio n. 30
0
        public static Adjustment MakeAdjustment(long patNum, double adjAmt, DateTime adjDate = default(DateTime), DateTime procDate = default(DateTime)
                                                , long procNum = 0, long provNum = 0)
        {
            Adjustment adjustment = new Adjustment();

            if (adjDate == default(DateTime))
            {
                adjDate = DateTime.Today;
            }
            if (procDate == default(DateTime))
            {
                procDate = DateTime.Today;
            }
            adjustment.PatNum   = patNum;
            adjustment.AdjAmt   = adjAmt;
            adjustment.ProcNum  = procNum;
            adjustment.ProvNum  = provNum;
            adjustment.AdjDate  = adjDate;
            adjustment.ProcDate = procDate;
            Adjustments.Insert(adjustment);
            return(adjustment);
        }