根据像素绘制点 [英] Plotting points according to pixel

查看:78
本文介绍了根据像素绘制点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在使用图表控件显示我的项目数据.我想根据高度和宽度绘制点
图表区域.因此,有人可以建议我这样做的方法还是如何转换Datapoints
转换成像素格式???????? :doh:

Hi all,
I am using chart control to show data of my project.I want to plot point according to higth and width
of chart area.So can anybody suggest me the method to do that or how can i convert the Datapoints
into pixel format???????? :doh:

推荐答案

这应该不难.您只需要将数据扩展到可用像素即可.要记住的重要一件事是始终使用单个或什至更好的双浮点值,以避免舍入错误.仅在完成实际绘制时才应用四舍五入.

关于缩放到像素的值:
只需将像素数除以最高数据值即可.假设图表区域为800x600,您的数据为4000x6000.

您会得到:
800/4000 = 0.2
600/6000 = 0.1

这意味着每个x值都乘以0.2,每个y值都乘以-0.1(负数是因为您可能希望最低的值在底部,最高的在顶部,但是对于屏幕绘制而言,却是相反的).

祝你好运!
That shouldn''t be to hard. You just need to scale the data up to the available pixels. An important thing to remember is to always use single, or even better a double floating point values to avoid rounding errors. Rounding should only be applied when actual drawing is done.

About the scaling values to pixels:
Simply divide the number-of-pixels by the highest data value. Lets assume the chart area is 800x600 and your data is 4000x6000.

You get:
800 / 4000 = 0.2
600 / 6000 = 0.1

This means that every x value is multiplied by 0.2 and every y value is multiplied by -0.1 (the minus is because you probably would like the lowest value at the bottom and the highest at the top but for screen drawing it is the opposite).

Good luck!


这篇关于根据像素绘制点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆