Beispiel #1
0
        private void RedrawTab1Images()
        {
            this.Cursor = Cursors.WaitCursor;
            if (mInputImage != null)
            {
                ImagingTool tool1 = new ImagingTool(mInputImage);
                pictureBoxOriginal.Image = tool1.FitToControl(pictureBoxOriginal);
            }
            else
            {
                pictureBoxOriginal.Image = null;
            }
            if (mResizedImage != null)
            {
                ImagingTool tool2 = new ImagingTool(mResizedImage);
                pictureBoxResized.Image = tool2.FitToControl(pictureBoxOriginal);
            }
            else
            {
                pictureBoxResized.Image = null;
            }

            updateFormFromSettings();
            this.Cursor = Cursors.Default;
        }
Beispiel #2
0
 public void LoadImage()
 {
     this.Cursor = Cursors.WaitCursor;
     try
     {
         disposeColourViewer();
         mColourViewer = null;
         mInputImage   = (Bitmap)Image.FromFile(mSettings.InputImagePath);
         if (mInputImage.Height > 1000 || mInputImage.Width > 1000)
         {
             // too big. resize to be smaller.
             float       maxDim  = Math.Max(mInputImage.Width, mInputImage.Height);
             float       scale   = maxDim / 1000;
             Size        newSize = new Size((int)((float)mInputImage.Width / scale), (int)((float)mInputImage.Height / scale));
             ImagingTool tool    = new ImagingTool(mInputImage);
             tool.ResizeImage(newSize, InterpolationMode.Default);
             mInputImage = tool.OutputImage;
         }
         mSettings.InputImageSize = mInputImage.Size;
         mSettings.FixSizeRatio   = fixRatioCheck.Checked;
         mResizedImage            = null;
         //mCroppedImage = null;
         mRecolouredImage = null;
         mPatternImage    = null;
     }
     catch (ArgumentException e)
     {
         MessageBox.Show("Ooops! Bad Argument" + Environment.NewLine + "Filename = " + mSettings.InputImagePath
                         + Environment.NewLine + e + Environment.NewLine + e.StackTrace);
     }
     finally { this.Cursor = Cursors.Default; }
     RedrawTab1Images();
     RedrawTab2Images();
     RedrawTab3Images();
 }
Beispiel #3
0
        private void setImage(Bitmap b)
        {
            ImagingTool tool = new ImagingTool(b);

            tool.ResizeImage(pictureBox.Size);
            pictureBox.Image = tool.OutputImage;
        }
Beispiel #4
0
 private void RedrawPattern()
 {
     if (mRecolouredImage != null)
     {
         ImagingTool tool3 = new ImagingTool(mRecolouredImage);
         tool3.ReplaceColoursWithPatterns(patternEditor);
         mPatternImage           = tool3.OutputImage;
         pictureBoxPattern.Image = mPatternImage;
     }
 }
Beispiel #5
0
 public void ShowPatternEditor()
 {
     if (mRecolouredImage != null)
     {
         this.Cursor = Cursors.WaitCursor;
         ImagingTool tool = new ImagingTool(mRecolouredImage);
         patternEditor.UpdateColourMap();
         this.Cursor = Cursors.Default;
         patternEditor.Show();
         patternEditor.Focus();
     }
 }
Beispiel #6
0
 private void UpdateColourMap()
 {
     if (mRecolouredImage != null && ColourMap != null)
     {
         ImagingTool tool = new ImagingTool(mRecolouredImage, ColourMap);
         tool.UpdateColourMapFromImage();
         mSettings.MaxColours = ColourMap.Count;
         updateFormFromSettings();
         if (mColourViewer != null)
         {
             mColourViewer.UpdateColourMap(ColourMap);
         }
     }
 }
Beispiel #7
0
        void mColourViewer_ColourChangeEvent(object sender, ColourChangeEventArgs e)
        {
            if (mRecolouredImage == null)
            {
                return;
            }
            ImagingTool tool = new ImagingTool(mRecolouredImage, ColourMap);

            if (!e.DoReplace)
            {
                tool.RemoveFromPalette(e.Colour);
            }
            else
            {
                tool.ReplaceColour(e.Colour, e.ReplacementColour);
            }
            mRecolouredImage = tool.OutputImage;
            //UpdateColourMap();
            //showPalette(null, null);
            RedrawTab2Images();
        }
Beispiel #8
0
        public void ResizeImage(object sender, EventArgs e)
        {
            if (mInputImage == null)
            {
                return;
            }
            this.Cursor = Cursors.WaitCursor;
            ImagingTool tool;

            if (mCroppedImage == null)
            {
                tool = new ImagingTool(mInputImage, ColourMap);
            }
            else
            {
                tool = new ImagingTool(mCroppedImage, ColourMap);
            }
            //mSettings.InputImageSize = mInputImage.Size;
            tool.ResizeImage(mSettings.OutputImageSize, (InterpolationMode)interpCombo.SelectedItem);
            mResizedImage = tool.OutputImage;
            this.Cursor   = Cursors.Default;
            RedrawTab1Images();
        }
Beispiel #9
0
        public void RecolourImage(bool startAgain)
        {
            this.Cursor = Cursors.WaitCursor;
            ImagingTool tool;

            if (mRecolouredImage == null || startAgain)
            {
                CreateNewColourMap();
                tool = new ImagingTool(mResizedImage, ColourMap);
                //tool.ReduceColourDepth();
                tool.ReduceColourDepth(ColourMap);
                mRecolouredImage = tool.OutputImage;
            }
            else
            {
                tool = new ImagingTool(mRecolouredImage, ColourMap);
                tool.ReduceColourDepth((int)maxColoursUpDown.Value);
                mRecolouredImage = tool.OutputImage;
            }
            //UpdateColourMap();
            this.Cursor = Cursors.Default;
            RedrawTab2Images();
        }
Beispiel #10
0
 private void RedrawTab3Images()
 {
     this.Cursor = Cursors.WaitCursor;
     if (mRecolouredImage != null)
     {
         ImagingTool tool1 = new ImagingTool(mRecolouredImage);
         pictureBoxRecoloured2.Image = tool1.FitToControl(pictureBoxRecoloured2);
     }
     else
     {
         pictureBoxRecoloured2.Image = null;
     }
     if (mPatternImage != null)
     {
         ImagingTool tool2 = new ImagingTool(mPatternImage);
         pictureBoxPattern.Image = tool2.FitToControl(pictureBoxPattern);
     }
     else
     {
         pictureBoxPattern.Image = null;
     }
     updateFormFromSettings();
     this.Cursor = Cursors.Default;
 }
Beispiel #11
0
 private void RedrawTab3Images()
 {
     this.Cursor = Cursors.WaitCursor;
     if (mRecolouredImage != null)
     {
         ImagingTool tool1 = new ImagingTool(mRecolouredImage);
         pictureBoxRecoloured2.Image = tool1.FitToControl(pictureBoxRecoloured2);
     }
     else
     {
         pictureBoxRecoloured2.Image = null;
     }
     if (mPatternImage != null)
     {
         ImagingTool tool2 = new ImagingTool(mPatternImage);
         pictureBoxPattern.Image = tool2.FitToControl(pictureBoxPattern);
     }
     else
     {
         pictureBoxPattern.Image = null;
     }
     updateFormFromSettings();
     this.Cursor = Cursors.Default;
 }
Beispiel #12
0
        private void RedrawTab1Images()
        {
            this.Cursor = Cursors.WaitCursor;
            if (mInputImage != null)
            {
                ImagingTool tool1 = new ImagingTool(mInputImage);
                pictureBoxOriginal.Image = tool1.FitToControl(pictureBoxOriginal);
            }
            else
            {
                pictureBoxOriginal.Image = null;
            }
            if (mResizedImage != null)
            {
                ImagingTool tool2 = new ImagingTool(mResizedImage);
                pictureBoxResized.Image = tool2.FitToControl(pictureBoxOriginal);
            }
            else
            {
                pictureBoxResized.Image = null;
            }

            updateFormFromSettings();
            this.Cursor = Cursors.Default;
        }
Beispiel #13
0
 private void RedrawPattern()
 {
     if (mRecolouredImage != null)
     {
         ImagingTool tool3 = new ImagingTool(mRecolouredImage);
         tool3.ReplaceColoursWithPatterns(patternEditor);
         mPatternImage = tool3.OutputImage;
         pictureBoxPattern.Image = mPatternImage;
     }
 }
Beispiel #14
0
 void mColourViewer_ColourChangeEvent(object sender, ColourChangeEventArgs e)
 {
     if (mRecolouredImage == null) return;
     ImagingTool tool = new ImagingTool(mRecolouredImage, ColourMap);
     if (!e.DoReplace)
     {
         tool.RemoveFromPalette(e.Colour);
     }
     else
     {
         tool.ReplaceColour(e.Colour, e.ReplacementColour);
     }
     mRecolouredImage = tool.OutputImage;
     //UpdateColourMap();
     //showPalette(null, null);
     RedrawTab2Images();
 }
Beispiel #15
0
 public void ShowPatternEditor()
 {
     if (mRecolouredImage != null)
     {
         this.Cursor = Cursors.WaitCursor;
         ImagingTool tool = new ImagingTool(mRecolouredImage);
         patternEditor.UpdateColourMap();
         this.Cursor = Cursors.Default;
         patternEditor.Show();
         patternEditor.Focus();
     }
 }
Beispiel #16
0
 public void ResizeImage(object sender, EventArgs e)
 {
     if (mInputImage == null) return;
     this.Cursor = Cursors.WaitCursor;
     ImagingTool tool;
     if (mCroppedImage == null)
         tool = new ImagingTool(mInputImage, ColourMap);
     else
         tool = new ImagingTool(mCroppedImage, ColourMap);
     //mSettings.InputImageSize = mInputImage.Size;
     tool.ResizeImage(mSettings.OutputImageSize, (InterpolationMode)interpCombo.SelectedItem);
     mResizedImage = tool.OutputImage;
     this.Cursor = Cursors.Default;
     RedrawTab1Images();
 }
Beispiel #17
0
 public void RecolourImage(bool startAgain)
 {
     this.Cursor = Cursors.WaitCursor;
     ImagingTool tool;
     if (mRecolouredImage == null || startAgain)
     {
         CreateNewColourMap();
         tool = new ImagingTool(mResizedImage, ColourMap);
         //tool.ReduceColourDepth();
         tool.ReduceColourDepth(ColourMap);
         mRecolouredImage = tool.OutputImage;
     }
     else
     {
         tool = new ImagingTool(mRecolouredImage, ColourMap);
         tool.ReduceColourDepth((int)maxColoursUpDown.Value);
         mRecolouredImage = tool.OutputImage;
     }
     //UpdateColourMap();
     this.Cursor = Cursors.Default;
     RedrawTab2Images();
 }
Beispiel #18
0
 private void UpdateColourMap()
 {
     if (mRecolouredImage != null && ColourMap != null)
     {
         ImagingTool tool = new ImagingTool(mRecolouredImage, ColourMap);
         tool.UpdateColourMapFromImage();
         mSettings.MaxColours = ColourMap.Count;
         updateFormFromSettings();
         if (mColourViewer != null)
         {
             mColourViewer.UpdateColourMap(ColourMap);
         }
     }
 }
Beispiel #19
0
        public void LoadImage()
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                disposeColourViewer();
                mColourViewer = null;
                mInputImage = (Bitmap)Image.FromFile(mSettings.InputImagePath);
                if (mInputImage.Height > 1000 || mInputImage.Width > 1000)
                {
                    // too big. resize to be smaller.
                    float maxDim = Math.Max(mInputImage.Width, mInputImage.Height);
                    float scale = maxDim / 1000;
                    Size newSize = new Size((int)((float)mInputImage.Width / scale),(int)((float) mInputImage.Height / scale));
                    ImagingTool tool = new ImagingTool(mInputImage);
                    tool.ResizeImage(newSize,InterpolationMode.Default);
                    mInputImage = tool.OutputImage;

                }
                mSettings.InputImageSize = mInputImage.Size;
                mSettings.FixSizeRatio = fixRatioCheck.Checked;
                mResizedImage = null;
                //mCroppedImage = null;
                mRecolouredImage = null;
                mPatternImage = null;
            }
            catch (ArgumentException e)
            {
                MessageBox.Show("Ooops! Bad Argument" + Environment.NewLine + "Filename = " + mSettings.InputImagePath
                    + Environment.NewLine + e + Environment.NewLine + e.StackTrace);
            }
            finally { this.Cursor = Cursors.Default; }
            RedrawTab1Images();
            RedrawTab2Images();
            RedrawTab3Images();
        }
 private void setImage(Bitmap b)
 {
     ImagingTool tool = new ImagingTool(b);
     tool.ResizeImage(pictureBox.Size);
     pictureBox.Image = tool.OutputImage;
 }