Пример #1
0
        public static bool TryGetSpanBitmap <T>(this Imaging.TensorBitmap <T> src, out SpanBitmap dst)
            where T : unmanaged
        {
            if (src.NumChannels != 1)
            {
                dst = default; return(false);
            }

            var fmt = GetFormat <T>(src.Encoding);

            dst = new SpanBitmap(src.GetChannelX <Byte>(), src.Width, src.Height, fmt);
            return(true);
        }
Пример #2
0
        public static void CopyTo <TSrc, TDst>(this Imaging.TensorBitmap <TSrc> src, ref MemoryBitmap <TDst> dst)
            where TSrc : unmanaged
            where TDst : unmanaged
        {
            if (dst.Width != src.Width || dst.Height != src.Height)
            {
                dst = new MemoryBitmap <TDst>(src.Width, src.Height);
            }

            for (int y = 0; y < dst.Height; y++)
            {
                for (int x = 0; x < dst.Width; x++)
                {
                    var pixel = src.GetPixel(x, y);
                    var rgba  = new Pixel.RGBA128F(pixel).To <TDst>();
                    dst.SetPixel(x, y, rgba);
                }
            }
        }
Пример #3
0
        public void CopyTo <TOther>(TensorBitmap <TOther> dst)
            where TOther : unmanaged
        {
            if (this._Width != dst._Width)
            {
                throw new ArgumentException("width mismatch", nameof(dst));
            }
            if (this._Height != dst._Height)
            {
                throw new ArgumentException("height mismatch", nameof(dst));
            }

            for (int y = 0; y < dst._Height; ++y)
            {
                for (int x = 0; x < dst._Width; ++x)
                {
                    var value = this.GetPixel(x, y);
                    dst.SetPixel(x, y, value);
                }
            }
        }
Пример #4
0
 public static unsafe void FillBitmap(this Imaging.TensorBitmap <Vector3> dst, SpanBitmap src, in Imaging.BitmapTransform xform)