static void Process8BitIndexedRow(ImageLine imageLine, Chunks.PngChunkPLTE plte, Chunks.PngChunkTRNS trns, Color[] pixels) { #if DEBUG UnityEngine.Assertions.Assert.IsNotNull(trns, "make sure this image contains no transparency data"); #endif int row = imageLine.ImageRow; ImageInfo imgInfo = imageLine.ImgInfo; int numRows = imgInfo.Rows; int numCols = imgInfo.Cols; int bitDepth = imgInfo.BitDepth; int channels = imgInfo.Channels;// int channels = 4; float max = GetBitDepthMaxValue(bitDepth); int[] paletteAlpha = trns.PaletteAlpha; int numIndicesWithAlpha = paletteAlpha.Length; if (imageLine.SampleType == ImageLine.ESampleType.BYTE) { byte[] scanline = imageLine.ScanlineB; for (int col = 0; col < numCols; col++) { int index = scanline[col] & 0xFF; RGB <int> rgb = plte.GetEntryRgb(index, col * channels); RGBA <int> rgba = rgb.RGBA(index < numIndicesWithAlpha ? paletteAlpha[index] : 255); pixels[IndexPngToTexture(row, col, numRows, numCols)] = RGBA.ToColor(rgba, max); } } else { int[] scanline = imageLine.Scanline; for (int col = 0; col < numCols; col++) { int index = scanline[col]; RGB <int> rgb = plte.GetEntryRgb(index, col * channels); RGBA <int> rgba = rgb.RGBA(index < numIndicesWithAlpha ? paletteAlpha[index] : 255); pixels[IndexPngToTexture(row, col, numRows, numCols)] = RGBA.ToColor(rgba, max); } } }