private bool IsSimilarColor(Mosaic mosaic, Dot dot, RGBColor color, RGBColor offset) { if (offset == null) //Use pre-fined offset { if (this.greyCb.Checked) { if (mosaic.IsSimilarColor(dot, color, Convert.ToInt32(this.greyOffset.Value), Convert.ToInt32(this.greyOffset.Value), Convert.ToInt32(this.greyOffset.Value))) { return(true); } } else { if (mosaic.IsSimilarColor(dot, color, this.redCb.Checked ? Convert.ToInt32(this.redOffset.Value) : 0, this.greenCb.Checked ? Convert.ToInt32(this.redOffset.Value) : 0, this.blueCb.Checked ? Convert.ToInt32(this.redOffset.Value) : 0)) // if (!mosaic.IsSimilarColor(dot, color, Convert.ToInt32(this.redOffset.Value), Convert.ToInt32(this.greenOffset.Value), Convert.ToInt32(this.blueOffset.Value))) { return(true); } } } else if (offset.Red == 0 && offset.Green == 0 && offset.Blue == 0) //Use optimize offset { if (mosaic.IsSimilarColor(dot, color, optimizeOffset(color.Red), optimizeOffset(color.Green), optimizeOffset(color.Blue))) { return(true); } } else if (mosaic.IsSimilarColor(dot, color, offset.Red, offset.Green, offset.Blue)) { return(true); } return(false); }
private void ScanNextDot(Picture pic, Mosaic mosaic, Dot dot, RGBColor color) { if (mosaic.IsSimilarColor(dot, color, Convert.ToInt32(this.redOffset.Value), Convert.ToInt32(this.greenOffset.Value), Convert.ToInt32(this.blueOffset.Value))) { mosaic.AddIntoMosaicPiece(dot, color); pic.GetPixel(dot).Scanned = true; if (mosaic.Dots.Count >= 1000) { return; } ScanAround(pic, dot, mosaic); } }
//Return true if reaching the picture edge or liner private bool ScanDot1(Picture pic, Mosaic mosaic, Dot dot) { if (!pic.IsInside(dot) || pic.IsScanned(dot)) { return(true); } pic.GetPixel(dot).Scanned = true; if (!mosaic.IsSimilarColor(dot, pic.GetColor(dot), this.redCb.Checked ? Convert.ToInt32(this.redOffset.Value) : 0, this.greenCb.Checked ? Convert.ToInt32(this.redOffset.Value) : 0, this.blueCb.Checked ? Convert.ToInt32(this.redOffset.Value) : 0)) { mosaic.Dots.Add(dot); return(true); } return(false); }