Beispiel #1
0
        private static Bitmap SaveFile(ImageFile imageFile)
        {
            var    process        = new ImageProcess();
            object filterProperty = "Convert";
            // ReSharper disable once UseIndexedProperty
            var convertFilterID = process.FilterInfos.get_Item(ref filterProperty).FilterID;

            // ReSharper disable once RedundantArgumentDefaultValue
            process.Filters.Add(convertFilterID, 0);
            object formatPropValue   = FormatID.wiaFormatTIFF;
            object formatIdProperty  = "FormatID";
            object qualityPropValue  = 100L;
            object qualityIdProperty = "Quality";
            var    properties        = process.Filters[process.Filters.Count].Properties;
            // ReSharper disable once UseIndexedProperty
            var property = properties.get_Item(ref formatIdProperty);

            // ReSharper disable once UseIndexedProperty
            property.set_Value(ref formatPropValue);
            // ReSharper disable once UseIndexedProperty
            var qualityProperty = properties.get_Item(ref qualityIdProperty);

            // ReSharper disable once UseIndexedProperty
            qualityProperty.set_Value(ref qualityPropValue);
            imageFile = process.Apply(imageFile);
            Bitmap bitmap;

            // ReSharper disable once UseIndexedProperty
            using (var stream = new MemoryStream((byte[])imageFile.FileData.get_BinaryData()))
            {
                bitmap = new Bitmap(Image.FromStream(stream));
            }
            return(bitmap);
        }
        private static void SaveImageToTiff(ImageFile image, string fileName)
        {
            ImageProcess imgProcess      = new ImageProcess();
            object       convertFilter   = "Convert";
            string       convertFilterID = imgProcess.FilterInfos.get_Item(ref convertFilter).FilterID;

            imgProcess.Filters.Add(convertFilterID, 0);
            SetWIAProperty(imgProcess.Filters[imgProcess.Filters.Count].Properties, "FormatID", WIA.FormatID.wiaFormatTIFF);
            image = imgProcess.Apply(image);
            image.SaveFile(fileName);
        }
Beispiel #3
0
        private void SaveImageToJPEGFile(ImageFile image, string fileName)
        {

            ImageProcess imgProcess = new ImageProcess();
            object convertFilter = "Convert";
            string convertFilterID = imgProcess.FilterInfos.get_Item(ref convertFilter).FilterID;
            imgProcess.Filters.Add(convertFilterID, 0);
            SetWIAProperty(imgProcess.Filters[imgProcess.Filters.Count].Properties, "FormatID", WIA.FormatID.wiaFormatJPEG);
            image = imgProcess.Apply(image);
            image.SaveFile(fileName);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="imagem"></param>
        private static string SalvarPNG(ImageFile imagem)
        {
            string       fileName        = CaminhoUnico();
            ImageProcess imgProcess      = new ImageProcess();
            object       convertFilter   = "Convert";
            string       convertFilterID = imgProcess.FilterInfos.get_Item(ref convertFilter).FilterID;

            imgProcess.Filters.Add(convertFilterID, 0);
            GravaPropriedadeWIA(imgProcess.Filters[imgProcess.Filters.Count].Properties, "FormatID", WIA.FormatID.wiaFormatPNG);
            imagem = imgProcess.Apply(imagem);
            imagem.SaveFile(fileName);
            return(fileName);
        }
Beispiel #5
0
 private bool SaveImageToPNGFile(ImageFile image, string fileName)
 {
     if (image != null)
     {
         ImageProcess imgProcess      = new ImageProcess();
         object       convertFilter   = "Convert";
         string       convertFilterID = imgProcess.FilterInfos.get_Item(ref convertFilter).FilterID;
         imgProcess.Filters.Add(convertFilterID, 0);
         SetWIAProperty(imgProcess.Filters[imgProcess.Filters.Count].Properties, "FormatID", WIA.FormatID.wiaFormatPNG);
         image = imgProcess.Apply(image);
         image.SaveFile(fileName);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #6
0
 public ImageFile Filter(ImageFile image, string filter)
 {
     _ip.Filters.Add(_ip.FilterInfos["Convert"].FilterID);
     _ip.Filters[1].Properties["FormatID"].set_Value(filter);
     return(_ip.Apply(image));
 }
Beispiel #7
0
 internal ImageFile ApplyFilters()
 {
     return(_imageProcess.Apply(_imageFile));
 }