internal FormatChannel(FormatChannelIndex channel, FormatChannelType type, int bits) { this.channel = channel; this.type = type; this.bits = bits; }
internal Format(PixelInternalFormat?internalFormat, PixelFormat format, PixelType?type, int rows, int columns, FormatChannelType channelType, int channelBits) : this(internalFormat, format, type) { int realCount = (rows == -1 || rows == -2) ? 1 : (rows == -3) ? 2 : rows; FormatChannel[,] channels = new FormatChannel[rows, columns]; if (rows == -1) { channels[0, 0] = new FormatChannel(FormatChannelIndex.Depth, channelType, channelBits); } else if (rows == -2) { channels[1, 0] = new FormatChannel(FormatChannelIndex.Stencil, channelType, channelBits); } else if (rows < 0) { throw new Exception(); } else { for (int column = 0; column < columns; column++) { for (int row = 0; row < rows; row++) { FormatChannelIndex index; if (columns > 1) { index = FormatChannelIndex.Cell; } else if (format == PixelFormat.Bgr || format == PixelFormat.Bgra) { switch (row) { case 0: index = FormatChannelIndex.Blue; break; case 1: index = FormatChannelIndex.Green; break; case 2: index = FormatChannelIndex.Red; break; case 3: index = FormatChannelIndex.Alpha; break; default: throw new Exception(); } } else { switch (row) { case 0: index = FormatChannelIndex.Red; break; case 1: index = FormatChannelIndex.Green; break; case 2: index = FormatChannelIndex.Blue; break; case 3: index = FormatChannelIndex.Alpha; break; default: throw new Exception(); } } channels[row, column] = new FormatChannel(index, channelType, channelBits); } } } this.channels = new FormatChannelCollection(channels); SetupChannels(); }