博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# Base64转换
阅读量:2026 次
发布时间:2019-04-28

本文共 1227 字,大约阅读时间需要 4 分钟。

using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Text.RegularExpressions;using System.Threading.Tasks;using System.Drawing;using System.Drawing.Imaging;namespace ConsoleApplication10{    class Program    {        static void Main(string[] args)        {            string str = @"假设这里是一段base64编码的字符串";            Regex rgx = new Regex(@" ");            str = rgx.Replace(str, @"+");            byte[] data = new byte[str.Length];            data = Convert.FromBase64String(str);            MemoryStream ms = new MemoryStream(data);            Image img = Image.FromStream(ms);            //image.Save(@"C:\Users\Administrator\Desktop\a1a1.png", ImageFormat.Png);            Bitmap image = new Bitmap(img);            Bitmap image1 = new Bitmap(120, 120);            int width = image.Width;            int height = image.Height;            Graphics g = Graphics.FromImage(image1);            Rectangle rect = new Rectangle(50, 25, 120, 120);            g.DrawImage(image, 0, 0, rect, GraphicsUnit.Pixel);            //string url = Server.MapPath(@"~/saveimg/as.png");            image1.Save(@"C:\Users\Administrator\Desktop\a2.png", ImageFormat.Png);        }    }}

转载地址:http://ftdaf.baihongyu.com/

你可能感兴趣的文章
MySQL 常用命令(持续更新)
查看>>
HtmlAgilityPack下载开启压缩的页面乱码
查看>>
jQuery triger与trigerHandler的区别
查看>>
MySQL 批量插入 Update时Replace
查看>>
图的存储结构
查看>>
MySQL 主从热备份(读写分离)
查看>>
基于谷歌地图的Dijkstra算法水路路径规划
查看>>
CSS3 初步学习
查看>>
javascript call与apply关键字的作用
查看>>
带权重的有向图求最短路径
查看>>
Func<T>、Action<T> 的区别于说明
查看>>
javascript 闭包最简单理解
查看>>
DataTable转List<dynamic>
查看>>
javascript this关键字指向详解
查看>>
IIS7 启用GZip压缩
查看>>
jQuery.fn.extend() 与 jQuery.extend()
查看>>
CSS垂直居中的方法
查看>>
javascript arguments解释,实现可变长参数。
查看>>
FileAccess枚举
查看>>
Asp.net开发常用DOS命令
查看>>