public override Region CreateComplement(Region another) { CpuBlitRegion rgnB = another as CpuBlitRegion; if (rgnB == null) { return(null); } // // switch (rgnB.Kind) { default: throw new System.NotSupportedException(); case CpuBlitRegionKind.BitmapBasedRegion: { //TODO: review here BitmapBasedRegion bmpRgn = (BitmapBasedRegion)rgnB; } break; case CpuBlitRegionKind.MixedRegion: break; case CpuBlitRegionKind.VxsRegion: //TODO: review complement break; } return(null); }
BitmapBasedRegion CreateNewRegion(BitmapBasedRegion another, SetOperationName opName) { // MemBitmap myBmp = this.GetRegionBitmap(); //or create new as need MemBitmap anotherBmp = another.GetRegionBitmap(); //do bitmap union //2 rgn merge may Rectangle r1Rect = this.GetRectBounds(); Rectangle r2Rect = another.GetRectBounds(); Rectangle r3Rect = Rectangle.Union(r1Rect, r2Rect); // MemBitmap r3Bmp = new MemBitmap(r3Rect.Width, r3Rect.Height); r3Bmp.Clear(Color.Black); MaskBitmapReader r1 = new MaskBitmapReader(); r1.SetBitmap(myBmp); MaskBitmapReader r2 = new MaskBitmapReader(); r2.SetBitmap(anotherBmp); MaskBitmapWriter w3 = new MaskBitmapWriter(); w3.SetBitmap(r3Bmp); int height = r3Rect.Height; int width = r3Rect.Width; switch (opName) { case SetOperationName.Union: for (int y = 0; y < height; ++y) { r1.MoveTo(0, y); r2.MoveTo(0, y); w3.MoveTo(0, y); for (int x = 0; x < width; ++x) { w3.Union(r1.Read(), r2.Read()); r1.MoveRight(); r2.MoveRight(); w3.MoveRight(); } } break; case SetOperationName.Intersect: for (int y = 0; y < height; ++y) { r1.MoveTo(0, y); r2.MoveTo(0, y); w3.MoveTo(0, y); for (int x = 0; x < width; ++x) { w3.Intersect(r1.Read(), r2.Read()); r1.MoveRight(); r2.MoveRight(); w3.MoveRight(); } } break; case SetOperationName.Diff: for (int y = 0; y < height; ++y) { r1.MoveTo(0, y); r2.MoveTo(0, y); w3.MoveTo(0, y); for (int x = 0; x < width; ++x) { w3.Diff(r1.Read(), r2.Read()); r1.MoveRight(); r2.MoveRight(); w3.MoveRight(); } } break; case SetOperationName.Xor: for (int y = 0; y < height; ++y) { r1.MoveTo(0, y); r2.MoveTo(0, y); w3.MoveTo(0, y); for (int x = 0; x < width; ++x) { w3.Xor(r1.Read(), r2.Read()); r1.MoveRight(); r2.MoveRight(); w3.MoveRight(); } } break; } return(new BitmapBasedRegion(r3Bmp)); }