/// <summary> /// A Webp lossless image can go through four different types of transformation before being entropy encoded. /// This will reverse the transformations, if any are present. /// </summary> /// <param name="decoder">The decoder holding the transformation infos.</param> /// <param name="pixelData">The pixel data to apply the transformation.</param> /// <param name="memoryAllocator">The memory allocator is needed to allocate memory during the predictor transform.</param> public static void ApplyInverseTransforms(Vp8LDecoder decoder, Span <uint> pixelData, MemoryAllocator memoryAllocator) { List <Vp8LTransform> transforms = decoder.Transforms; for (int i = transforms.Count - 1; i >= 0; i--) { Vp8LTransform transform = transforms[i]; Vp8LTransformType transformType = transform.TransformType; switch (transformType) { case Vp8LTransformType.PredictorTransform: using (IMemoryOwner <uint> output = memoryAllocator.Allocate <uint>(pixelData.Length, AllocationOptions.Clean)) { LosslessUtils.PredictorInverseTransform(transform, pixelData, output.GetSpan()); } break; case Vp8LTransformType.SubtractGreen: LosslessUtils.AddGreenToBlueAndRed(pixelData); break; case Vp8LTransformType.CrossColorTransform: LosslessUtils.ColorSpaceInverseTransform(transform, pixelData); break; case Vp8LTransformType.ColorIndexingTransform: LosslessUtils.ColorIndexInverseTransform(transform, pixelData); break; } } }
public Vp8LTransform(Vp8LTransformType transformType, int xSize, int ySize) { this.TransformType = transformType; this.XSize = xSize; this.YSize = ySize; }