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rsXsBBjP52zrkr5QYjcO4QUnrucPkNyUSmYMfg7Qmmq9WA68BLQm6UslLgfocnfGDnZkODA6h8wvOvHIc16qWGhTj/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/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAAiACIDASIAAhEBAxEB/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pdjG1ujsobarO4LYDAZxz7Vnf2Z8Iv+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)); }
#18
非要把简单的事情弄复杂了,真高人也
public Form1() { InitializeComponent(); var s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAYAAACoYAD2AAAE30lEQVRYR+2Ya4gbVRTH/+em2e3iVtvMvpS21Apa/aAUXZF+EBXBR0Fsxa2biQsLRStorVAqUjOZTCxYKrSriC1Si+3OLkStD6SoXyyCCtYHolIfVEtbXfcx2coi62aTe+TOJm2STZpJJl8KvRAId87jl/M/9965IVwEgy4CRlyCbJRKlyp5qZKNqkCj4jSsJ5eYB5eL7ILbIbibGDczsAxzn9IcDOA0AaeZ8A0kHZOBzGeTZt+pSj/KF2Tn1oOXZVvEowx6CIQ7AQTqrF4WjE8J/E5gWh4afanv38I4dUEuNg8sFrLpaQIeB3BlCdgYgO9B+IWY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mWJE3S+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/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAAiACIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzU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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)); }
也许我真的太笨了,
这样?
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);
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); } }
#20
哦,你是要去除那个 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); } }
对的
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);
public Form1() { InitializeComponent(); var s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAYAAACoYAD2AAAE30lEQVRYR+2Ya4gbVRTH/+em2e3iVtvMvpS21Apa/aAUXZF+EBXBR0Fsxa2biQsLRStorVAqUjOZTCxYKrSriC1Si+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sTHjqXfWy9g3u9C0tcicQmkrU4MdU+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/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAAiACIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVW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8g1K2CSxu25SA0gI4POR1rivGvw2tdLPhe+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)); }
#18
非要把简单的事情弄复杂了,真高人也
public Form1() { InitializeComponent(); var s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAYAAACoYAD2AAAE30lEQVRYR+2Ya4gbVRTH/+em2e3iVtvMvpS21Apa/aAUXZF+EBXBR0Fsxa2biQsLRStorVAqUjOZTCxYKrSriC1Si+3OLkStD6SoXyyCCtYHolIfVEtbXfcx2coi62aTe+TOJm2STZpJJl8KvRAId87jl/M/9965IVwEgy4CRlyCbJRKlyp5qZKNqkCj4jSsJ5eYB5eL7ILbIbibGDczsAxzn9IcDOA0AaeZ8A0kHZOBzGeTZt+pSj/KF2Tn1oOXZVvEowx6CIQ7AQTqrF4WjE8J/E5gWh4afanv38I4dUEuNg8sFrLpaQIeB3BlCdgYgO9B+IWYTzJoDIKmXBvJiwjcwUQrwLgOwE0AOkr8RxjYJ0V64KzZf1Y9qxlSi9pPgmAC0PLBCfhDgg6TwJFFmPnipNn/n5eKrjAPLJxC8xqWuF+A1zNwdYGfA3DMsSKveobsNO2VmSztB/Ed5wIxHQXxHscKfwCQ6jUfg0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q+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/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)); }
也许我真的太笨了,
这样?
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);
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); } }
#20
哦,你是要去除那个 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); } }
对的
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);