internal PdfImageContent(PdfImage image, double posx, double posy, double DPI)
 {
     this.image = image;
     this.posx = posx;
     this.dpi = DPI;
     this.posy = posy - this.TargetHeight;
 }
예제 #2
0
        internal void Add(byte[] jpegImage, double posx, double posy, double DPI)
        {
            if (DPI <= 0)
            {
                throw new Exception("DPI must be greater than zero.");
            }

            string   hash = BitConverter.ToInt32(MD5.Create().ComputeHash(jpegImage), 12).ToString("X");
            PdfImage pi   = (PdfImage)this.PdfDocument.images[hash];

            if (pi == null)
            {
                pi = this.PdfDocument.NewImage(jpegImage, hash);
                this.PdfDocument.images.Add(hash, pi);
            }

            if (!this.Images.Contains(pi))
            {
                this.Images.Add(pi);
            }

            PdfImageContent pic = new PdfImageContent(pi, posx, this.Height - posy, DPI);

            this.PdfStream.StreamObjectElements.Add(pic);
        }
예제 #3
0
 internal PdfImage NewImage(byte[] imageData, string hash)
 {
     using (MemoryStream ms = new MemoryStream(imageData))
     {
         using (Image i = Image.FromStream(ms))
         {
             using (MemoryStream ms2 = new MemoryStream())
             {
                 i.Save(ms2, ImageFormat.Jpeg);
                 PdfImage pi = new PdfImage(this, ms2.ToArray(), i.Width, i.Height, hash);
                 return(pi);
             }
         }
     }
 }
 internal PdfImage NewImage(byte[] imageData,string hash)
 {
     using (MemoryStream ms = new MemoryStream(imageData))
     {
         using (Image i = Image.FromStream(ms))
         {
             using (MemoryStream ms2 = new MemoryStream())
             {
                 i.Save(ms2, ImageFormat.Jpeg);
                 PdfImage pi = new PdfImage(this, ms2.ToArray(), i.Width, i.Height,hash);
                 return pi;
             }
         }
     }
 }