private static Complex[,] FromBitmapData(BitmapData _BitmapData)
{
if (_BitmapData.PixelFormat != PixelFormat.Format8bppIndexed)
{
throw new Exception("Source can be grayscale (8bpp indexed) only.");
}
int width = _BitmapData.Width;
int height = _BitmapData.Height;
int offset = _BitmapData.Stride - width;
if ((!Utils.IsPowerOf2(width)) || (!Utils.IsPowerOf2(height)))
{
throw new Exception("Image width and height should be power of 2.");
}
Complex[,] data = new Complex[width, height];
unsafe
{
byte* src = (byte*)_BitmapData.Scan0.ToPointer();
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++, src++)
{
data[y, x] = new Complex((float)*src/255,
data[y, x].Imaginary);
}
src += offset;
}
}
return data;
}
Почему значение указано *src
делится на 255?небезопасный код информация