添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
using System.Collections.Generic; using System.Runtime.InteropServices; using System.Drawing; using System.Drawing.Imaging; namespace CS_ConsoleTest [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct StPoint public Int64 X, Y; public StPoint(Int64 _x, Int64 _y) { X = _x; Y = _y; } public class ImageWarp // using System.Drawing; // using System.Drawing.Imaging; public Bitmap bmp; public Graphics gph; public ImageWarp(Int32 width, Int32 height) bmp = new Bitmap(width, height); gph = Graphics.FromImage(bmp); gph.Clear(Color.Empty); public void DrawPoint(StPoint pt, Color color, Single thickness = 1.0f) gph.DrawEllipse(new Pen(color, thickness), (int)pt.X - thickness * 0.5f, (int)pt.Y - thickness * 0.5f, thickness, thickness); //gph.FillEllipse(); public void DrawLine(StPoint p0, StPoint p1, Color color, Single thickness = 1.0f) gph.DrawLine(new Pen(color, thickness), p0.X, p0.Y, p1.X, p1.Y); public void DrawPolygon(StPoint[] points, Color color, Single thickness = 1.0f) gph.DrawPolygon(new Pen(color, thickness), DataWarp.ToWinPoints(points)); public void Save(string filename) gph.Save(); gph.Dispose(); bmp.MakeTransparent(Color.Transparent); bmp.Save(filename, ImageFormat.Png); public static void Demo01() ImageWarp image = new ImageWarp(512, 512); image.DrawLine(new StPoint(256, 0), new StPoint(256, 511), Color.Blue, 1.0f); image.DrawLine(new StPoint(0, 256), new StPoint(511, 256), Color.Red, 1.0f); image.DrawPoint(new StPoint(256, 256), Color.Green, 2.0f); image.DrawPoint(new StPoint(0, 0), Color.Black, 10.0f); image.Save("ImageWarp.Demo01.png");

main函数:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CS_ConsoleTest
    class Program
        static void Main(string[] args)
            ImageWarp.Demo01();

// Mylaf 

// 2019-11-08 厦门

环境:Windows 10 x64, VS2017问题:使用C#语言将图像数据写入到PNG格式的图片文件中代码:// Mylaf using System;using System.Collections.Generic;using System.Runtime.InteropServices;using System.Drawing;using System.Drawin... 数据库的Image字段保存的是字节,所以写入数据Image字段和从数据Image字段读取的内容都应该为字节.     1、数据Image字段读文件      文件文件的过程为将文件以流文件形式打开并将内容读取到一个byte数组,然后将此byte数组写入数据库的Image字段。      FileInfo ///ImageData:图片的byte数组数据 ///imageName:图片保存的路径 private void SaveImage(byte[] ImageData, string imageName) //保存图片到本地文件夹 System.IO.MemoryStream ms = new System.IO.Memor
在一些应用设计中肯定会运用到图片,就以窗体应用为例,加入图片的方式有: 1.直接通过图片所在的位置进行添加; 格式: this.BackgroundImage = Image.FromFile(@"盘符:\文件夹名\照片名称"); 例如: this.BackgroundImage = Image.FromFile(@"C:\Users\Desktop\博客编辑\1.jpg"); 2.通过在...
private void btnSavePng_Click(object sender, EventArgs e) // cat.png feather.png Format32bppArgb string strOldFilePath = @"D:\icon\colorpen.jpg"; Image img = Image.FromFile(Application.StartupPath + "\\Sig.png"); using (var bmp = new Bitmap(img.Width, img.Height)) 其实可以直接把数据在图片里! 做法很简单!我了点代码,大家可以参考下! https://hub004.xindong.com/yangyiqiang/AvatarTool/blob/master/src/utils/As3PngEncoder.as 原理就是把PNG数据格式中的IEND给替换成你要
Sharp代码 StreamWriter是一个用于将数据写入文本文件的类。在C#中,您可以使用StreamWriter类来写入文本文件,下面是一个基本的示例代码: using System; using System.IO; class Program static void Main(string[] args) string filePath = @"C:\Users\UserName\Desktop\example.txt"; using (StreamWriter writer = new StreamWriter(filePath)) writer.WriteLine("Hello World!"); 以上代码可以将字符串“Hello World!”写入名为“example.txt”的文本文件中。请注意,使用“using”语句可以确保StreamWriter实例在使用后被正确释放。
CSDN-Ada助手: 非常感谢您分享了这篇有价值的博客!CMakeLists.txt 是一个非常重要的项目模板,它能够帮助我们快速构建项目,提高开发效率。希望您能够继续分享更多关于 CMake 的经验和技巧,比如如何使用 CMake 进行跨平台开发、如何将 CMake 与多线程编程相结合等,都是非常有价值的主题。期待您的下一篇技术博文! 为了方便博主创作,提高生产力,CSDN上线了AI写作助手功能,就在创作编辑器右侧哦~(https://mp.csdn.net/edit?utm_source=blog_comment_recall )诚邀您来加入测评,到此(https://activity.csdn.net/creatActivity?id=10450&utm_source=blog_comment_recall)发布测评文章即可获得「话题勋章」,同时还有机会拿定制奖牌。 制作OpenCV相机标定板棋盘格图像 mylaf: 检查一下打印机的分辨率和分辨力,进行换算 制作OpenCV相机标定板棋盘格图像 mylaf: 注意修改自己计算机的分辨率 dpi 制作OpenCV相机标定板棋盘格图像 m0_52689550: 我用a4纸打印出来的图片大小变了一点,请问有啥办法吗 MathGL在Windows下的编译 Amillton: 请问 MathGL调试成功怎么使用呢,已经出现调试会话的可执行文件,然后怎么使用MathGL呢。