Пример #1
0
        public static Texture2DArray GifToTextureArray(string path)
        {
            Texture2DArray array = null;

#if DOT_NET_TWO_POINT_ZERO_OR_ABOVE
#if IMAGING_DLL_EXISTS
            EditorUtility.DisplayProgressBar("Creating Texture Array for " + path, "", 0);
            System.Drawing.Image IMG = System.Drawing.Image.FromFile(path);
            int Length = IMG.GetFrameCount(FrameDimension.Time);

            IMG.SelectActiveFrame(FrameDimension.Time, 0);
            array = new Texture2DArray(IMG.Width, IMG.Height, Length, TextureFormat.RGBA32, true, false);

            for (int i = 0; i < Length; i++)
            {
                EditorUtility.DisplayProgressBar("Creating Texture Array for " + path, "Converting frame #" + i, (float)i / Length);
                IMG.SelectActiveFrame(FrameDimension.Time, i);
                System.Drawing.Bitmap bitmap   = new System.Drawing.Bitmap(IMG);
                MemoryStream          msFinger = new MemoryStream();
                IMG.Save(msFinger, bitmap.RawFormat);
                Texture2D texture = new Texture2D(IMG.Width, IMG.Height);
                texture.LoadImage(msFinger.ToArray());
                array.SetPixels(texture.GetPixels(), i);
            }
            IMG.Dispose();
            EditorUtility.ClearProgressBar();

            array.Apply();
            string newPath = path.Replace(".gif", ".asset");
            AssetDatabase.CreateAsset(array, newPath);
#endif
#endif
            return(array);
        }
Пример #2
0
        public void LoadFrames()
        {
            System.Drawing.Imaging.FrameDimension frameDimension = new System.Drawing.Imaging.FrameDimension(Image.FrameDimensionsList[0]);
            Data.FramesCount = Image.GetFrameCount(frameDimension);

            for (int i = 0; i < Data.FramesCount; i++)
            {
                if (Data.CancelLoading)
                {
                    return;
                }

                Image.SelectActiveFrame(frameDimension, i);
                Quantizer = new ImageManipulation.OctreeQuantizer(255, 8);

                System.Drawing.Bitmap quantized = Quantizer.Quantize(Image);
                MemoryStream          stream    = new MemoryStream();
                quantized.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                Data.Frames.Add(new Texture(stream));

                stream.Dispose();

                if (Data.CancelLoading)
                {
                    return;
                }

                Data.Frames[i].Smooth = Data.Smooth;
                Data.Frames[i].Mipmap = Data.Mipmap;
            }
            Data.FullyLoaded = true;
        }
Пример #3
0
        public GifInfoCache(ImageStorage image)
        {
            var frameDimension = new FrameDimension(image.FrameDimensionsList[0]);

            image.SelectActiveFrame(frameDimension, 0);

            this.IsLooping         = BitConverter.ToInt16(image.GetPropertyItem(kIsLooping).Value, 0) != 1;
            this.SourcePixelWidth  = image.Width;
            this.SourcePixelHeight = image.Height;

            int frameCount = image.GetFrameCount(frameDimension);

            this.Frames = new List <GifFrame>(frameCount);
            for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex)
            {
                image.SelectActiveFrame(frameDimension, frameIndex);
                this.Frames.Add(new GifFrame(this, image, frameIndex));
            }
        }
Пример #4
0
        private void SetImageFrames(MemoryStream memoryStream)
        {
            Frames = new List <ImageFrame>();

            System.Drawing.Image gif = System.Drawing.Image.FromStream(memoryStream);

            FrameDimension fd    = new FrameDimension(gif.FrameDimensionsList[0]);
            int            count = gif.GetFrameCount(fd);

            byte[] delayByte = new byte[4];//延迟时间,以1/100秒为单位

            for (int i = 0; i < count; i++)
            {
                gif.SelectActiveFrame(fd, i);
                MemoryStream ms = new MemoryStream();
                {
                    gif.Save(ms, ImageFormat.Png);

                    BitmapImage imgSource = new BitmapImage();
                    imgSource.BeginInit();
                    imgSource.StreamSource = ms;
                    imgSource.EndInit();

                    imgSource.Freeze();
                    //BitmapImage imgSource = new BitmapImage(new Uri(path));
                    ImageFrame frame = new ImageFrame()
                    {
                        BSource = imgSource, Stream = ms
                    };
                    Frames.Add(frame);

                    for (int j = 0; j < gif.PropertyIdList.Length; j++)                       //遍历帧属性
                    {
                        if ((int)gif.PropertyIdList.GetValue(j) == 0x5100)                    //.如果是延迟时间
                        {
                            PropertyItem pItem = (PropertyItem)gif.PropertyItems.GetValue(j); //获取延迟时间属性

                            delayByte[0] = pItem.Value[i * 4];
                            delayByte[1] = pItem.Value[1 + i * 4];
                            delayByte[2] = pItem.Value[2 + i * 4];
                            delayByte[3] = pItem.Value[3 + i * 4];
                            int delay = BitConverter.ToInt32(delayByte, 0) * 10;
                            frame.Delay = delay <= 0 ? 100 : delay;
                            break;
                        }
                    }
                }
            }

            gif       = null;
            fd        = null;
            delayByte = null;

            FramesLoaded?.Invoke(Frames);
        }
Пример #5
0
        private static void ConvertImageToPdf(string inputFileName, string outputFileName)
        {
            // Create Aspose.Words.Document and DocumentBuilder.
            // The builder makes it simple to add content to the document.
            Aspose.Words.Document doc     = new Aspose.Words.Document();
            DocumentBuilder       builder = new DocumentBuilder(doc);

            // Read the image from file, ensure it is disposed.
            using (System.Drawing.Image image = System.Drawing.Image.FromFile(inputFileName))
            {
                // Find which dimension the frames in this image represent. For example
                // the frames of a BMP or TIFF are "page dimension" whereas frames of a GIF image are "time dimension".
                FrameDimension dimension = new FrameDimension(image.FrameDimensionsList[0]);

                int framesCount = image.GetFrameCount(dimension);
                // Get the number of frames in the image.
                framesCount = image.GetFrameCount(FrameDimension.Page);


                // Loop through all frames.
                for (int frameIdx = 0; frameIdx < framesCount; frameIdx++)
                {
                    // Insert a section break before each new page, in case of a multi-frame TIFF.
                    if (frameIdx != 0)
                    {
                        builder.InsertBreak(BreakType.SectionBreakNewPage);
                    }

                    // Select active frame.
                    image.SelectActiveFrame(dimension, frameIdx);

                    // We want the size of the page to be the same as the size of the image.
                    // Convert pixels to points to size the page to the actual image size.
                    PageSetup ps = builder.PageSetup;
                    ps.PageWidth  = ConvertUtil.PixelToPoint(image.Width, image.HorizontalResolution);
                    ps.PageHeight = ConvertUtil.PixelToPoint(image.Height, image.VerticalResolution);

                    // Insert the image into the document and position it at the top left corner of the page.
                    builder.InsertImage(
                        image,
                        RelativeHorizontalPosition.Page,
                        0,
                        RelativeVerticalPosition.Page,
                        0,
                        ps.PageWidth > 950 ? 950 : ps.PageWidth,
                        ps.PageHeight > 950 ? 950 : ps.PageHeight,
                        WrapType.None);
                }
            }

            // Save the document to PDF.
            doc.Save(outputFileName);
        }
Пример #6
0
        public static void SplitTiff(string fileName)
        {
            System.Drawing.Image imageFile = System.Drawing.Image.FromFile(fileName);
            System.Drawing.Imaging.FrameDimension frameDimensions = new System.Drawing.Imaging.FrameDimension(imageFile.FrameDimensionsList[0]);
            int numberOfImages = imageFile.GetFrameCount(frameDimensions);

            System.Drawing.Image[] img = new System.Drawing.Image[numberOfImages];
            for (int intFrame = 0; intFrame < numberOfImages; intFrame++)
            {
                imageFile.SelectActiveFrame(frameDimensions, intFrame);
                img[intFrame] = imageFile;
            }
            img[0].Save(@"C:\YpiiData\test55.tif");
        }
Пример #7
0
        private void generujAktualnyObrazek()
        {
            _obrazekRoboczy.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, this._aktualnaStrona);
            this._szerokosc = _obrazekRoboczy.Width;
            this._wysokosc  = _obrazekRoboczy.Height;
            System.Drawing.Image tmp = _obrazekRoboczy.GetThumbnailImage(this._szerokosc * this._skala / 100, this._wysokosc * this._skala / 100, null, IntPtr.Zero);
            switch (_orientacja)
            {
            case OrientacjaObrazka.ObrotPrawo90: tmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone); break;

            case OrientacjaObrazka.ObrotLewo90: tmp.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipNone); break;

            case OrientacjaObrazka.Obrot180: tmp.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone); break;
            }
            tmp.Save(HttpContext.Current.Server.MapPath(UrlObrazka), System.Drawing.Imaging.ImageFormat.Gif); // wywalic do konfiguracji
            tmp.Dispose();
        }
        private static void ProcessingThread(byte[] gifData, AnimationInfo animationInfo)
        {
            System.Drawing.Image gifImage  = System.Drawing.Image.FromStream(new MemoryStream(gifData));
            FrameDimension       dimension = new FrameDimension(gifImage.FrameDimensionsList[0]);
            int frameCount = gifImage.GetFrameCount(dimension);

            animationInfo.frameCount  = frameCount;
            animationInfo.initialized = true;

            int index           = 0;
            int firstDelayValue = -1;

            for (int i = 0; i < frameCount; i++)
            {
                gifImage.SelectActiveFrame(dimension, i);
                System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(gifImage.Width, gifImage.Height);
                System.Drawing.Graphics.FromImage(bitmap).DrawImage(gifImage, System.Drawing.Point.Empty);
                LockBitmap frame = new LockBitmap(bitmap);
                frame.LockBits();
                FrameInfo currentFrame = new FrameInfo(bitmap.Width, bitmap.Height);
                if (currentFrame.colors == null)
                {
                    currentFrame.colors = new Color32[frame.Height * frame.Width];
                }
                for (int x = 0; x < frame.Width; x++)
                {
                    for (int y = 0; y < frame.Height; y++)
                    {
                        System.Drawing.Color sourceColor = frame.GetPixel(x, y);
                        currentFrame.colors[(frame.Height - y - 1) * frame.Width + x] = new Color32(sourceColor.R, sourceColor.G, sourceColor.B, sourceColor.A);
                    }
                }

                int delayPropertyValue = BitConverter.ToInt32(gifImage.GetPropertyItem(20736).Value, index);
                if (firstDelayValue == -1)
                {
                    firstDelayValue = delayPropertyValue;
                }

                currentFrame.delay = delayPropertyValue * 10;
                animationInfo.frames.Add(currentFrame);
                index += 4;

                Thread.Sleep(0);
            }
        }
        public ActionResult ReportVer1_RDLC()
        {
            var reportViewer = GetReport();

            //呼叫 ReportViewer.LoadReport 的 Render function,將資料轉成想要轉換的格式,並產生成Byte資料
            //轉成 Image ,格式為 image/Tif ( tif 是多張圖,瀏覽器不支援直接預覽,所以會變成下載 )
            byte[] tBytes = reportViewer.LocalReport.Render("Image");

            #region 拆解 tiff 並將圖片設為 png 格式,轉為 base64 後存起來
            MemoryStream         ms  = new MemoryStream(tBytes);
            System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
            Guid           guid      = (Guid)img.FrameDimensionsList.GetValue(0);
            FrameDimension dimension = new FrameDimension(guid);
            int            totalPage = img.GetFrameCount(dimension);

            List <string> result = new List <string>();
            for (int i = 0; i < totalPage; i++)
            {
                // 選擇多張圖底下的圖,在進行匯出
                img.SelectActiveFrame(dimension, i);

                byte[] data = null;
                using (MemoryStream oMemoryStream = new MemoryStream())
                {
                    img.Save(oMemoryStream, ImageFormat.Png);
                    //設定資料流位置,在read之前務必設定為0
                    oMemoryStream.Position = 0;
                    //設定 buffer 長度
                    data = new byte[oMemoryStream.Length];
                    //將資料寫入 buffer
                    oMemoryStream.Read(data, 0, Convert.ToInt32(oMemoryStream.Length));
                    //將所有緩衝區的資料寫入資料流
                    //oMemoryStream.Flush();
                }

                var base64 = Convert.ToBase64String(data);
                var imgSrc = String.Format("data:image/png;base64,{0}", base64);
                result.Add(imgSrc);
            }
            #endregion

            return(View(result));
        }
Пример #10
0
        public void LoadFromGif(string path)
        {
            System.Drawing.Image image     = System.Drawing.Image.FromFile(path);
            System.Drawing.Size  imageSize = new System.Drawing.Size(image.Size.Width, image.Size.Height);
            System.Drawing.Imaging.FrameDimension frameSize = new System.Drawing.Imaging.FrameDimension(image.FrameDimensionsList[0]);

            int frames = image.GetFrameCount(frameSize);

            Images = new BitmapImage[frames];

            for (int i = 0; i < frames; i++)
            {
                System.Drawing.Bitmap   b = new System.Drawing.Bitmap(imageSize.Width, imageSize.Height);
                System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(b);

                image.SelectActiveFrame(frameSize, i);
                g.DrawImage(image, 0, 0);

                Images[i] = Bitmap2BitmapImage(b);

                b.Dispose();
            }
        }
Пример #11
0
        public System.Drawing.Image[] TiffPages()
        {
            System.Drawing.Image[] tiffPages = new System.Drawing.Image [0];

            try {
                // INITIALIZATION - SOURCE

                System.Drawing.Image tiffImage = System.Drawing.Bitmap.FromStream(ImageDecompressed);

                Int32 tiffPageCount = TiffPageCount(tiffImage);

                tiffPages = new System.Drawing.Image[tiffPageCount];


                // INITIALIZATION - FRAME DIMENSIONS

                System.Drawing.Imaging.FrameDimension pageDimension = new System.Drawing.Imaging.FrameDimension(tiffImage.FrameDimensionsList[0]);


                for (Int32 currentPageIndex = 0; currentPageIndex < tiffPageCount; currentPageIndex++)
                {
                    System.IO.MemoryStream tiffPage = new System.IO.MemoryStream();

                    tiffImage.SelectActiveFrame(pageDimension, currentPageIndex);

                    tiffImage.Save(tiffPage, System.Drawing.Imaging.ImageFormat.Tiff);

                    tiffPages[currentPageIndex] = System.Drawing.Image.FromStream(tiffPage);
                }
            }

            catch (Exception imageException) {
                System.Diagnostics.Debug.WriteLine("!---> Image Stream Exception [TiffPages]: " + imageException.Message);
            }

            return(tiffPages);
        }
Пример #12
0
        public static byte[] PerformOCRTesseract(byte[] image)
        {
            // Specify that Tesseract use three 3 languages: English, Russian and Vietnamese.
            string tesseractLanguages = "rus+eng+vie";


            // A path to a folder which contains languages data files and font file "pdf.ttf".
            // Language data files can be found here:
            // Good and fast: https://github.com/tesseract-ocr/tessdata_fast
            // or
            // Best and slow: https://github.com/tesseract-ocr/tessdata_best
            // Also this folder must have write permissions.
            string tesseractData = Path.GetFullPath(@"..\..\tessdata\");

            // A path for a temporary PDF file (because Tesseract returns OCR result as PDF document)
            string tempFile = Path.Combine(tesseractData, Path.GetRandomFileName());

            try
            {
                using (Tesseract.IResultRenderer renderer = Tesseract.PdfResultRenderer.CreatePdfRenderer(tempFile, tesseractData, true))
                {
                    using (renderer.BeginDocument("Serachablepdf"))
                    {
                        using (Tesseract.TesseractEngine engine = new Tesseract.TesseractEngine(tesseractData, tesseractLanguages, Tesseract.EngineMode.Default))
                        {
                            engine.DefaultPageSegMode = Tesseract.PageSegMode.Auto;
                            using (MemoryStream msImg = new MemoryStream(image))
                            {
                                System.Drawing.Image imgWithText = System.Drawing.Image.FromStream(msImg);
                                for (int i = 0; i < imgWithText.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page); i++)
                                {
                                    imgWithText.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, i);
                                    using (MemoryStream ms = new MemoryStream())
                                    {
                                        imgWithText.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                                        byte[] imgBytes = ms.ToArray();
                                        using (Tesseract.Pix img = Tesseract.Pix.LoadFromMemory(imgBytes))
                                        {
                                            using (var page = engine.Process(img, "Serachablepdf"))
                                            {
                                                renderer.AddPage(page);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                PdfLoadOptions pl = new PdfLoadOptions();
                pl.ShowInvisibleText     = true;
                pl.PreserveEmbeddedFonts = false;
                pl.ConversionMode        = PdfConversionMode.Continuous;

                DocumentCore dc = DocumentCore.Load(File.OpenRead(tempFile + @".pdf"), pl);

                byte[] returnPdf;
                using (MemoryStream ms = new MemoryStream())
                {
                    PdfSaveOptions ps = new PdfSaveOptions();
                    dc.Save(ms, ps);
                    returnPdf = ms.ToArray();
                }
                return(returnPdf);
            }
            catch (Exception e)
            {
                Console.WriteLine();
                Console.WriteLine("Please be sure that you have Language data files (*.traineddata) in your folder \"tessdata\"");
                Console.WriteLine("The Language data files can be download from here: https://github.com/tesseract-ocr/tessdata_fast");
                Console.ReadKey();
                throw new Exception("Error Tesseract: " + e.Message);
            }
            finally
            {
                if (File.Exists(tempFile + ".pdf"))
                {
                    File.Delete(tempFile + ".pdf");
                }
            }
        }
Пример #13
0
        public GifInfo(string filePath)
        {
            bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

            if (System.IO.File.Exists(filePath))
            {
                using (System.Drawing.Image image = System.Drawing.Image.FromFile(filePath))
                {
                    this.size = new System.Drawing.Size(image.Width, image.Height);

                    if (image.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Gif))
                    {
                        this.frames   = new System.Collections.Generic.List <System.Drawing.Image>();
                        this.fileInfo = new System.IO.FileInfo(filePath);

                        if (System.Drawing.ImageAnimator.CanAnimate(image))
                        {
                            // Get frames
                            System.Drawing.Imaging.FrameDimension dimension =
                                new System.Drawing.Imaging.FrameDimension(image.FrameDimensionsList[0]);

                            int frameCount = image.GetFrameCount(dimension);

                            int index    = 0;
                            int duration = 0;
                            for (int i = 0; i < frameCount; i++)
                            {
                                image.SelectActiveFrame(dimension, i);
                                System.Drawing.Image frame = image.Clone() as System.Drawing.Image;
                                frames.Add(frame);

                                // https://docs.microsoft.com/en-us/dotnet/api/system.drawing.imaging.propertyitem.id?view=dotnet-plat-ext-3.1
                                // 0x5100	PropertyTagFrameDelay
                                byte[] propertyArray = image.GetPropertyItem(20736).Value;

                                int delay = 0;

                                if (isWindows)
                                {
                                    delay = System.BitConverter.ToInt32(propertyArray, index) * 10;
                                }
                                else
                                {
                                    delay = System.BitConverter.ToInt32(propertyArray, 0) * 10;
                                }

                                duration += (delay < 100 ? 100 : delay);

                                index += 4;
                            } // Next i

                            this.animationDuration = System.TimeSpan.FromMilliseconds(duration);
                            this.animated          = true;
                            this.loop = System.BitConverter.ToInt16(image.GetPropertyItem(20737).Value, 0) != 1;
                        }
                        else
                        {
                            this.frames.Add(image.Clone() as System.Drawing.Image);
                        }
                    }
                    else
                    {
                        throw new System.FormatException("Not valid GIF image format");
                    }
                } // End Using image
            }     // End if (System.IO.File.Exists(filePath))
        }         // End Constructor
Пример #14
0
        internal void LoadImageDataFromByte(Triggernometry.RealPlugin plug, Graphics g, byte[] data)
        {
            GifData gif = GetGifData(data);

            using (MemoryStream ms = new MemoryStream(data))
            {
                using (System.Drawing.Image i = System.Drawing.Image.FromStream(ms))
                {
                    System.Drawing.Bitmap b = (System.Drawing.Bitmap)i;
                    System.Drawing.Imaging.FrameDimension CurrentFd = new System.Drawing.Imaging.FrameDimension(i.FrameDimensionsList[0]);
                    NumberOfFrames = i.GetFrameCount(CurrentFd);
                    IsAnimated     = (NumberOfFrames > 1);
                    if (IsAnimated == true)
                    {
                        Frames      = new List <Image>();
                        FrameDelays = new List <int>();
                        System.Drawing.Imaging.PropertyItem delay = i.GetPropertyItem(0x5100);
                        Color tc;
                        bool  hastc = false;
                        if (gif.TransparencyIndex >= 0)
                        {
                            tc    = gif.Palette[gif.TransparencyIndex];
                            hastc = true;
                        }
                        else
                        {
                            tc = gif.Palette[0];
                        }
                        for (int h = 0; h < NumberOfFrames; h++)
                        {
                            int delayn = (delay.Value[h * 4] + (delay.Value[(h * 4) + 1] * 256)) * 10;
                            FrameDelays.Add(delayn);
                            i.SelectActiveFrame(CurrentFd, h);
                            System.Drawing.Image ifa = ((System.Drawing.Image)i.Clone());
                            byte[] idata             = ImageToByte(ifa);
                            if (hastc == true)
                            {
                                if (gif.TransparencyIndex != gif.BackgroundColor)
                                {
                                    // hack in case transparency color is different from bgcolor (some gifs have this shit)
                                    SetTransparencyIndex(idata, (byte)gif.BackgroundColor);
                                }
                                else
                                {
                                    for (int j = 0; j < gif.TransparencyIndex; j++)
                                    {
                                        if ((gif.Palette[j].R == tc.R) && (gif.Palette[j].R == tc.G) && (gif.Palette[j].R == tc.B))
                                        {
                                            // net itself might have selected an earlier color as new transparency color
                                            // hack to reset transparency index to match if so
                                            SetTransparencyIndex(idata, (byte)j);
                                            break;
                                        }
                                    }
                                }
                            }
                            Frames.Add(g.CreateImage(idata));
                        }
                        CurrentFrame = -1;
                        AdvanceFrame();
                    }
                    else
                    {
                        OriginalImage = g.CreateImage(data);
                    }
                }
            }
        }
Пример #15
0
        private void crearPdf_2(string rutaFinal)
        {
            try
            {
                lbl_pdfconvertir.Text = "Convirtiendo a PDF/A...";
                lbl_pdfconvertir.Refresh();
                string ruta_archivo = convertidor_path;
                System.Drawing.Image actualBitmap_ = System.Drawing.Image.FromFile(ruta_archivo);
                Guid objGuid = actualBitmap_.FrameDimensionsList[0];
                System.Drawing.Imaging.FrameDimension objDimension = new System.Drawing.Imaging.FrameDimension(objGuid);
                int total_page = actualBitmap_.GetFrameCount(objDimension);
                actualBitmap_.SelectActiveFrame(objDimension, 0);



                garbage_collector();
                var width0  = actualBitmap_.Width;
                var height0 = actualBitmap_.Height;
                iTextSharp.text.Rectangle cero = new iTextSharp.text.Rectangle(width0, height0);

                doc_pdf = new Document(cero, 0, 0, 0, 0);

                doc_pdf.SetMargins(0, 0, 0, 0);
                PdfWriter writer = PdfWriter.GetInstance(doc_pdf, new FileStream(rutaFinal, FileMode.Create));
                writer.PDFXConformance = PdfWriter.PDFA1B;
                doc_pdf.Open();

                PdfDictionary outi = new PdfDictionary(PdfName.OUTPUTINTENT);
                outi.Put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString("sRGB IEC61966-2.1"));
                outi.Put(PdfName.INFO, new PdfString("sRGB IEC61966-2.1"));
                outi.Put(PdfName.S, PdfName.GTS_PDFA1);

                //Perfiles icc
                var path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
                path = path.Replace("file:\\", "");
                ICC_Profile icc = ICC_Profile.GetInstance(path + @"\sRGB_v4.icc");
                PdfICCBased ib  = new PdfICCBased(icc);
                ib.Remove(PdfName.ALTERNATE);
                outi.Put(PdfName.DESTOUTPUTPROFILE, writer.AddToBody(ib).IndirectReference);

                writer.ExtraCatalog.Put(PdfName.OUTPUTINTENTS, new PdfArray(outi));
                BaseFont             bf = BaseFont.CreateFont(path + @"\arial.ttf", BaseFont.WINANSI, true);
                iTextSharp.text.Font f  = new iTextSharp.text.Font(bf, 12);

                float subtrahend0 = doc_pdf.PageSize.Height - 10;

                iTextSharp.text.Image pool0;
                pool0 = iTextSharp.text.Image.GetInstance(actualBitmap_, System.Drawing.Imaging.ImageFormat.Gif);

                pool0.Alignment = 3;
                pool0.ScaleToFit(doc_pdf.PageSize.Width - (doc_pdf.RightMargin * 2), subtrahend0);
                doc_pdf.Add(pool0);
                garbage_collector();
                //Crear las paginas
                for (int i = 1; i < total_page; ++i)
                {
                    actualBitmap_.SelectActiveFrame(objDimension, i);
                    float Width  = actualBitmap_.Width;
                    float Height = actualBitmap_.Height;
                    Task  task1  = Task.Factory.StartNew(() => pdf_paralelo_page(actualBitmap_));
                    Task  task2  = Task.Factory.StartNew(() => pdf_paralelo_doc(Width, Height));
                    Task.WaitAll(task1, task2);
                    doc_pdf.Add(page_prop_pdf);
                    decimal porcentaje = ((decimal)i / (decimal)total_page);
                    progressBar1.Value = (int)(porcentaje * 100);
                    progressBar1.Refresh();
                    garbage_collector();
                }
                progressBar1.Value = 100;
                writer.CreateXmpMetadata();
                doc_pdf.Close();
                actualBitmap_.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Falla de sistema en la conversión a PDF/A", title);
                if (ex.ToString().Contains("utilizado en otro proceso"))
                {
                    MessageBox.Show("El PDF esta siendo utilizado en otro proceso", title);
                }
                MessageBox.Show(ex.ToString(), title);
                garbage_collector();
            }
            garbage_collector();
        }