/// <summary> /// Create the mipmaps by downsampling using a filter. /// </summary> public void GenerateMipmaps(Filter filter) { for (int i = 1; i < Levels; i++) { TextureData2D src = Data[i - 1]; TextureData2D dst = Data[i]; int srcWidth = src.GetWidth(); int srcHeight = src.GetHeight(); int dstWidth = dst.GetWidth(); int dstHeight = dst.GetHeight(); float[] tmp = new float[dstWidth * srcHeight * Channels]; PolyphaseKernel xKernel = new PolyphaseKernel(filter, srcWidth, dstWidth, 32); PolyphaseKernel yKernel = new PolyphaseKernel(filter, srcHeight, dstHeight, 32); for (int y = 0; y < srcHeight; y++) { xKernel.ApplyHorizontal(y, src, tmp, dstWidth); } for (int x = 0; x < dstWidth; x++) { yKernel.ApplyVertical(x, tmp, dstWidth, srcHeight, Channels, dst); } } }