public static BitmapSource DecodeDct(DctParameters dctParameters) { var encoded = Jpeg.Load(dctParameters); var encodedMatrices = SplitToBlocksInt(encoded, 8); var dequantizedMatrices = DequantizeMatrices(encodedMatrices, dctParameters); var dct = GetDctMatrix(); var transposedDct = dct.Transpose(); var inversedDct = ApplyDct(dequantizedMatrices, transposedDct, dct); var flattened = FlattenByte(inversedDct); var undecimated = Undecimate(flattened, dctParameters.DecimationType); var inRgb = ToRgbBytes(undecimated); return(BitmapSource.Create(undecimated.GetLength(0), undecimated.GetLength(1), 96.0, 96.0, PixelFormats.Bgr32, null, inRgb, inRgb.Length / undecimated.GetLength(0))); }