Question

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}.

Note: the precision varies from number to number.

Was it helpful?

Solution

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);
}

OTHER TIPS

Oh, sure. For example, the Line class will draw a line in WPF. It uses two doubles for each coordinate. X1, Y1 and 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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top