public void WriteBitmapSource(BitmapSource value) { if (value == null) { WriteInt(0); return; } byte[] data = value.GetBytes(); WriteInt(data.Length); WriteBytes(data); }
public static Vector <Byte>[] GetColors([NotNull] this BitmapSource bitmap) { if (bitmap.Format != PixelFormats.Bgr32) { throw new NotSupportedException(string.Format("Getting RGB colors for '{0}' is not supported", bitmap.Format)); } var bytes = bitmap.GetBytes(); var result = new Vector <byte> [bytes.Length / 4]; for (var i = 0; i < bytes.Length; i += 4) { result[i / 4] = new Vector <byte>(new [] { bytes[i + 2], bytes[i + 1], bytes[i] }); } return(result); }
public static BitmapSource ApplyWavelet(BitmapSource bitmap, WaveletParameters waveletParameters) { if (bitmap.Format != PixelFormats.Gray8) { var colors = bitmap.GetColors(); //var yCrCb = Transformation.RGBToYCbCr(colors); var channels = GetChannels(colors, bitmap.PixelHeight, bitmap.PixelWidth); for (var channel = 0; channel < 3; ++channel) { DoApplyWavelet(channels[channel], waveletParameters); } SaveWavelet(bitmap, waveletParameters, channels); return(bitmap.Create(ToColors(channels))); } var bytes = bitmap.GetBytes(); var channl = GetChannel(bytes, bitmap.PixelHeight, bitmap.PixelWidth); DoApplyWavelet(channl, waveletParameters); SaveWavelet(bitmap, waveletParameters, new Vector <double[, ]>(new[] { channl })); return(bitmap.Create(ToGrey(channl))); }