base64编码的文本转为图片中jpeg保存为白色背景问题

时间:2022-11-13 07:29:00
问题出现原因,jpeg不支持透明背景,那么我就想改为白色背景,但是现实是试过很多种方法都不行
源码
        /// <summary>
        /// base64编码的文本 转为    图片
        /// </summary>
        /// <param name="txtFileName"> base64编码</param>
        /// <param name="layout">图片格式 支持 jpg|bmp|gif|png</param>
        ///  <param name="ImgUrl">保存的图片路径</param>
        public bool Base64StringToImg(string Imgbase64, string layout, string ImgUrl)
        {
            //try
            //{
                //FileStream ifs = new FileStream(Imgbase64, FileMode.Open, FileAccess.Read);
                //StreamReader sr = new StreamReader(ifs);
                //String inputStr = sr.ReadToEnd();

                byte[] arr = Convert.FromBase64String(Imgbase64.Split(',')[1]);
                MemoryStream ms = new MemoryStream(arr);
                Bitmap bmp = new Bitmap(ms);
                if (layout.ToLower() == "jpg")
                {
                    bmp.Save(ImgUrl + ".jpg",ImageFormat.Jpeg);
                }
                else if (layout.ToLower() == "jpeg")
                {
                    //图片标准压缩格式
                    bmp.Save(ImgUrl + ".jpeg", ImageFormat.Jpeg);
                }
                else if (layout.ToLower() == "bmp")
                {
                    //保存的图片格式需支持透明
                    bmp.MakeTransparent();
                    bmp.Save(ImgUrl + ".bmp", ImageFormat.Bmp);
                }
                else if (layout.ToLower() == "gif")
                {
                    //保存的图片格式需支持透明
                    bmp.MakeTransparent();
                    bmp.Save(ImgUrl + ".gif", ImageFormat.Gif);
                }
                else if (layout.ToLower() == "png")
                {
                    //保存的图片格式需支持透明
                    bmp.MakeTransparent();
                    //便携式网络图形(无损压缩的位图图形格式)
                    bmp.Save(ImgUrl + ".png",ImageFormat.Png);
                }
               
                ms.Close();
                //sr.Close();
                //ifs.Close();

                if (File.Exists(Imgbase64))
                {
                    File.Delete(Imgbase64);
                }
                return true;
                //MessageBox.Show("转换成功!");
            //}
            //catch (Exception)
            //{
            //    return false;
            //}

        }

试过的方法1:
        public Bitmap PTransparentAdjust(Bitmap src)
        {
            try
            {
                int w = src.Width;
                int h = src.Height;
                Bitmap dstBitmap = new Bitmap(src.Width, src.Height, PixelFormat.Format32bppArgb);
                BitmapData srcData = src.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly,PixelFormat.Format32bppArgb);
                BitmapData dstData = dstBitmap.LockBits(new Rectangle(0, 0, w, h),ImageLockMode.WriteOnly,PixelFormat.Format32bppArgb);
                unsafe
                {
                    byte* pIn = (byte*)srcData.Scan0.ToPointer();
                    byte* pOut = (byte*)dstData.Scan0.ToPointer();
                    byte* p;
                    int stride = srcData.Stride;
                    int r, g, b, a;
                    for (int y = 0; y < h; y++)
                    {
                        for (int x = 0; x < w; x++)
                        {
                            p = pIn;
                            b = pIn[0];
                            g = pIn[1];
                            r = pIn[2];
                            a = pIn[3];
                            if (a == 0)
                            {
                                pOut[1] = (byte)255;
                                pOut[2] = (byte)255;
                                pOut[3] = (byte)255;
                                pOut[0] = (byte)255;
                            }
                            else
                            {
                                pOut[1] = (byte)g;
                                pOut[2] = (byte)r;
                                pOut[3] = (byte)a;
                                pOut[0] = (byte)b;
                            }
                            pIn += 4;
                            pOut += 4;
                        }
                        pIn += srcData.Stride - w * 4;
                        pOut += srcData.Stride - w * 4;
                    }
                    src.UnlockBits(srcData);
                    dstBitmap.UnlockBits(dstData);
                    return dstBitmap;
                }
            }
            catch (Exception e)
            {
                return null;
            }

        }


方法二:
                     //        Image img = Image.FromStream(ms, true);
                     //int width = img.Width;
                     //int height = img.Height;
                     //var x = img.HorizontalResolution;
                     //var y = img.VerticalResolution;
                     //var tempHeight = height * 300 / y;
                     //var tempWidth = width * 300 / y;

                     //Bitmap bmpTemp = new Bitmap((int)tempWidth, (int)tempHeight);
                     //Graphics g = Graphics.FromImage(bmpTemp);
                     //g.SmoothingMode = SmoothingMode.AntiAlias;
                     //g.Clear(Color.Red);
                     //g.DrawImage(img, new RectangleF(0, 0, tempWidth, tempHeight),
                     //    new RectangleF(0, 0, width, height), GraphicsUnit.Pixel);
                     //g.Save();

                     //bmpTemp.Save(ImgUrl + ".jpeg", ImageFormat.Jpeg);
                     //g.Dispose();
                     //img.Dispose();
                     //bmpTemp.Dispose();

结果都不行

20 个解决方案

#1


base64编码的文本转为图片中jpeg保存为白色背景问题

#2


base64编码的文本转为图片中jpeg保存为白色背景问题

#3


你应给出数据,用于测试你的代码

#4


引用 3 楼 xuzuning 的回复:
你应给出数据,用于测试你的代码
base64码?但是好长呀?我在楼下放一段出来吧。

#5



data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAYAAACoYAD2AAAE30lEQVRYR+2Ya4gbVRTH/+em2e3iVtvMvpS21Apa/aAUXZF+EBXBR0Fsxa2biQsLRStorVAqUjOZTCxYKrSriC1Si+3OLkStD6SoXyyCCtYHolIfVEtbXfcx2coi62aTe+TOJm2STZpJJl8KvRAId87jl/M/9965IVwEgy4CRlyCbJRKlyp5qZKNqkCj4jSsJ5eYB5eL7ILbIbibGDczsAxzn9IcDOA0AaeZ8A0kHZOBzGeTZt+pSj/KF2Tn1oOXZVvEowx6CIQ7AQTqrF4WjE8J/E5gWh4afanv38I4dUEuNg8sFrLpaQIeB3BlCdgYgO9B+IWYTzJoDIKmXBvJiwjcwUQrwLgOwE0AOkr8RxjYJ0V64KzZf1Y9qxlSi9pPgmAC0PLBCfhDgg6TwJFFmPnipNn/n5eKrjAPLJxC8xqWuF+A1zNwdYGfA3DMsSKveobsNO2VmSztB/Ed5wIxHQXxHscKfwCQ6jUfg0kzhh4A05aiHFBt4GFoxuA6gGwALTnznyGw3TH1wx7cazbRTHs9JHYAWOVJbi1qbwZhIJ+JwbtSVmRbzZnrcAjF7F3E2HrBSrYZtsVANBc/DUEbHDP8Xh356nZRKlaELKnguBTZuybNvh/rzubDsSxkmzG8liE/zPXDhBS8OmVGzvjI48t1HmS7meyScvav3PbERIFVE/FHfvWVxafzPEjNsI8BuEXFFYS143H9iM8cvt2LIEPRoY1E/Hou6oBj6VvKZWiPDq9mkutAYu9EvFdVvWGjLTZ8FVhuIhbvjid6vyvagtzdX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a2u4tQt0DDykUgq7qykEEEEcYrjv8AhmT4kf8AQAh/8Gdp/wDHau+IPh18P/AOqSaF4m8Q65Jr1qqfaxpdjG1ujsobarO4LYDAZxz7Vnf2Z8Iv+g74s/8ABfB/8cr3cTh8PVrzqYiFpttyXtoKzb1VnB216Xdu5Kbtobnj54vBWj/Cjw9qk8K6voElzPqUFvKs32dZLsSICyEgttBJAPp6irXxF+BfjLxr4617X9BsLPVdG1O8ku7S8g1K2CSxu25SA0gI4POR1rivGvw2tdLPhe+8PajJqei+JQ62El5EIZkkSQROkigkcMR8wOD+HO7rngn4ZeENXu9F1bxH4huNUsZDBdPY6fF5Pmrw4Te4JAORk9cUpp1nUp4inaC5LfvIx2haPvNNSvHXRLvpewehV/4Zk+JH/QAh/wDBnaf/AB2io/7M+EX/AEHfFn/gvg/+OUVz/U8D2/8AK0P/AJWO7HftN/8AJc/FX/XWH/0RHXmFFFeXm3/IwxH+OX/pTHHZHtOp/wDIgfAj/r6vv/S9a4v42f8AJXvGP/YVuP8A0M0UV6uZf7t/4J/9MoS3OKooor5Us//Z


上面那段是png的 base64编码的文本转为图片中jpeg保存为白色背景问题

#7


把你的图片覆盖到一个白色的底图上面。

#8


引用 7 楼 closurer 的回复:
把你的图片覆盖到一个白色的底图上面。

我方法二就这么做的但是不知道为啥没有用,

#9


引用 8 楼 excalibur_zbs 的回复:
Quote: 引用 7 楼 closurer 的回复:

把你的图片覆盖到一个白色的底图上面。

我方法二就这么做的但是不知道为啥没有用,


这样做是可行的。我的 图片缩放模块就是这样做的。

我看到你对底图的宽和高做了计算,需要检查一下覆盖的时候,位置是否有对准。

#10


我测试过你的发的 png 图片了,里面并没有透明像素。

……

#11


base64编码的文本转为图片中jpeg保存为白色背景问题

#12


引用 10 楼 closurer 的回复:
我测试过你的发的 png 图片了,里面并没有透明像素。

……

png 没有问题 只要 Bitmap.MakeTransparent();  一下就可以
问题是jqeg 不支持透明所以无内容区域会变成 黑色? 还是说本来就黑色的低所以 不管这么处理都是黑色的?

#13


base64编码的文本转为图片中jpeg保存为白色背景问题

这张可以。

#14


引用 13 楼 closurer 的回复:
base64编码的文本转为图片中jpeg保存为白色背景问题

这张可以。

额,问题出现在上传慢和jqeg无法透明的问题上,本来我是直接转出png的base64 码的但是太大,现在客户手机截图随便一张都5~10M,所以我就转成jqeg的,但是却不支持透明,所以我想做成白色的底这样和页面背景一样也就不会影响用户体验

#15


手机截图可以有透明像素?

#16


引用 15 楼 closurer 的回复:
手机截图可以有透明像素?
不是,我用的截图插件,如果客户只截图图的一部分一部分未空,那么最后一部分图片会没有内容。而没有内容的部分会默认为黑色背景
base64编码的文本转为图片中jpeg保存为白色背景问题

#17


非要把简单的事情弄复杂了,真高人也
        public Form1()
        {
            InitializeComponent();
            var s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAYAAACoYAD2AAAE30lEQVRYR+2Ya4gbVRTH/+em2e3iVtvMvpS21Apa/aAUXZF+EBXBR0Fsxa2biQsLRStorVAqUjOZTCxYKrSriC1Si+3OLkStD6SoXyyCCtYHolIfVEtbXfcx2coi62aTe+TOJm2STZpJJl8KvRAId87jl/M/9965IVwEgy4CRlyCbJRKlyp5qZKNqkCj4jSsJ5eYB5eL7ILbIbibGDczsAxzn9IcDOA0AaeZ8A0kHZOBzGeTZt+pSj/KF2Tn1oOXZVvEowx6CIQ7AQTqrF4WjE8J/E5gWh4afanv38I4dUEuNg8sFrLpaQIeB3BlCdgYgO9B+IWYTzJoDIKmXBvJiwjcwUQrwLgOwE0AOkr8RxjYJ0V64KzZf1Y9qxlSi9pPgmAC0PLBCfhDgg6TwJFFmPnipNn/n5eKrjAPLJxC8xqWuF+A1zNwdYGfA3DMsSKveobsNO2VmSztB/Ed5wIxHQXxHscKfwCQ6jUfg0kzhh4A05aiHFBt4GFoxuA6gGwALTnznyGw3TH1wx7cazbRTHs9JHYAWOVJbi1qbwZhIJ+JwbtSVmRbzZnrcAjF7F3E2HrBSrYZtsVANBc/DUEbHDP8X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5CYII=";
            var b = Convert.FromBase64String(s.Split(',')[1]);
            MemoryStream mysm = new MemoryStream(b);
            Image ims = Image.FromStream(mysm);
            pictureBox1.Image = ims;

            var bm = new Bitmap(pictureBox2.Width, pictureBox2.Height);
            pictureBox2.Image = bm;
            s = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAAiACIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD4F1X4P+EfCV3/AGX4o+Ig0nX4URruwttFlukt2ZQwTzVcBjgjJAxVP/hA/hl/0VSb/wAJqf8A+OUftN/8lz8Vf9dYf/REdeYV9DjKuGwuJq4eOGg1CTV26l3Z21tNK/ol6Eq7V7nceNvhl/wjk3h+fRtVj8RaPr6t/Z18kLW7Sur+W6NGxypViB1xz1646HU/hR4G8OX8+l618TRaavaN5V3b22hTTxxSj7yCQON2DxnA6Voan/yIHwI/6+r7/wBL1ri/jZ/yV7xj/wBhW4/9GGt8RSw2FhKsqKlf2dk3Ky5qfO7Wknu9Lt6feJXZtf8ACB/DL/oqk3/hNT//AByivMKK8z65Q/6BYffU/wDlg7eZ9BfF34ReJ/ij8QtV8VeFbW01rQdT8qa2u4tQt0DDykUgq7qykEEEEcYrjv8AhmT4kf8AQAh/8Gdp/wDHau+IPh18P/AOqSaF4m8Q65Jr1qqfaxpdjG1ujsobarO4LYDAZxz7Vnf2Z8Iv+g74s/8ABfB/8cr3cTh8PVrzqYiFpttyXtoKzb1VnB216Xdu5Kbtobnj54vBWj/Cjw9qk8K6voElzPqUFvKs32dZLsSICyEgttBJAPp6irXxF+BfjLxr4617X9BsLPVdG1O8ku7S8g1K2CSxu25SA0gI4POR1rivGvw2tdLPhe+8PajJqei+JQ62El5EIZkkSQROkigkcMR8wOD+HO7rngn4ZeENXu9F1bxH4huNUsZDBdPY6fF5Pmrw4Te4JAORk9cUpp1nUp4inaC5LfvIx2haPvNNSvHXRLvpewehV/4Zk+JH/QAh/wDBnaf/AB2io/7M+EX/AEHfFn/gvg/+OUVz/U8D2/8AK0P/AJWO7HftN/8AJc/FX/XWH/0RHXmFFFeXm3/IwxH+OX/pTHHZHtOp/wDIgfAj/r6vv/S9a4v42f8AJXvGP/YVuP8A0M0UV6uZf7t/4J/9MoS3OKooor5Us//Z";
            b = Convert.FromBase64String(s.Split(',')[1]);
            mysm = new MemoryStream(b);
            ims = Image.FromStream(mysm);

            var g = Graphics.FromImage(bm);
            g.Clear(Color.White);
            g.DrawImage(ims, 0, 0);
            g.DrawImage(pictureBox1.Image, new Point(0, pictureBox2.Height / 2));
        }
base64编码的文本转为图片中jpeg保存为白色背景问题

#18


引用 17 楼 xuzuning 的回复:
非要把简单的事情弄复杂了,真高人也
        public Form1()
        {
            InitializeComponent();
            var s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAYAAACoYAD2AAAE30lEQVRYR+2Ya4gbVRTH/+em2e3iVtvMvpS21Apa/aAUXZF+EBXBR0Fsxa2biQsLRStorVAqUjOZTCxYKrSriC1Si+3OLkStD6SoXyyCCtYHolIfVEtbXfcx2coi62aTe+TOJm2STZpJJl8KvRAId87jl/M/9965IVwEgy4CRlyCbJRKlyp5qZKNqkCj4jSsJ5eYB5eL7ILbIbibGDczsAxzn9IcDOA0AaeZ8A0kHZOBzGeTZt+pSj/KF2Tn1oOXZVvEowx6CIQ7AQTqrF4WjE8J/E5gWh4afanv38I4dUEuNg8sFrLpaQIeB3BlCdgYgO9B+IWYTzJoDIKmXBvJiwjcwUQrwLgOwE0AOkr8RxjYJ0V64KzZf1Y9qxlSi9pPgmAC0PLBCfhDgg6TwJFFmPnipNn/n5eKrjAPLJxC8xqWuF+A1zNwdYGfA3DMsSKveobsNO2VmSztB/Ed5wIxHQXxHscKfwCQ6jUfg0kzhh4A05aiHFBt4GFoxuA6gGwALTnznyGw3TH1wx7cazbRTHs9JHYAWOVJbi1qbwZhIJ+JwbtSVmRbzZnrcAjF7F3E2HrBSrYZtsVANBc/DUEbHDP8Xh356nZRKlaELKnguBTZuybNvh/rzubDsSxkmzG8liE/zPXDhBS8OmVGzvjI48t1HmS7meyScvav3PbERIFVE/FHfvWVxafzPEjNsI8BuEXFFYS143H9iM8cvt2LIEPRoY1E/Hou6oBj6VvKZWiPDq9mkutAYu9EvFdVvWGjLTZ8FVhuIhbvjid6vyvagtzdXzal5vZC+tOxwksrZQ4Z9gkCVgIY5azoTu3oPd0IytD24WUUkErJTgZ+T1n6NUWQoeiQQcRxNcmC7kuZ4Y8uABklwMo9H2HBt/pdWCFzcClJ+ir/LsCAkbL0xHnIx/YFta5WVcVWAF87lt5drTLFeyj/zQLd9YLOAeIYQF05qMSEpRt5BrcnQ8ZQP4HfcKtIfE8qHvmkGqR6rsXsBBjP52zrkr5QYjcO4QUnrucPkNyUSmYMfg7Qmmq9WA68BLQm6UslLgfocnfGDnZkODA6h8wvOvHIc16qWGhTj/TVJC6MT1p0KALiQ67UTGtSifCXtULWKr0XiYshY/ZrYGwCkHKOBzvwVk+2HsgyoGWl9ypxMeS5fsTHjqXfWy9g3u9C0tcicQmkrU4MdU+peMLUCq4ZQ08B/HJ+1TsiuNyttJxVN8LOuXna7FjhV7zEJs2wM+qWx8zPpBKRPV6cimzMZFNbekabaQrMqvkF0wtmJ3f2/KOdbyPV7cdzYNfn9pS9Tlx/YsmzySsyLZmgmmtOZ4MLp5vPntndM13KoCDzd5M+x9LdBeR1hIzBDQTaDaAdQLrAT313ALjHWplxIneRayp4pmAnAd7mWJE3S+XOQz7oWPr7XgFd+QxbHQD9tfhUtWV620mEH24Y5OVmMhTMpjeSoE5mmpkPICWIloHR53YhcZIZvwFCzJOUuJkZY2lB+6fM8EQlyJrlrloV1QdzL9EjylYy3ziZiPzgxa8U0t/CqZIxFBu8jZjcA6Lel2i1cBq+BRVyNwgy/3LRmM28tLCNkdvnsdhuJlslMndXVD0rrwXRTnfhAAkW9G0l2yxmjub/pCruSZ8vGJph/wTghloXQwX7U44VXlH6v9L/w88+LApG1A4AAAAASUVORK5CYII=";
            var b = Convert.FromBase64String(s.Split(',')[1]);
            MemoryStream mysm = new MemoryStream(b);
            Image ims = Image.FromStream(mysm);
            pictureBox1.Image = ims;

            var bm = new Bitmap(pictureBox2.Width, pictureBox2.Height);
            pictureBox2.Image = bm;
            s = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFB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8qa2u4tQt0DDykUgq7qykEEEEcYrjv8AhmT4kf8AQAh/8Gdp/wDHau+IPh18P/AOqSaF4m8Q65Jr1qqfaxpdjG1ujsobarO4LYDAZxz7Vnf2Z8Iv+g74s/8ABfB/8cr3cTh8PVrzqYiFpttyXtoKzb1VnB216Xdu5Kbtobnj54vBWj/Cjw9qk8K6voElzPqUFvKs32dZLsSICyEgttBJAPp6irXxF+BfjLxr4617X9BsLPVdG1O8ku7S8g1K2CSxu25SA0gI4POR1rivGvw2tdLPhe+8PajJqei+JQ62El5EIZkkSQROkigkcMR8wOD+HO7rngn4ZeENXu9F1bxH4huNUsZDBdPY6fF5Pmrw4Te4JAORk9cUpp1nUp4inaC5LfvIx2haPvNNSvHXRLvpewehV/4Zk+JH/QAh/wDBnaf/AB2io/7M+EX/AEHfFn/gvg/+OUVz/U8D2/8AK0P/AJWO7HftN/8AJc/FX/XWH/0RHXmFFFeXm3/IwxH+OX/pTHHZHtOp/wDIgfAj/r6vv/S9a4v42f8AJXvGP/YVuP8A0M0UV6uZf7t/4J/9MoS3OKooor5Us//Z";
            b = Convert.FromBase64String(s.Split(',')[1]);
            mysm = new MemoryStream(b);
            ims = Image.FromStream(mysm);

            var g = Graphics.FromImage(bm);
            g.Clear(Color.White);
            g.DrawImage(ims, 0, 0);
            g.DrawImage(pictureBox1.Image, new Point(0, pictureBox2.Height / 2));
        }
base64编码的文本转为图片中jpeg保存为白色背景问题

也许我真的太笨了,
这样?
                    Image img = Image.FromStream(ms, true);
                    int width = img.Width;
                    int height = img.Height;
                    Bitmap bm = new Bitmap(width, height);
                    Graphics g = Graphics.FromImage(bm);
                    g.Clear(Color.White);
                    g.DrawImage(img, 0, 0);
                    img.Save(ImgUrl + ".jpeg", ImageFormat.Jpeg);

还是就是这样不行 base64编码的文本转为图片中jpeg保存为白色背景问题
嗯,还有就png是没有问题的没有任何问题 Bitmap.MakeTransparent();一下就OK了 ,
现在是 data:image/jpeg;base64 这无法做到白底

#19


哦,你是要去除那个 jpg 的黑色背景
             var c = (ims as Bitmap).GetPixel(0, 0).GetBrightness()+0.1f;
            for (var x = 0; x < ims.Width; x++)
            {
                for (var y = 0; y < ims.Height; y++)
                {
                    if ((ims as Bitmap).GetPixel(x, y).GetBrightness() <= c) (ims as Bitmap).SetPixel(x, y, Color.White);
                }
            }
base64编码的文本转为图片中jpeg保存为白色背景问题

#20


引用 19 楼 xuzuning 的回复:
哦,你是要去除那个 jpg 的黑色背景
             var c = (ims as Bitmap).GetPixel(0, 0).GetBrightness()+0.1f;
            for (var x = 0; x < ims.Width; x++)
            {
                for (var y = 0; y < ims.Height; y++)
                {
                    if ((ims as Bitmap).GetPixel(x, y).GetBrightness() <= c) (ims as Bitmap).SetPixel(x, y, Color.White);
                }
            }
base64编码的文本转为图片中jpeg保存为白色背景问题

对的 
                    Image img = Image.FromStream(ms, true);
                    var c = (img as Bitmap).GetPixel(0, 0).GetBrightness() + 0.1f;
                    for (var x = 0; x < img.Width; x++)
                    {
                        for (var y = 0; y < img.Height; y++)
                        {
                            if ((img as Bitmap).GetPixel(x, y).GetBrightness() <= c)
                                (img as Bitmap).SetPixel(x, y, Color.White);
                        }
                    }
                    img.Save(ImgUrl + ".jpeg", ImageFormat.Jpeg);

但是还是有点问题,有点的图片会变成纯白的 ,比如
base64编码的文本转为图片中jpeg保存为白色背景问题
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCABeAF4DASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxF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xnuUY4WVQcqOQeo5IB/9k=

不过能出来结果了,我自己再纠结,纠结吧。实在不行就看看别的思路吧,谢谢两位大神

#1


base64编码的文本转为图片中jpeg保存为白色背景问题

#2


base64编码的文本转为图片中jpeg保存为白色背景问题

#3


你应给出数据,用于测试你的代码

#4


引用 3 楼 xuzuning 的回复:
你应给出数据,用于测试你的代码
base64码?但是好长呀?我在楼下放一段出来吧。

#5



data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAYAAACoYAD2AAAE30lEQVRYR+2Ya4gbVRTH/+em2e3iVtvMvpS21Apa/aAUXZF+EBXBR0Fsxa2biQsLRStorVAqUjOZTCxYKrSriC1Si+3OLkStD6SoXyyCCtYHolIfVEtbXfcx2coi62aTe+TOJm2STZpJJl8KvRAId87jl/M/9965IVwEgy4CRlyCbJRKlyp5qZKNqkCj4jSsJ5eYB5eL7ILbIbibGDczsAxzn9IcDOA0AaeZ8A0kHZOBzGeTZt+pSj/KF2Tn1oOXZVvEowx6CIQ7AQTqrF4WjE8J/E5gWh4afanv38I4dUEuNg8sFrLpaQIeB3BlCdgYgO9B+IWYTzJoDIKmXBvJiwjcwUQrwLgOwE0AOkr8RxjYJ0V64KzZf1Y9qxlSi9pPgmAC0PLBCfhDgg6TwJFFmPnipNn/n5eKrjAPLJxC8xqWuF+A1zNwdYGfA3DMsSKveobsNO2VmSztB/Ed5wIxHQXxHscKfwCQ6jUfg0kzhh4A05aiHFBt4GFoxuA6gGwALTnznyGw3TH1wx7cazbRTHs9JHYAWOVJbi1qbwZhIJ+JwbtSVmRbzZnrcAjF7F3E2HrBSrYZtsVANBc/DUEbHDP8Xh356nZRKlaELKnguBTZuybNvh/rzubDsSxkmzG8liE/zPXDhBS8OmVGzvjI48t1HmS7meyScvav3PbERIFVE/FHfvWVxafzPEjNsI8BuEXFFYS143H9iM8cvt2LIEPRoY1E/Hou6oBj6VvKZWiPDq9mkutAYu9EvFdVvWGjLTZ8FVhuIhbvjid6vyvagtzdXzal5vZ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Qt0DDykUgq7qykEEEEcYrjv8AhmT4kf8AQAh/8Gdp/wDHau+IPh18P/AOqSaF4m8Q65Jr1qqfaxpdjG1ujsobarO4LYDAZxz7Vnf2Z8Iv+g74s/8ABfB/8cr3cTh8PVrzqYiFpttyXtoKzb1VnB216Xdu5Kbtobnj54vBWj/Cjw9qk8K6voElzPqUFvKs32dZLsSICyEgttBJAPp6irXxF+BfjLxr4617X9BsLPVdG1O8ku7S8g1K2CSxu25SA0gI4POR1rivGvw2tdLPhe+8PajJqei+JQ62El5EIZkkSQROkigkcMR8wOD+HO7rngn4ZeENXu9F1bxH4huNUsZDBdPY6fF5Pmrw4Te4JAORk9cUpp1nUp4inaC5LfvIx2haPvNNSvHXRLvpewehV/4Zk+JH/QAh/wDBnaf/AB2io/7M+EX/AEHfFn/gvg/+OUVz/U8D2/8AK0P/AJWO7HftN/8AJc/FX/XWH/0RHXmFFFeXm3/IwxH+OX/pTHHZHtOp/wDIgfAj/r6vv/S9a4v42f8AJXvGP/YVuP8A0M0UV6uZf7t/4J/9MoS3OKooor5Us//Z


上面那段是png的 base64编码的文本转为图片中jpeg保存为白色背景问题

#7


把你的图片覆盖到一个白色的底图上面。

#8


引用 7 楼 closurer 的回复:
把你的图片覆盖到一个白色的底图上面。

我方法二就这么做的但是不知道为啥没有用,

#9


引用 8 楼 excalibur_zbs 的回复:
Quote: 引用 7 楼 closurer 的回复:

把你的图片覆盖到一个白色的底图上面。

我方法二就这么做的但是不知道为啥没有用,


这样做是可行的。我的 图片缩放模块就是这样做的。

我看到你对底图的宽和高做了计算,需要检查一下覆盖的时候,位置是否有对准。

#10


我测试过你的发的 png 图片了,里面并没有透明像素。

……

#11


base64编码的文本转为图片中jpeg保存为白色背景问题

#12


引用 10 楼 closurer 的回复:
我测试过你的发的 png 图片了,里面并没有透明像素。

……

png 没有问题 只要 Bitmap.MakeTransparent();  一下就可以
问题是jqeg 不支持透明所以无内容区域会变成 黑色? 还是说本来就黑色的低所以 不管这么处理都是黑色的?

#13


base64编码的文本转为图片中jpeg保存为白色背景问题

这张可以。

#14


引用 13 楼 closurer 的回复:
base64编码的文本转为图片中jpeg保存为白色背景问题

这张可以。

额,问题出现在上传慢和jqeg无法透明的问题上,本来我是直接转出png的base64 码的但是太大,现在客户手机截图随便一张都5~10M,所以我就转成jqeg的,但是却不支持透明,所以我想做成白色的底这样和页面背景一样也就不会影响用户体验

#15


手机截图可以有透明像素?

#16


引用 15 楼 closurer 的回复:
手机截图可以有透明像素?
不是,我用的截图插件,如果客户只截图图的一部分一部分未空,那么最后一部分图片会没有内容。而没有内容的部分会默认为黑色背景
base64编码的文本转为图片中jpeg保存为白色背景问题

#17


非要把简单的事情弄复杂了,真高人也
        public Form1()
        {
            InitializeComponent();
            var s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAYAAACoYAD2AAAE30lEQVRYR+2Ya4gbVRTH/+em2e3iVtvMvpS21Apa/aAUXZF+EBXBR0Fsxa2biQsLRStorVAqUjOZTCxYKrSriC1Si+3OLkStD6SoXyyCCtYHolIfVEtbXfcx2coi62aTe+TOJm2STZpJJl8KvRAId87jl/M/9965IVwEgy4CRlyCbJRKlyp5qZKNqkCj4jSsJ5eYB5eL7ILbIbibGDczsAxzn9IcDOA0AaeZ8A0kHZOBzGeTZt+pSj/KF2Tn1oOXZVvEowx6CIQ7AQTqrF4WjE8J/E5gWh4afanv38I4dUEuNg8sFrLpaQIeB3BlCdgYgO9B+IWYTzJoDIKmXBvJiwjcwUQrwLgOwE0AOkr8RxjYJ0V64KzZf1Y9qxlSi9pPgmAC0PLBCfhDgg6TwJFFmPnipNn/n5eKrjAPLJxC8xqWuF+A1zNwdYGfA3DMsSKveobsNO2VmSztB/Ed5wIxHQXxHscKfwCQ6jUfg0kzhh4A05aiHFBt4GFoxuA6gGwALTnznyGw3TH1wx7cazbRTHs9JHYAWOVJbi1qbwZhIJ+JwbtSVmRbzZnrcAjF7F3E2HrBSrYZtsVANBc/DUEbHDP8Xh356nZR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";
            var b = Convert.FromBase64String(s.Split(',')[1]);
            MemoryStream mysm = new MemoryStream(b);
            Image ims = Image.FromStream(mysm);
            pictureBox1.Image = ims;

            var bm = new Bitmap(pictureBox2.Width, pictureBox2.Height);
            pictureBox2.Image = bm;
            s = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAAiACIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD4F1X4P+EfCV3/AGX4o+Ig0nX4URruwttFlukt2ZQwTzVcBjgjJAxVP/hA/hl/0VSb/wAJqf8A+OUftN/8lz8Vf9dYf/REdeYV9DjKuGwuJq4eOGg1CTV26l3Z21tNK/ol6Eq7V7nceNvhl/wjk3h+fRtVj8RaPr6t/Z18kLW7Sur+W6NGxypViB1xz1646HU/hR4G8OX8+l618TRaavaN5V3b22hTTxxSj7yCQON2DxnA6Voan/yIHwI/6+r7/wBL1ri/jZ/yV7xj/wBhW4/9GGt8RSw2FhKsqKlf2dk3Ky5qfO7Wknu9Lt6feJXZtf8ACB/DL/oqk3/hNT//AByivMKK8z65Q/6BYffU/wDlg7eZ9BfF34ReJ/ij8QtV8VeFbW01rQdT8qa2u4tQt0DDykUgq7qykEEEEcYrjv8AhmT4kf8AQAh/8Gdp/wDHau+IPh18P/AOqSaF4m8Q65Jr1qqfaxpdjG1ujsobarO4LYDAZxz7Vnf2Z8Iv+g74s/8ABfB/8cr3cTh8PVrzqYiFpttyXtoKzb1VnB216Xdu5Kbtobnj54vBWj/Cjw9qk8K6voElzPqUFvKs32dZLsSICyEgttBJAPp6irXxF+BfjLxr4617X9BsLPVdG1O8ku7S8g1K2CSxu25SA0gI4POR1rivGvw2tdLPhe+8PajJqei+JQ62El5EIZkkSQROkigkcMR8wOD+HO7rngn4ZeENXu9F1bxH4huNUsZDBdPY6fF5Pmrw4Te4JAORk9cUpp1nUp4inaC5LfvIx2haPvNNSvHXRLvpewehV/4Zk+JH/QAh/wDBnaf/AB2io/7M+EX/AEHfFn/gvg/+OUVz/U8D2/8AK0P/AJWO7HftN/8AJc/FX/XWH/0RHXmFFFeXm3/IwxH+OX/pTHHZHtOp/wDIgfAj/r6vv/S9a4v42f8AJXvGP/YVuP8A0M0UV6uZf7t/4J/9MoS3OKooor5Us//Z";
            b = Convert.FromBase64String(s.Split(',')[1]);
            mysm = new MemoryStream(b);
            ims = Image.FromStream(mysm);

            var g = Graphics.FromImage(bm);
            g.Clear(Color.White);
            g.DrawImage(ims, 0, 0);
            g.DrawImage(pictureBox1.Image, new Point(0, pictureBox2.Height / 2));
        }
base64编码的文本转为图片中jpeg保存为白色背景问题

#18


引用 17 楼 xuzuning 的回复:
非要把简单的事情弄复杂了,真高人也
        public Form1()
        {
            InitializeComponent();
            var s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAYAAACoYAD2AAAE30lEQVRYR+2Ya4gbVRTH/+em2e3iVtvMvpS21Apa/aAUXZF+EBXBR0Fsxa2biQsLRStorVAqUjOZTCxYKrSriC1Si+3OLkStD6SoXyyCCtYHolIfVEtbXfcx2coi62aTe+TOJm2STZpJJl8KvRAId87jl/M/9965IVwEgy4CRlyCbJRKlyp5qZKNqkCj4jSsJ5eYB5eL7ILbIbibGDczsAxzn9IcDOA0AaeZ8A0kHZOBzGeTZt+pSj/KF2Tn1oOXZVvEowx6CIQ7AQTqrF4WjE8J/E5gWh4afanv38I4dUEuNg8sFrLpaQIeB3BlCdgYgO9B+IWYTzJoDIKmXBvJiwjcwUQrwLgOwE0AOkr8RxjYJ0V64KzZf1Y9qxlSi9pPgmAC0PLBCfhDgg6TwJFFmPnipNn/n5eKrjAPLJxC8xqWuF+A1zNwdYGfA3DMsSKveobsNO2VmSztB/Ed5wIxHQXxHscKfwCQ6jUfg0kzhh4A05aiHFBt4GFoxuA6gGwALTnznyGw3TH1wx7cazbRTHs9JHYAWOVJbi1qbwZhIJ+JwbtSVmRbzZnrcAjF7F3E2HrBSrYZtsVANBc/DUEbHDP8Xh356nZRKlaELKnguBTZuybNvh/rzubDsSxkmzG8liE/zPXDhBS8OmVGzvjI48t1HmS7meyScvav3PbERIFVE/FHfvWVxafzPEjNsI8BuEXFFYS143H9iM8cvt2LIEPRoY1E/Hou6oBj6VvKZWiPDq9mkutAYu9EvFdVvWGjLTZ8FVhuIhbvjid6vyvagtzdXzal5vZC+tOxwksrZQ4Z9gkCVgIY5azoTu3oPd0IytD24WUUkErJTgZ+T1n6NUWQoeiQQcRxNcmC7kuZ4Y8uABklwMo9H2HBt/pdWCFzcClJ+ir/LsCAkbL0xHnIx/YFta5WVcVWAF87lt5drTLFeyj/zQLd9YLOAeIYQF05qMSEpRt5BrcnQ8ZQP4HfcKtIfE8qHvmkGqR6rsXsBBjP52zrkr5QYjcO4QUnrucPkNyUSmYMfg7Qmmq9WA68BLQm6UslLgfocnfGDnZkODA6h8wvOvHIc16qWGhTj/TVJC6MT1p0KALiQ67UTGtSifCXtULWKr0XiYshY/ZrYGwCkHKOBzvwVk+2HsgyoGWl9ypxMeS5fsTHjqXfWy9g3u9C0tcicQmkrU4MdU+peMLUCq4ZQ08B/HJ+1TsiuNyttJxVN8LOuXna7FjhV7zEJs2wM+qWx8zPpBKRPV6cimzMZFNbekabaQrMqvkF0wtmJ3f2/KOdbyPV7cdzYNfn9pS9Tlx/YsmzySsyLZmgmmtOZ4MLp5vPntndM13KoCDzd5M+x9LdBeR1hIzBDQTaDaAdQLrAT313ALjHWplxIneRayp4pmAnAd7mWJE3S+XOQz7oWPr7XgFd+QxbHQD9tfhUtWV620mEH24Y5OVmMhTMpjeSoE5mmpkPICWIloHR53YhcZIZvwFCzJOUuJkZY2lB+6fM8EQlyJrlrloV1QdzL9EjylYy3ziZiPzgxa8U0t/CqZIxFBu8jZjcA6Lel2i1cBq+BRVyNwgy/3LRmM28tLCNkdvnsdhuJlslMndXVD0rrwXRTnfhAAkW9G0l2yxmjub/pCruSZ8vGJph/wTghloXQwX7U44VXlH6v9L/w88+LApG1A4AAAAASUVORK5CYII=";
            var b = Convert.FromBase64String(s.Split(',')[1]);
            MemoryStream mysm = new MemoryStream(b);
            Image ims = Image.FromStream(mysm);
            pictureBox1.Image = ims;

            var bm = new Bitmap(pictureBox2.Width, pictureBox2.Height);
            pictureBox2.Image = bm;
            s = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQ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4tQt0DDykUgq7qykEEEEcYrjv8AhmT4kf8AQAh/8Gdp/wDHau+IPh18P/AOqSaF4m8Q65Jr1qqfaxpdjG1ujsobarO4LYDAZxz7Vnf2Z8Iv+g74s/8ABfB/8cr3cTh8PVrzqYiFpttyXtoKzb1VnB216Xdu5Kbtobnj54vBWj/Cjw9qk8K6voElzPqUFvKs32dZLsSICyEgttBJAPp6irXxF+BfjLxr4617X9BsLPVdG1O8ku7S8g1K2CSxu25SA0gI4POR1rivGvw2tdLPhe+8PajJqei+JQ62El5EIZkkSQROkigkcMR8wOD+HO7rngn4ZeENXu9F1bxH4huNUsZDBdPY6fF5Pmrw4Te4JAORk9cUpp1nUp4inaC5LfvIx2haPvNNSvHXRLvpewehV/4Zk+JH/QAh/wDBnaf/AB2io/7M+EX/AEHfFn/gvg/+OUVz/U8D2/8AK0P/AJWO7HftN/8AJc/FX/XWH/0RHXmFFFeXm3/IwxH+OX/pTHHZHtOp/wDIgfAj/r6vv/S9a4v42f8AJXvGP/YVuP8A0M0UV6uZf7t/4J/9MoS3OKooor5Us//Z";
            b = Convert.FromBase64String(s.Split(',')[1]);
            mysm = new MemoryStream(b);
            ims = Image.FromStream(mysm);

            var g = Graphics.FromImage(bm);
            g.Clear(Color.White);
            g.DrawImage(ims, 0, 0);
            g.DrawImage(pictureBox1.Image, new Point(0, pictureBox2.Height / 2));
        }
base64编码的文本转为图片中jpeg保存为白色背景问题

也许我真的太笨了,
这样?
                    Image img = Image.FromStream(ms, true);
                    int width = img.Width;
                    int height = img.Height;
                    Bitmap bm = new Bitmap(width, height);
                    Graphics g = Graphics.FromImage(bm);
                    g.Clear(Color.White);
                    g.DrawImage(img, 0, 0);
                    img.Save(ImgUrl + ".jpeg", ImageFormat.Jpeg);

还是就是这样不行 base64编码的文本转为图片中jpeg保存为白色背景问题
嗯,还有就png是没有问题的没有任何问题 Bitmap.MakeTransparent();一下就OK了 ,
现在是 data:image/jpeg;base64 这无法做到白底

#19


哦,你是要去除那个 jpg 的黑色背景
             var c = (ims as Bitmap).GetPixel(0, 0).GetBrightness()+0.1f;
            for (var x = 0; x < ims.Width; x++)
            {
                for (var y = 0; y < ims.Height; y++)
                {
                    if ((ims as Bitmap).GetPixel(x, y).GetBrightness() <= c) (ims as Bitmap).SetPixel(x, y, Color.White);
                }
            }
base64编码的文本转为图片中jpeg保存为白色背景问题

#20


引用 19 楼 xuzuning 的回复:
哦,你是要去除那个 jpg 的黑色背景
             var c = (ims as Bitmap).GetPixel(0, 0).GetBrightness()+0.1f;
            for (var x = 0; x < ims.Width; x++)
            {
                for (var y = 0; y < ims.Height; y++)
                {
                    if ((ims as Bitmap).GetPixel(x, y).GetBrightness() <= c) (ims as Bitmap).SetPixel(x, y, Color.White);
                }
            }
base64编码的文本转为图片中jpeg保存为白色背景问题

对的 
                    Image img = Image.FromStream(ms, true);
                    var c = (img as Bitmap).GetPixel(0, 0).GetBrightness() + 0.1f;
                    for (var x = 0; x < img.Width; x++)
                    {
                        for (var y = 0; y < img.Height; y++)
                        {
                            if ((img as Bitmap).GetPixel(x, y).GetBrightness() <= c)
                                (img as Bitmap).SetPixel(x, y, Color.White);
                        }
                    }
                    img.Save(ImgUrl + ".jpeg", ImageFormat.Jpeg);

但是还是有点问题,有点的图片会变成纯白的 ,比如
base64编码的文本转为图片中jpeg保存为白色背景问题
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCABeAF4DASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBka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4WVQcqOQeo5IB/9k=

不过能出来结果了,我自己再纠结,纠结吧。实在不行就看看别的思路吧,谢谢两位大神

#21