Пример #1
0
 private void HandlePictureGroup(PhotoGroup photoGroup)
 {
     using (Bitmap newPic = photoModifier.CombinePicture(photoGroup))
     {
         fileWriter.SavePic(photoGroup, newPic);
     }
 }
Пример #2
0
        private async void CombinePicture()
        {
            string msg = string.Format("Combine picture started. Front Picture={0}, Back Picture={1}, New Picture={2}",
                                       ChoosenFrontPicPath, ChoosenBackPicPath, ChoosenOutputPicPath);

            log.LogInfo(msg);
            messageDispatcher.PopulateMessage(msg);

            if (string.IsNullOrEmpty(ChoosenFrontPicPath) ||
                string.IsNullOrEmpty(ChoosenBackPicPath) ||
                string.IsNullOrEmpty(ChoosenOutputPicPath))
            {
                log.LogError("Picture path shall not be empty.");
                messageDispatcher.PopulateMessage("Picture path shall not be empty.");
                return;
            }

            await Task.Factory.StartNew(() => {
                try
                {
                    using (Bitmap newPic = photoModifier.CombinePicture(ChoosenFrontPicPath, ChoosenBackPicPath))
                    {
                        if (newPic != null)
                        {
                            fileWriter.SavePic(ChoosenOutputPicPath, newPic);
                        }
                    }

                    log.LogInfo("Combine picture completed.");
                    messageDispatcher.PopulateMessage("Combine picture completed.");
                }
                catch (Exception ex)
                {
                    log.LogException("Combine picture error.", ex);
                    messageDispatcher.PopulateMessage("Combine picture error.");
                }
            });

            //Force collect bitmap left in memory.
            GC.Collect();
        }