CrossStitchCreator.ImagingTool.ReplaceColoursWithPatterns C# (CSharp) Method

ReplaceColoursWithPatterns() public method

public ReplaceColoursWithPatterns ( object p, BackgroundWorker w, DoWorkEventArgs e ) : object
p object
w System.ComponentModel.BackgroundWorker
e System.ComponentModel.DoWorkEventArgs
return object
        public object ReplaceColoursWithPatterns(object p, BackgroundWorker w, DoWorkEventArgs e)
        {
            if (mPatterns == null) { e.Cancel = true; return this; }
            int pScale = PatternEditor.PATTERN_WIDTH;
            Bitmap orig = mOutput;
            Bitmap b = new Bitmap(orig.Width * pScale, orig.Height * pScale, PixelFormat.Format24bppRgb);

            Graphics g = Graphics.FromImage(b);
            //AdriansLib.ProgressBarForm prog = new AdriansLib.ProgressBarForm("Replacing Colours With Patterns...", orig.Width * orig.Height);
            //prog.Show();
            int co = 0;
            for (int x = 0; x < orig.Width; x++)
                for (int y = 0; y < orig.Height; y++)
                {
                    if (w.CancellationPending) { e.Cancel = true; return this; }
                    Color c = orig.GetPixel(x, y);
                    Bitmap i = mPatterns[c];
                    g.DrawImage(i, x * pScale, y * pScale);
                    if (x % 5 == 0)
                        g.DrawLine(Pens.Gray, x * pScale - 1, y * pScale - 1, (x) * pScale - 1, (y + 1) * pScale - 1);
                    if (y % 5 == 0)
                        g.DrawLine(Pens.Gray, x * pScale - 1, y * pScale - 1, (x + 1) * pScale - 1, (y) * pScale - 1);
                    w.ReportProgress((co++) * 100 / (b.Width * b.Height));
                }
            g.Dispose();
            mOutput = b;
            return this;
        }

Same methods

ImagingTool::ReplaceColoursWithPatterns ( PatternEditor patterns ) : void

Usage Example

コード例 #1
0
 private void RedrawPattern()
 {
     if (mRecolouredImage != null)
     {
         ImagingTool tool3 = new ImagingTool(mRecolouredImage);
         tool3.ReplaceColoursWithPatterns(patternEditor);
         mPatternImage           = tool3.OutputImage;
         pictureBoxPattern.Image = mPatternImage;
     }
 }
All Usage Examples Of CrossStitchCreator.ImagingTool::ReplaceColoursWithPatterns