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


C# ImageConverter.ConvertFrom方法代码示例

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


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

示例1: Check

 private void Check()
 {
     PKDataContext pkdata = new PKDataContext(clsDeclare.gblConnectStringLinQ);
     byte[] arrImgFront = null;
     byte[] arrImgBack = null;
     frontPic.EditValue = null;
     backPic.EditValue = null;
     ImageConverter converter = new ImageConverter();
     var pk = new Execute(pkdata).GetSinglePKIn(txtRFID.Text);
     if (pk != null)
     {
         new Execute(pkdata).getImage(pk.ID, ref arrImgFront, true);
         if (arrImgFront != null)
         {
             Image tmp = (Image)converter.ConvertFrom(arrImgFront);
             frontPic.Image = tmp;
             arrImgFront = null;
         }
         new Execute(pkdata).getImage(pk.ID, ref arrImgBack, false);
         if (arrImgBack != null)
         {
             Image tmp = (Image)converter.ConvertFrom(arrImgBack);
             backPic.Image = tmp;
             arrImgBack = null;
         }
         LoadDataToControl(pk);
         btnOK.Focus();
     }
 }
开发者ID:vanloc0301,项目名称:hugate-parking,代码行数:29,代码来源:frmWayOut.cs

示例2: byteArrayToImage

        private Image byteArrayToImage(byte[] byteArrayIn)
        {
            System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter();
            Image img = (Image)converter.ConvertFrom(byteArrayIn);

            return img;
        }
开发者ID:senthilmmurugesan,项目名称:ECommerce_Desktop_Application,代码行数:7,代码来源:frmAddProduct.cs

示例3: OnPreRender

    protected override void OnPreRender(EventArgs e)
    {
        //throw new Exception(shTwiX.shFunctions.decryptBase64Url(Request.QueryString[0]));
        Response.Clear();
        Response.ContentType = "image/jpeg";
        WebClient webclient = new WebClient();
        webclient.Headers.Clear();
        webclient.Headers.Add("Accept: image/jpeg, application/x-ms-application, image/gif, image/png, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*");
        //webclient.Headers.Add("Accept-Encoding: gzip, deflate");
        webclient.Headers.Add("User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2)");

        byte[] data = webclient.DownloadData(DES.Decrypt(shTwiX.shFunctions.decryptBase64Url(Request.QueryString[0]), shTwiX.shFunctions.key));
        do
        {
        } while (webclient.IsBusy);
        ImageConverter imageConverter = new System.Drawing.ImageConverter();
        try
        {
            System.Drawing.Image image = (System.Drawing.Image)imageConverter.ConvertFrom(data);
            image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
        catch
        {
            Response.Write(data.Length.ToString() + "<br/>" + Request.QueryString[0]);
        }
    }
开发者ID:shaahin,项目名称:shTwiX,代码行数:26,代码来源:image.aspx.cs

示例4: CompanyInfoHeaderStartTitleGridEndFooter

        //LOGO lấy từ FrameworkParams.ReportHeaderImage
        public CompanyInfoHeaderStartTitleGridEndFooter()
        {
            CompanyInfo info = DACompanyInfo.Instance.load();

            //Lấy logo
            ImageConverter ic = new ImageConverter();
            Image img = (Image)ic.ConvertFrom(info.logo);

            ImageCollection images = new ImageCollection();
            images.ImageSize = new Size(48, 48);
            images.AddImage(img);

            ReportHeaderImage = images.Images[0];

            //Lay Info
            String blank = "                      ";
            StringBuilder str = new StringBuilder("");

            if (info.name != null) str.AppendLine(blank + info.name);
            if (info.address != null) str.AppendLine(blank + "Địa chỉ: " + info.address);
            if (info.phone != null) str.Append(blank + "Điện thoại: " + info.phone);
            if (info.fax != null) str.Append("   Fax: " + info.fax);
            str.AppendLine();
            if (info.email != null) str.Append(blank + "Email: " + info.email);
            if (info.website != null) str.Append("   Website: " + info.website);

            RichTextBox r = new RichTextBox();
            r.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            r.Text = str.ToString();
            rtfGridHeader = r.Rtf;
        }
开发者ID:khanhdtn,项目名称:my-fw-win,代码行数:32,代码来源:CompanyInfoHeaderStartTitleGridEndFooter.cs

示例5: ConvertTiffToBitmap

            /// <summary>
            /// Convert Tiff image to another mime-type bitmap
            /// </summary>
            /// <param name="tiffImage">Source TIFF file</param>
            /// <param name="mimeType">Desired result mime-type</param>
            /// <returns>Converted image</returns>
            public Bitmap ConvertTiffToBitmap(Image tiffImage, string mimeType)
            {
                var imageCodecInfo = ImageCodecInfo.GetImageEncoders().FirstOrDefault(encoder => encoder.MimeType == "image/tiff");

                if (imageCodecInfo == null)
                {
                    return null;
                }
                Bitmap sourceImg;

                using (var memoryStream = new MemoryStream())
                {
                    // Setting encode params
                    var imageEncoderParams = new EncoderParameters(1);
                    imageEncoderParams.Param[0] = new EncoderParameter(Encoder.Quality, 100L);
                    tiffImage.Save(memoryStream, imageCodecInfo, imageEncoderParams);
                    tiffImage.Dispose();

                    var ic = new ImageConverter();

                    // Reading stream data to new image
                    var tempTiffImage = (Image)ic.ConvertFrom(memoryStream.GetBuffer());

                    // Setting new result mime-type
                    imageCodecInfo = ImageCodecInfo.GetImageEncoders().FirstOrDefault(encoder => encoder.MimeType == mimeType);
                    if (tempTiffImage != null) tempTiffImage.Save(memoryStream, imageCodecInfo, imageEncoderParams);

                    sourceImg = new Bitmap(Image.FromStream(memoryStream, true));

                }

                return sourceImg;
            }
开发者ID:petersgiles,项目名称:Converty,代码行数:39,代码来源:Program.cs

示例6: Main

        static void Main()
        {
            SqlConnection con = new SqlConnection(Settings.Default.NortwindConStr);
            con.Open();
            using (con)
            {
                Console.WriteLine("Retriving images from DB and saving to computer...");
                SqlCommand comand = new SqlCommand("SELECT Picture, CategoryId FROM Categories", con);
                SqlDataReader reader = comand.ExecuteReader();
                while (reader.Read())
                {
                    byte[] photo = (byte[])reader[0];
                    MemoryStream ms = new MemoryStream(photo);
                    int id = (int)reader[1];
                       
                    ms.Close();
                    ImageConverter imgConverter = new ImageConverter();

                    Image img = imgConverter.ConvertFrom(photo) as Image;
                    
                    
                    img.Save(id + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);


                  
                 
                }
                Console.WriteLine("Done.");
            }
        }
开发者ID:krstan4o,项目名称:TelerikAcademy,代码行数:30,代码来源:Program.cs

示例7: convert_ByteArrayToBitmap

 public Bitmap convert_ByteArrayToBitmap(byte[,] byteArray)
 {
     ImageConverter ic = new ImageConverter();
     Image img = (Image)ic.ConvertFrom(byteArray);
     Bitmap bitmap1 = new Bitmap(img);
     return bitmap1;
 }
开发者ID:angelut2012,项目名称:TFAFM_mcu_gui,代码行数:7,代码来源:Form_ImageShow_DrawROI.cs

示例8: GetPhoto

		protected Image GetPhoto() {
			if((photo == null) && (Photo_Binary != null)) {
				ImageConverter imageConverter = new ImageConverter();
				photo = (Image)imageConverter.ConvertFrom(Photo_Binary);
			}
			return photo;
		}
开发者ID:kamchung322,项目名称:eXpand,代码行数:7,代码来源:Party.cs

示例9: ToBitmap

 /// <summary>
 /// Converte um array de bytes em um bitmap
 /// </summary>
 /// <param name="instance">Objeto a ser convertido</param>
 /// <returns>Bitmap convertido</returns>
 public static Bitmap ToBitmap(this byte[] instance)
 {
     ImageConverter ic = new ImageConverter();
     System.Drawing.Image img = (System.Drawing.Image)ic.ConvertFrom(instance);
     Bitmap bitmap = new Bitmap(img);
     return bitmap;
 }
开发者ID:rcarubbi,项目名称:Carubbi.Components,代码行数:12,代码来源:BitmapExtensions.cs

示例10: ImageFromStr

 public static Image ImageFromStr(string strImageData)
 {
     if (strImageData == "")
         return null;
     byte[] byteImageData = new Byte[0];
     byteImageData = Convert.FromBase64String(strImageData);
     ImageConverter ic = new ImageConverter();
     Image img = (Image)ic.ConvertFrom(byteImageData);
     return img;
 }
开发者ID:vtthanh83,项目名称:Karaoke,代码行数:10,代码来源:CustomListBox.cs

示例11: GetImageFromString

        //---------------------------------------------------------------------
        /// <summary>
        /// Converts a Base64-String to an Image
        /// </summary>
        /// <param name="base64String">
        /// String to convert
        /// </param>
        /// <returns>
        /// Image created from the String
        /// </returns>
        public static Image GetImageFromString(string base64String)
        {
            byte[] buffer = Convert.FromBase64String(base64String);

            if (buffer != null)
            {
                ImageConverter ic = new ImageConverter();
                return ic.ConvertFrom(buffer) as Image;
            }
            else
                return null;
        }
开发者ID:palaniellappank,项目名称:online-medical-consultant-system,代码行数:22,代码来源:ImageToString.cs

示例12: ResourceRepoFetches

        public void ResourceRepoFetches()
        {
            var ic = new ImageConverter();

            using (var repo = new ResourceWrapper<Bitmap>(b => ic.ConvertFrom(b) as Bitmap, s => null, n => null, testRes.ResourceManager))
            {
                Assert.AreEqual(8, repo.Length);

                var luna = repo.Fetch("Luna_DIFF");

                Assert.IsNotNull(luna);
            }
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:13,代码来源:ResourceCRUDTests.cs

示例13: GetBitmapImage

 private static BitmapImage GetBitmapImage(byte[] image)
 {
     var ic = new ImageConverter();
     var img = (System.Drawing.Image)ic.ConvertFrom(image);
     var bitmap = new Bitmap(img);
     var ms = new MemoryStream();
     bitmap.Save(ms, ImageFormat.Png);
     ms.Position = 0;
     var bi = new BitmapImage();
     bi.BeginInit();
     bi.StreamSource = ms;
     bi.EndInit();
     return bi;
 }
开发者ID:JakeGinnivan,项目名称:AsyncAllTheThings,代码行数:14,代码来源:MainWindow.xaml.cs

示例14: FirstRunSetup

        internal void FirstRunSetup()
        {
            // Timing rig
            Debug.WriteLine("[INFO] Beginning first-run initialization.");
            Stopwatch timer = new Stopwatch();
            timer.Start();

            // Function start
            dbEngine.createDbFile(); // First run -- DB file will be needed

            ASComicAccess.xkcd.ComicMetadata meta = accessEngine.getComic();
            string imgPath = meta.img;

            // Download the image file
            WebClient connectAgent = new WebClient();
            ImageConverter converter = new ImageConverter();
            byte[] rawData;

            try
            {
                rawData = connectAgent.DownloadData(imgPath);
            }
            catch (WebException)
            {
                Debug.WriteLine("[ERROR] WebException thrown - Not connected?");
                return;
            }

            Image img;
            try
            {
                img = (Image)converter.ConvertFrom(rawData);
            }
            catch
            {
                Debug.Fail("[ERROR] Error thrown in image parser");
                throw;
            }

            dbEngine.insertRow(meta);

            if (xkcd_Viewer.Properties.Settings.Default.offlineMode)
                dbEngine.updateImgData(int.Parse(meta.num), img);

            // Function end; stop timer rig
            timer.Stop();
            timerResult = timer.ElapsedMilliseconds;
            Debug.WriteLine("[INFO] Completed first-run initialization in " + timerResult + "ms");
        }
开发者ID:Sunstrike,项目名称:xkcd-viewer,代码行数:49,代码来源:ViewerCore.cs

示例15: btnConnect_Click

		private async void btnConnect_Click( object sender, EventArgs e )
		{
			this.btnConnect.Enabled = false;
			this.btnCancel.Enabled = true;
			this.pbStatus.Visible = true;

			Camera c = new Camera( this.txtHostName.Text, Int32.Parse(this.txtPort.Text), this.txtUserName.Text, this.txtPassword.Text );

			this.lblStatus.Text = "Getting port information...";
			GetPortInfoResult ports = await c.GetPortInfoAsync( this.cts.Token );
			this.lblHttpPort.Text = ports.HttpPort.ToString( CultureInfo.InvariantCulture );
			this.lblHttpsPort.Text = ports.HttpsPort.ToString( CultureInfo.InvariantCulture );
			this.lblMediaPort.Text = ports.MediaPort.ToString( CultureInfo.InvariantCulture );
			this.lblOnvifPort.Text = ports.OnvifPort.ToString( CultureInfo.InvariantCulture );

			this.lblStatus.Text = "Getting IP information...";
			GetIPInfoResult ipInfo = await c.GetIPInfoAsync( this.cts.Token );

			this.lblStatus.Text = "Getting model name...";
			GetProductModelNameResult productModelName = await c.GetProductModelNameAsync( this.cts.Token );
			this.lblCameraInfo.Text = String.Format( CultureInfo.InvariantCulture, "Model {0} on {1}", productModelName.ModelName, ipInfo.IPAddress);

			this.lblStatus.Text = "Getting device information...";
			GetDeviceInfoResult deviceInfo = await c.GetDeviceInfoAsync( this.cts.Token );
			this.lblProductName.Text = deviceInfo.ProductName;
			this.lblDeviceName.Text = deviceInfo.DeviceName;
			this.lblSerialNo.Text = deviceInfo.SerialNumber;
			this.lblMac.Text = deviceInfo.MacAddress;
			this.lblCurrentDate.Text = deviceInfo.CurrentDate.ToString(CultureInfo.CurrentCulture);
			this.lblTimeZone.Text = deviceInfo.TimeZone;
			this.lblFirmwareVersion.Text = deviceInfo.FirmwareVersion;
			this.lblHardwareVersion.Text = deviceInfo.HardwareVersion;

			this.lblStatus.Text = "Getting snapshot image...";
			GetSnapshotResult snapshot = await c.GetSnapshotAsync( this.cts.Token );
			ImageConverter converter = new ImageConverter();
			this.pbSnapshot.Image = (Image) converter.ConvertFrom( snapshot.Image );

			this.lblStatus.Text = "Ready.";
			this.pbStatus.Visible = false;
			this.btnConnect.Enabled = true;
			this.btnCancel.Enabled = false;
		}
开发者ID:balassy,项目名称:Foscon,代码行数:43,代码来源:MainForm.cs


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