简体   繁体   English

用十进制数据在C#中创建图像或图形?

[英]Creating image or graphic in C# from decimal data?

Is it possible to create an image or graphic using vector data that has decimal components that vary? 是否可以使用具有不同的十进制组件的矢量数据来创建图像或图形? And, of course, if its possible... then how? 而且,当然,如果它可能......那么如何?

For example: a vector has two points where point one is {9.56, 4.1} and point two is {3.456789,2.12345}. 例如:向量有两个点,其中第一点是{9.56,4.1},第二点是{3.456789,2.12345}。

Note: the precision varies from number to number. 注意:精度因数量而异。

You can draw vectors to a bitmap and then save that bitmap as follows. 您可以将矢量绘制到位图,然后按如下方式保存该位图。

using System.Drawing;
using System.Drawing.Imaging;
.
.  
.
using (Bitmap bmp = new Bitmap(10, 10))
{
    using (Graphics g = Graphics.FromImage(bmp))
    {
        g.Clear(Color.White);
        g.DrawLine(Pens.Black, new PointF(9.56f, 4.1f), new PointF(3.456789f, 2.12345f));
    }
    bmp.Save(@"c:\myimage.jpg", ImageFormat.Jpeg);
}

Oh, sure. 行,可以。 For example, the Line class will draw a line in WPF. 例如,Line类将在WPF中绘制一条线。 It uses two doubles for each coordinate. 它为每个坐标使用两个双打。 X1, Y1 and X2, Y2. X1,Y1和X2,Y2。

If your data is stored in the decimal datatype, you can do a simple cast. 如果您的数据以十进制数据类型存储,则可以进行简单的转换。

Keep in mind, I'm trying to extrapolate what you're trying to do from your question. 请记住,我正试图从你的问题中推断出你想要做的事情。 How are you planning to draw your vector shapes? 你打算如何绘制矢量形状? What's your overall approach? 你的整体方法是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM