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


C# Drawing.ImageConverter类代码示例

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


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

示例1: ConvertImageToDataString

 public static void ConvertImageToDataString(Picture pictureToSave, Stream stream)
 {
     ImageConverter IC = new ImageConverter();
     Image image = Image.FromStream(stream);
     image = PictureResizer.ScaleImage(image, 600, 400);
     pictureToSave.PictureData = Convert.ToBase64String(PictureResizer.GetByteArrayFromImage(image));
 }
开发者ID:Buchan28,项目名称:PLM,代码行数:7,代码来源:PicturesController.cs

示例2: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			var bmp = value as Bitmap;
			if (bmp == null) return;
			var converter = new ImageConverter();
			writer.WriteValue(Convert.ToBase64String((byte[])converter.ConvertTo(bmp, typeof(byte[]))));
		}
开发者ID:w01f,项目名称:VolgaTeam.Dashboard,代码行数:7,代码来源:JsonImageConverter.cs

示例3: 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

示例4: ImageToByte

        public static byte[] ImageToByte(Image img)
        {
            ImageConverter converter = new ImageConverter();
            MessageBox.Show("metodo ImageToByte:" + "" + (byte[])converter.ConvertTo(img, typeof(byte[])));

            return (byte[])converter.ConvertTo(img, typeof(byte[]));
        }
开发者ID:josehmaza,项目名称:MIREPOSICAPJH,代码行数:7,代码来源:frmRegistrarPersonal.cs

示例5: Compare

        public static CompareResult Compare(Bitmap bmp1, Bitmap bmp2)
        {
            CompareResult cr = CompareResult.ciCompareOk;
            // removed the size test - all images compared will be the same size! (32-bit x height x width)

            //Convert each image to a byte array
            System.Drawing.ImageConverter ic =
                   new System.Drawing.ImageConverter();
            byte[] btImage1 = new byte[1];
            btImage1 = (byte[])ic.ConvertTo(bmp1, btImage1.GetType());
            byte[] btImage2 = new byte[1];
            btImage2 = (byte[])ic.ConvertTo(bmp2, btImage2.GetType());

            //Compute a hash for each image
            //Pointless to use SHA256 when MD5 is good enough. Speed advantage is worth it here.
            MD5 shaM = new MD5CryptoServiceProvider();
            byte[] hash1 = shaM.ComputeHash(btImage1);
            byte[] hash2 = shaM.ComputeHash(btImage2);

            //Compare the hash values
            for (int i = 0; i < hash1.Length && i < hash2.Length && cr == CompareResult.ciCompareOk; i++)
            {
                if (hash1[i] != hash2[i])
                    cr = CompareResult.ciPixelMismatch;
            }

            return cr;
        } // end function
开发者ID:nelsestu,项目名称:a-vnc,代码行数:28,代码来源:CompareImages.cs

示例6: GenerateTextImage

        public byte[] GenerateTextImage(string text, string stringFont, int fontSize, FontStyle[] fontStyles, string stringColor, Size imageSize, bool isVertical)
        {
            fontSize = (fontSize == 0 ? 1024 : fontSize);

            Color color = new Color();
            try
            {
                color = ColorTranslator.FromHtml(stringColor);
            }
            catch { }

            FontStyle styles = FontStyle.Regular;
            if (fontStyles != null)
            {
                foreach (FontStyle style in fontStyles)
                {
                    styles |= style;
                }
            }

            Image image = ImageProcessor.GenerateTextImage(text, new Font(stringFont, fontSize, styles), new SolidBrush(color), isVertical);

            if (imageSize != null && imageSize.Width > 0 && imageSize.Height > 0)
            {
                image = new Bitmap(image, imageSize);
            }

            ImageConverter converter = new ImageConverter();
            return (byte[])converter.ConvertTo(image, typeof(byte[]));
        }
开发者ID:minchen898,项目名称:ImageService,代码行数:30,代码来源:ProcessImage.asmx.cs

示例7: Index

        public ActionResult Index(HttpPostedFileBase image)
        {
            if (image == null) return Index("Where's the beef?");
            var imageStreamConverter = new ImageStreamConverter();
            var bitmap = imageStreamConverter.GetBitmapFromPostedFile(image);

            if (bitmap == null) return Index("That's not an image, homie...");

            var serviceBusConnectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            var blobConnectionString = CloudConfigurationManager.GetSetting("BlobStorage.ConnectionString");

            var storageAccount = CloudStorageAccount.Parse(blobConnectionString);
            var blobClient = storageAccount.CreateCloudBlobClient();
            var container = blobClient.GetContainerReference("images");
            container.CreateIfNotExists();

            var blockReference = container.GetBlockBlobReference(image.FileName);
            var converter = new ImageConverter();
            var bitmapBytes = (byte[])converter.ConvertTo(bitmap, typeof(byte[]));

            blockReference.UploadFromByteArray(bitmapBytes, 0, bitmapBytes.Length);

            var namespaceManager = NamespaceManager.CreateFromConnectionString(serviceBusConnectionString);

            if (!namespaceManager.QueueExists("ImageProcessing"))
            {
                namespaceManager.CreateQueue("ImageProcessing");
            }

            var client = QueueClient.CreateFromConnectionString(serviceBusConnectionString, "ImageProcessing");
            var message = new BrokeredMessage(new ImageMessage { BlobBlockName = blockReference.Name });

            client.Send(message);
            return Index();
        }
开发者ID:justinSelf,项目名称:AzureServiceBusDemo,代码行数:35,代码来源:HomeController.cs

示例8: 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

示例9: 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

示例10: ExcelPicture

        internal ExcelPicture(ExcelDrawings drawings, XmlNode node) :
            base(drawings, node, "xdr:pic/xdr:nvPicPr/xdr:cNvPr/@name")
        {
            XmlNode picNode = node.SelectSingleNode("xdr:pic/xdr:blipFill/a:blip", drawings.NameSpaceManager);
            if (picNode != null)
            {
                RelPic = drawings.Part.GetRelationship(picNode.Attributes["r:embed"].Value);
                UriPic = PackUriHelper.ResolvePartUri(drawings.UriDrawing, RelPic.TargetUri);

                Part = drawings.Part.Package.GetPart(UriPic);
                FileInfo f = new FileInfo(UriPic.OriginalString);
                ContentType = GetContentType(f.Extension);
                _image = Image.FromStream(Part.GetStream());
                ImageConverter ic=new ImageConverter();
                var iby=(byte[])ic.ConvertTo(_image, typeof(byte[]));
                var ii = _drawings._package.LoadImage(iby, UriPic, Part);
                ImageHash = ii.Hash;

                string relID = GetXmlNodeString("xdr:pic/xdr:nvPicPr/xdr:cNvPr/a:hlinkClick/@r:id");
                if (!string.IsNullOrEmpty(relID))
                {
                    HypRel = drawings.Part.GetRelationship(relID);
                    if (HypRel.TargetUri.IsAbsoluteUri)
                    {
                        _hyperlink = new ExcelHyperLink(HypRel.TargetUri.AbsoluteUri);
                    }
                    else
                    {
                        _hyperlink = new ExcelHyperLink(HypRel.TargetUri.OriginalString, UriKind.Relative);
                    }
                    ((ExcelHyperLink)_hyperlink).ToolTip = GetXmlNodeString("xdr:pic/xdr:nvPicPr/xdr:cNvPr/a:hlinkClick/@tooltip");
                }
            }
        }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:34,代码来源:ExcelPicture.cs

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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