コード例 #1
0
        /// <summary>
        /// Write image
        /// </summary>
        /// <param name="image">Image</param>
        /// <param name="width">Pixel width</param>
        /// <param name="height">Pixel height</param>
        /// <param name="imageData">Image binary data</param>
        public void WriteImage(Image image, int width, int height, byte[] imageData)
        {
            if (imageData == null)
            {
                return;
            }

            var memoryStream = new MemoryStream();

            image.Save(memoryStream, ImageFormat.Jpeg);
            memoryStream.Close();
            var bs = memoryStream.ToArray();

            Writer.WriteStartGroup();

            Writer.WriteKeyword("pict");
            Writer.WriteKeyword("jpegblip");
            Writer.WriteKeyword("picscalex" + Convert.ToInt32(width * 100.0 / image.Size.Width));
            Writer.WriteKeyword("picscaley" + Convert.ToInt32(height * 100.0 / image.Size.Height));
            Writer.WriteKeyword("picwgoal" + Convert.ToString(image.Size.Width * 15));
            Writer.WriteKeyword("pichgoal" + Convert.ToString(image.Size.Height * 15));
            Writer.WriteBytes(bs);
            Writer.WriteEndGroup();
        }