private static Container containerOR(Container ca, Container cb) { BitmapContainer a = null; BitmapContainer b = null; if (ca is BitmapContainer) { a = (BitmapContainer)ca; } else { a = (BitmapContainer)ca.Change(); } if (cb is BitmapContainer) { b = (BitmapContainer)cb; } else { b = (BitmapContainer)cb.Change(); } var av = a.Values(); var bv = b.Values(); var la = av != null ? av.Length : 1024; var lb = bv != null ? bv.Length : 1024; var max = la; if (lb > max) { max = lb; } List <ulong> vals = new List <ulong>(); for (int i = 0; i < max; i++) { ulong ua = 0; ulong ub = 0; if (av != null && i < la) { ua = av[i]; } if (bv != null && i < lb) { ub = bv[i]; } vals.Add(ua | ub); } return(new BitmapContainer(vals.ToArray())); }
private static Container containerAND(Container ca, Container cb) { BitmapContainer a = null; BitmapContainer b = null; if (ca is BitmapContainer) { a = (BitmapContainer)ca; } else { a = (BitmapContainer)ca.Change(); } if (cb is BitmapContainer) { b = (BitmapContainer)cb; } else { b = (BitmapContainer)cb.Change(); } var av = a.Values(); var bv = b.Values(); var la = av != null ? av.Length : 1024; var lb = bv != null ? bv.Length : 1024; var min = la; if (lb < min) { min = lb; } List <ulong> vals = new List <ulong>(); for (int i = 0; i < min; i++) { ulong ua = ulong.MaxValue; ulong ub = ulong.MaxValue; if (av != null) { ua = av[i]; } if (bv != null) { ub = bv[i]; } vals.Add(ua & ub); } return(new BitmapContainer(vals.ToArray())); }