//public PixelByte Clone() => base.clone<byte>().Create(Width, Height); // public static TOutput[] ConvertAll<TInput, TOutput>(TInput[] array1, TInput[] array2, Func<TInput, TInput, TOutput> conv) // where TOutput : struct // { // if (array1.Length != array2.Length) // throw new ArgumentOutOfRangeException("Array Size"); // TOutput[] result = new TOutput[array1.Length]; //#if MultipleCore // 普通の方が圧倒的に早い // ParallelOptions options = new ParallelOptions(){ MaxDegreeOfParallelism = 4}; // Parallel.For(0, array1.Length, options, // (i) => result[i] = conv(array1[i], array2[i])); //#else // for (int i = 0; i < array1.Length; i++) // result[i] = conv(array1[i], array2[i]); //#endif // return result; // } #endregion #region チェック protected static void OperatorCheck(PixelBase <T> x, PixelBase <T> y) { if (x.Size != y.Size) { throw new ArgumentOutOfRangeException("OperatorCheck"); } }
protected static PArray <T> JoinVertical(PixelBase <T> top, PixelBase <T> bottom) { T[] buf = new T[top.Size + bottom.Size]; int count = 0; for (int i = 0; i < top.Size; i++) { buf[count++] = top[i]; } for (int i = 0; i < bottom.Size; i++) { buf[count++] = bottom[i]; } return(new PArray <T>() { p = buf, h = top.Height + bottom.Height, w = top.Width }); }
protected static PArray <T> JoinHorizontal(PixelBase <T> left, PixelBase <T> right) { T[] buf = new T[left.Size + right.Size]; int count = 0; for (int y = 0; y < left.Height; y++) { for (int x_left = 0; x_left < left.Width; x_left++) { buf[count++] = left[x_left, y]; } for (int x_right = 0; x_right < right.Width; x_right++) { buf[count++] = right[x_right, y]; } } return(new PArray <T>() { p = buf, w = left.Width + right.Width, h = left.Height }); }