public override byte[] Encode(byte[] source, int sourceIndex, int width, int height) { // Destination data & index byte[] destination = new byte[width * height * (PixelCodec.Bpp >> 3)]; int destinationIndex = 0; // Get the size of each block to process. int size = Math.Min(width, height); // Twiddle map int[] twiddleMap = MakeTwiddleMap(size); // Encode texture data for (int y = 0; y < height; y += size) { for (int x = 0; x < width; x += size) { for (int y2 = 0; y2 < size; y2++) { for (int x2 = 0; x2 < size; x2++) { PixelCodec.EncodePixel(source, sourceIndex + ((((y + y2) * width) + (x + x2)) * 4), destination, destinationIndex + (((twiddleMap[x2] << 1) | twiddleMap[y2]) << (PixelCodec.Bpp >> 4))); } } destinationIndex += (size * size) * (PixelCodec.Bpp >> 3); } } return(destination); }
public override byte[] Encode(byte[] source, int sourceIndex, int width, int height) { // Destination data byte[] destination = new byte[width * height * (PixelCodec.Bpp >> 3)]; // Encode texture data for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { PixelCodec.EncodePixel(source, sourceIndex, destination, GetSwizzledOffset(x, y, width, height, PixelCodec.Bpp)); sourceIndex += 4; } } return(destination); }
public override byte[] Encode(byte[] source, int sourceIndex, int width, int height) { // Destination data & index byte[] destination = new byte[width * height * (PixelCodec.Bpp >> 3)]; int destinationIndex = 0; // Encode texture data for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { PixelCodec.EncodePixel(source, sourceIndex, destination, destinationIndex); sourceIndex++; destinationIndex++; } } return(destination); }
public override byte[] Encode(byte[] source, int sourceIndex, int width, int height) { // Destination data byte[] destination = new byte[width * height * (PixelCodec.Bpp >> 3)]; // Twiddle map int[] twiddleMap = MakeTwiddleMap(width); // Encode texture data for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { PixelCodec.EncodePixel(source, sourceIndex, destination, ((twiddleMap[x] << 1) | twiddleMap[y]) << (PixelCodec.Bpp >> 4)); sourceIndex += 4; } } return(destination); }