// Create a MemoryStream with publicly visible buffer
cli.System.IO.MemoryStream stream = new cli.System.IO.MemoryStream(1024);
EncoderParameters params = new EncoderParameters(2);
try {
params.get_Param()[0] = new EncoderParameter(Encoder.LuminanceTable, qTableToShortArray(qTables[0]));
params.get_Param()[1] = new EncoderParameter(Encoder.ChrominanceTable, qTableToShortArray(qTables[1]));
bitmap.Save(stream, codec, params);
}
finally {
params.Dispose();
}