コード例 #1
0
 public static void WriteToImage(string data, Image image)
 {
     if (data == null) throw new ArgumentNullException(nameof(data));
     if (image == null) throw new ArgumentNullException(nameof(image));
     using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(data)))
     using (var bdStream = new BitmapDataStream((Bitmap) image))
     {
         bdStream.SetLength(0);
         using (var gZipStream = new GZipStream(bdStream, CompressionMode.Compress))
             memoryStream.CopyTo(gZipStream);
     }
 }