public void Decode2D(IntPtr input, int width, int height, int inputWidthStride, int inputOffset, IntPtr output, int outputWidthStride = -1, int outputOffset = -1) { if (outputWidthStride == -1) { outputWidthStride = inputWidthStride; } if (outputOffset == -1) { outputOffset = inputOffset; } // Decode rows for (int row = 0; row < height; row++) { Decode1D(input, width, 1, inputOffset + row * inputWidthStride, output, 1, outputOffset + row * outputWidthStride); } IntPtr buffer = Marshal.AllocHGlobal(width * height * ElementSize); MemoryAllocator.Copy2D(output, width, height, outputWidthStride, outputOffset, buffer, width, 0, ElementSize); // Decode columns for (int column = 0; column < width; column++) { Decode1D(buffer, height, width, column, output, outputWidthStride, outputOffset + column); } Marshal.FreeHGlobal(buffer); }
private void Decode2D(IntPtr input, int width, int height, int inputWidthStride, int inputOffset, IntPtr output, int outputWidthStride, int outputOffset, int level) { if (level < MaximumLevelNumber && width > MinimumBandSize && height > MinimumBandSize) { Decode2D(input, (width + 1) / 2, (height + 1) / 2, inputWidthStride, inputOffset, output, outputWidthStride, outputOffset, level + 1); _waveletTransformation.Decode2D(input, width, height, inputWidthStride, inputOffset, output, outputWidthStride, outputOffset); MemoryAllocator.Copy2D(output, width, height, outputWidthStride, outputOffset, input, inputWidthStride, inputOffset, ElementSize); } }
public void Encode2D(IntPtr input, int width, int height, int inputWidthStride, int inputOffset, IntPtr output, int outputWidthStride = -1, int outputOffset = -1) { if (outputWidthStride == -1) { outputWidthStride = inputWidthStride; } if (outputOffset == -1) { outputOffset = inputOffset; } IntPtr buffer = Marshal.AllocHGlobal(width * height * ElementSize); MemoryAllocator.Copy2D(input, width, height, inputWidthStride, inputOffset, buffer, width, 0, ElementSize); Encode2D(buffer, width, height, width, 0, output, outputWidthStride, outputOffset, 0); Marshal.FreeHGlobal(buffer); }
private void Encode2D(IntPtr input, int width, int height, int inputWidthStride, int inputOffset, IntPtr output, int outputWidthStride, int outputOffset, int level) { if (level < MaximumLevelNumber && width > MinimumBandSize && height > MinimumBandSize) { _waveletTransformation.Encode2D(input, width, height, inputWidthStride, inputOffset, output, outputWidthStride, outputOffset); width++; height++; width /= 2; height /= 2; level++; if (level < MaximumLevelNumber && width > MinimumBandSize && height > MinimumBandSize) { MemoryAllocator.Copy2D(output, width, height, outputWidthStride, outputOffset, input, inputWidthStride, 0, ElementSize); Encode2D(input, width, height, inputWidthStride, inputOffset, output, outputWidthStride, outputOffset, level); } } }