예제 #1
0
 private void _menuItemEditPaste_Click(object sender, EventArgs e)
 {
     try
     {
         using (WaitCursor wait = new WaitCursor())
         {
             RasterImage image = RasterClipboard.Paste(this.Handle);
             if (image != null)
             {
                 ViewerForm activeForm = ActiveViewerForm;
                 NewImage(new ImageInformation(image));
             }
         }
     }
     catch (Exception ex)
     {
         Messager.ShowError(this, ex);
     }
     finally
     {
         UpdateControls();
     }
 }
예제 #2
0
        private void _miEditPaste_Click(object sender, EventArgs e)
        {
            try
            {
                using (WaitCursor wait = new WaitCursor())
                {
                    RasterImage image = RasterClipboard.Paste(this.Handle);
                    if (image != null)
                    {
                        ViewerForm activeForm = ActiveViewerForm;

                        if (image.HasRegion && activeForm == null)
                        {
                            image.MakeRegionEmpty();
                        }

                        if (image.HasRegion)
                        {
                            // make sure the images have the same BitsPerPixel and Palette
                            if (activeForm.Viewer.Image.BitsPerPixel > 8)
                            {
                                if (image.BitsPerPixel != activeForm.Viewer.Image.BitsPerPixel)
                                {
                                    try
                                    {
                                        ColorResolutionCommand colorRes = new ColorResolutionCommand();
                                        colorRes.BitsPerPixel = activeForm.Viewer.Image.BitsPerPixel;
                                        colorRes.Order        = activeForm.Viewer.Image.Order;
                                        colorRes.Mode         = Leadtools.ImageProcessing.ColorResolutionCommandMode.InPlace;
                                        colorRes.Run(image);
                                    }
                                    catch (Exception ex)
                                    {
                                        Messager.ShowError(this, ex);
                                    }
                                }
                            }
                            else
                            {
                                try
                                {
                                    ColorResolutionCommand colorRes = new ColorResolutionCommand();
                                    colorRes.BitsPerPixel = activeForm.Viewer.Image.BitsPerPixel;
                                    colorRes.SetPalette(activeForm.Viewer.Image.GetPalette());
                                    colorRes.PaletteFlags = Leadtools.ImageProcessing.ColorResolutionCommandPaletteFlags.UsePalette;
                                    colorRes.Mode         = Leadtools.ImageProcessing.ColorResolutionCommandMode.InPlace;
                                    colorRes.Run(image);
                                }
                                catch (Exception ex)
                                {
                                    Messager.ShowError(this, ex);
                                }
                            }
                        }
                        else
                        {
                            NewImage(new ImageInformation(image));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Messager.ShowError(this, ex);
            }
            finally
            {
                UpdateControls();
            }
        }