当前位置: 首页>>代码示例>>C#>>正文


C# Imaging.ImageCodecInfo类代码示例

本文整理汇总了C#中System.Drawing.Imaging.ImageCodecInfo的典型用法代码示例。如果您正苦于以下问题:C# ImageCodecInfo类的具体用法?C# ImageCodecInfo怎么用?C# ImageCodecInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ImageCodecInfo类属于System.Drawing.Imaging命名空间,在下文中一共展示了ImageCodecInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResizeImage

 static void ResizeImage(string SourceFile, string DestinationFile, ImageCodecInfo encoder, EncoderParameters parameters)
 {
     try
     {
         using (Image Source = Image.FromFile(SourceFile))
         {
             int NewWidth, NewHeight;
             if (Source.Width > ResizeMaxPixels && Source.Width >= Source.Height)
             {
                 NewWidth = ResizeMaxPixels;
                 NewHeight = (Source.Height * ResizeMaxPixels) / Source.Width;
                 using (Image Dest = ResizeImage(Source, NewWidth, NewHeight))
                     Dest.Save(DestinationFile, encoder, parameters);
             }
             else if (Source.Height > ResizeMaxPixels && Source.Height >= Source.Width)
             {
                 NewWidth = (Source.Width * ResizeMaxPixels) / Source.Height;
                 NewHeight = ResizeMaxPixels;
                 using (Image Dest = ResizeImage(Source, NewWidth, NewHeight))
                     Dest.Save(DestinationFile, encoder, parameters);
             }
             else
             {
                 // no need for resize
                 Source.Save(DestinationFile, encoder, parameters);
             }
         }
     }
     catch (Exception e)
     {
         File.Delete(DestinationFile); // make sure destination file doesn't exist anymore
         Console.WriteLine("Error: " + e.Message);
     }
 }
开发者ID:Heimiko,项目名称:BatchSyncAndResizeImages,代码行数:34,代码来源:Program.cs

示例2: ConvertFromMemory

 private static ImageCodecInfo[] ConvertFromMemory(IntPtr memoryStart, int numCodecs)
 {
     ImageCodecInfo[] infoArray = new ImageCodecInfo[numCodecs];
     for (int i = 0; i < numCodecs; i++)
     {
         IntPtr lparam = (IntPtr) (((long) memoryStart) + (Marshal.SizeOf(typeof(ImageCodecInfoPrivate)) * i));
         ImageCodecInfoPrivate data = new ImageCodecInfoPrivate();
         System.Drawing.UnsafeNativeMethods.PtrToStructure(lparam, data);
         infoArray[i] = new ImageCodecInfo();
         infoArray[i].Clsid = data.Clsid;
         infoArray[i].FormatID = data.FormatID;
         infoArray[i].CodecName = Marshal.PtrToStringUni(data.CodecName);
         infoArray[i].DllName = Marshal.PtrToStringUni(data.DllName);
         infoArray[i].FormatDescription = Marshal.PtrToStringUni(data.FormatDescription);
         infoArray[i].FilenameExtension = Marshal.PtrToStringUni(data.FilenameExtension);
         infoArray[i].MimeType = Marshal.PtrToStringUni(data.MimeType);
         infoArray[i].Flags = (ImageCodecFlags) data.Flags;
         infoArray[i].Version = data.Version;
         infoArray[i].SignaturePatterns = new byte[data.SigCount][];
         infoArray[i].SignatureMasks = new byte[data.SigCount][];
         for (int j = 0; j < data.SigCount; j++)
         {
             infoArray[i].SignaturePatterns[j] = new byte[data.SigSize];
             infoArray[i].SignatureMasks[j] = new byte[data.SigSize];
             Marshal.Copy((IntPtr) (((long) data.SigMask) + (j * data.SigSize)), infoArray[i].SignatureMasks[j], 0, data.SigSize);
             Marshal.Copy((IntPtr) (((long) data.SigPattern) + (j * data.SigSize)), infoArray[i].SignaturePatterns[j], 0, data.SigSize);
         }
     }
     return infoArray;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:ImageCodecInfo.cs

示例3: ExportBitmapCommand

 static ExportBitmapCommand()
 {
     foreach (ImageCodecInfo ici in ImageCodecInfo.GetImageEncoders())
     {
         _jpegEncoder = ici;
     }
 }
开发者ID:razaraz,项目名称:Pscx,代码行数:7,代码来源:ExportBitmapCommand.cs

示例4: Form1

 public Form1()
 {
     InitializeComponent();
     connected=false;
     encoderParams=new EncoderParameters();
     encoderParams.Param[0]=new EncoderParameter(System.Drawing.Imaging.Encoder.Quality,95L);
     jpegCodec=ImageCodecInfo.GetImageEncoders().First(codec=>codec.MimeType=="image/jpeg");
 }
开发者ID:abcsharp,项目名称:RemoteController,代码行数:8,代码来源:Form1.cs

示例5: Save

		public void Save(FileStream fileStream, ImageCodecInfo encoder, int quality)
		{
			var encoderParams = new EncoderParameters(2);
			encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, quality);			
			encoderParams.Param[1] = new EncoderParameter(Encoder.ColorDepth, 24L);				
			_bitmap.Save(fileStream, encoder, encoderParams);
			fileStream.Close();
		}
开发者ID:TargetProcess,项目名称:Tp.TrayUtility,代码行数:8,代码来源:BitmapWrapper.cs

示例6: GetMapResponse

 public GetMapResponse(Image image, ImageCodecInfo codecInfo)
 {
     if (image == null)
         throw new ArgumentNullException("image");
     if (codecInfo == null)
         throw new ArgumentNullException("codecInfo");
     _image = image;
     _codecInfo = codecInfo;
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:9,代码来源:GetMapResponse.cs

示例7: DevicePresenter

 static DevicePresenter()
 {
     ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders();
     for (int j = 0; j < encoders.Length; ++j)
     {
         if (encoders[j].MimeType == "image/jpeg")
             _codecInfo = encoders[j];
     }
 }
开发者ID:eaglezhao,项目名称:tracnghiemweb,代码行数:9,代码来源:DevicePresenter.cs

示例8: GetImageDecoders

		public static ImageCodecInfo[] GetImageDecoders () 
		{
			Hashtable oldInfo = ImageCodec.Decoders;
			ImageCodecInfo [] newInfo = new ImageCodecInfo [oldInfo.Count];
			int i=0;
			foreach (ImageCodecInfo codec in oldInfo.Values) {
				newInfo [i++] = (ImageCodecInfo) codec.MemberwiseClone ();
			}
			return newInfo;
		}
开发者ID:GirlD,项目名称:mono,代码行数:10,代码来源:ImageCodecInfo.jvm.cs

示例9: SaveImage

		public static void SaveImage(Image image, string fileName, ImageCodecInfo jpgEncoder, EncoderParameters parameters)
		{
			RetryUtility.Retry(() => image.Save(fileName, jpgEncoder, parameters),
				RetryUtility.kDefaultMaxRetryAttempts,
				RetryUtility.kDefaultRetryDelay,
				new HashSet<Type>
				{
					Type.GetType("System.IO.IOException"),
					Type.GetType("System.Runtime.InteropServices.ExternalException")
				});
		}
开发者ID:regnrand,项目名称:libpalaso,代码行数:11,代码来源:RobustIO.cs

示例10: AvatarBuilder

 static AvatarBuilder()
 {
     ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
     foreach (ImageCodecInfo codec in codecs)
     {
         if (codec.FormatID == ImageFormat.Jpeg.Guid)
         {
             jpegImageCodeInfo = codec;
         }
     }
 }
开发者ID:huchao007,项目名称:bbsmax,代码行数:11,代码来源:AvatarBuilder.cs

示例11: setQuality

 /// <summary>
 /// 质量控制
 /// </summary>
 /// <param name="level">级别,1-100</param>
 /// <param name="mimeType">图片格式,</param>
 private static void setQuality(int level, string mimeType)
 {
     var codecs = ImageCodecInfo.GetImageEncoders();
     ici = null;
     foreach (var codec in codecs)
     {
         if (codec.MimeType == "image/" + mimeType)
             ici = codec;
     }
     ep = new EncoderParameters();
     ep.Param[0] = new EncoderParameter(Encoder.Quality, level);
 }
开发者ID:Eagle-Chan,项目名称:KIS,代码行数:17,代码来源:EditImage.cs

示例12: Check

		static void Check (ImageCodecInfo e, ImageCodecInfo d, Guid FormatID, string CodecName, string DllName,
			string FilenameExtension, ImageCodecFlags Flags, string FormatDescription,
			string MimeType, int Version, int signatureLength, string mask, string pattern, string pattern2)
		{
			Regex extRegex = new Regex (@"^(\*\.\w+(;(\*\.\w+))*;)?"+
				Regex.Escape (FilenameExtension)[email protected]"(;\*\.\w+(;(\*\.\w+))*)?$",
				RegexOptions.IgnoreCase | RegexOptions.Singleline);

			if (e != null) {
				Assert.AreEqual (FormatID, e.FormatID, "Encoder.FormatID");
				Assert.IsTrue (e.CodecName.IndexOf (CodecName)>=0,
					"Encoder.CodecName contains "+CodecName);
				Assert.AreEqual (DllName, e.DllName, "Encoder.DllName");
				Assert.IsTrue (extRegex.IsMatch (e.FilenameExtension),
					"Encoder.FilenameExtension is a right list with "+FilenameExtension);
				Assert.AreEqual (Flags, e.Flags, "Encoder.Flags");
				Assert.IsTrue (e.FormatDescription.IndexOf (FormatDescription)>=0,
					"Encoder.FormatDescription contains "+FormatDescription);
				Assert.IsTrue (e.MimeType.IndexOf (MimeType)>=0,
					"Encoder.MimeType contains "+MimeType);

				Assert.AreEqual (signatureLength, e.SignatureMasks.Length, "Encoder.SignatureMasks.Length");
				for (int i = 0; i < signatureLength; i++) {
					Assert.AreEqual (mask, BitConverter.ToString (e.SignatureMasks[i]), String.Format ("Encoder.SignatureMasks[{0}]", i));
				}
				Assert.AreEqual (signatureLength, e.SignaturePatterns.Length, "Encoder.SignaturePatterns.Length");
				Assert.AreEqual (pattern, BitConverter.ToString (e.SignaturePatterns[0]), "Encoder.SignaturePatterns[0]");
				if (pattern2 != null)
					Assert.AreEqual (pattern2, BitConverter.ToString (e.SignaturePatterns[1]), "Encoder.SignaturePatterns[1]");
			}
			if (d != null) {
				Assert.AreEqual (FormatID, d.FormatID, "Decoder.FormatID");
				Assert.IsTrue (d.CodecName.IndexOf (CodecName)>=0,
					"Decoder.CodecName contains "+CodecName);
				Assert.AreEqual (DllName, d.DllName, "Decoder.DllName");
				Assert.IsTrue (extRegex.IsMatch (d.FilenameExtension),
					"Decoder.FilenameExtension is a right list with "+FilenameExtension);
				Assert.AreEqual (Flags, d.Flags, "Decoder.Flags");
				Assert.IsTrue (d.FormatDescription.IndexOf (FormatDescription)>=0,
					"Decoder.FormatDescription contains "+FormatDescription);
				Assert.IsTrue (d.MimeType.IndexOf (MimeType)>=0,
					"Decoder.MimeType contains "+MimeType);

				Assert.AreEqual (signatureLength, d.SignatureMasks.Length, "Decoder.SignatureMasks.Length");
				for (int i = 0; i < signatureLength; i++) {
					Assert.AreEqual (mask, BitConverter.ToString (d.SignatureMasks[i]), String.Format ("Decoder.SignatureMasks[{0}]", i));
				}
				Assert.AreEqual (signatureLength, d.SignaturePatterns.Length, "Decoder.SignaturePatterns.Length");
				Assert.AreEqual (pattern, BitConverter.ToString (d.SignaturePatterns[0]), "Decoder.SignaturePatterns[0]");
				if (pattern2 != null)
					Assert.AreEqual (pattern2, BitConverter.ToString (d.SignaturePatterns[1]), "Decoder.SignaturePatterns[1]");
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:53,代码来源:TestImageCodecInfo.cs

示例13: ControllerHelpers

 static ControllerHelpers()
 {
     _MaxWidth = int.Parse(ConfigurationManager.AppSettings["UploadFileMaxWidth"]);
     _ThumbMaxWidth = int.Parse(ConfigurationManager.AppSettings["ThumbFileMaxWidth"]);
     _UserImgFolder = ConfigurationManager.AppSettings["UserImageFolder"];
     _JpegCodecInfo = ImageCodecInfo.GetImageEncoders().Where(codec => codec.MimeType == "image/jpeg").First();
     var qualityEncoder = Encoder.Quality;
     var quality = 100;
     var ratio = new EncoderParameter(qualityEncoder, quality);
     _EncoderParameters = new EncoderParameters(1);
     _EncoderParameters.Param[0] = ratio;
 }
开发者ID:tah91,项目名称:eworkyWebSite,代码行数:12,代码来源:ControllerHelpers.cs

示例14: Webcam

        public Webcam(string ocu_ipAddress, CameraConfiguration config)
        {
            this.config = config;
            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            if (videoDevices.Count < 1)
                throw new Exception("No video input devices available");
            if (!string.IsNullOrEmpty(config.DeviceName))
                videoSource = new VideoCaptureDevice(config.DeviceName);
                //videoSource = new VideoCaptureDevice(videoDevices[1].MonikerString);
            else
            {
                videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
            }

            updateWorker = new Timer();
            updateWorker.Elapsed += new ElapsedEventHandler(updateWorker_Elapsed);
            FrameRate = config.RCU_To_OCU_Framerate;
            JPEGQuality = config.JPEGQuality;
            isActive = false;
            jpegCodec = GetEncoderInfo("image/jpeg");
            videoSource.DesiredFrameSize = new Size(320, 240);
            videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);
            udp_sender = new Comms.UDP_Sender(ocu_ipAddress, config.SendPort);
            raw_frame_queue = new Utility.UpdateQueue<byte[]>(-1);
        }
开发者ID:jlucas9,项目名称:WVU-Lunabotics,代码行数:25,代码来源:Webcam.cs

示例15: LzwCompression

 public LzwCompression(int Quality)
 {
     this.parameter = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)Quality);
     this.encoderInfo = GetEncoderInfo("image/jpeg");
     this.encoderParams = new EncoderParameters(2);
     this.encoderParams.Param[0] = parameter;
     this.encoderParams.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, (long)2);
 }
开发者ID:PavilionVI,项目名称:SecureSocketProtocol,代码行数:8,代码来源:LzwCompression.cs


注:本文中的System.Drawing.Imaging.ImageCodecInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。