我需要在perl上绘制2D图像到大小为1024x768的图像;行的坐标是unix时间戳,如x1 = 1365693813 y1 =(某个虚拟中心)x2 = 1365793815 y2 =(某个虚拟中心)。什么公式可以将真实生活中的图像缩放到图像空间中?2D screenpace zooming
0
A
回答
1
假设($x1,$y1)
和($x2,$y2)
定义“视图窗口”你的左下角和右上角的角落,你有一个点要绘制($x3,$y3)
其中$x1 <= $x3 <= $x2
和$y1 <= $y3 <= $y2
。另外假设您正在标准图像空间中(0,0)是图像的左上角。你可以找到($xp, $yp)
为像素坐标,以这样的图像绘制:
# View window
my ($x1,$y1) = (1365693813, 100);
my ($x2,$y2) = (1365693815, 200);
my ($vw ,$vh) = ($x2 - $1, $y2 - $y1);
# Image width/height
my ($imgw,$imgh) = (1024, 768);
# Point to plot in original co-ordinates
my ($x3,$y3) = (1365693814, 150);
# Calculate point to plot in image co-ordinates
my $xp = int(($imgw * ($x3 - $x1)/$vw) + 0.5);
my $yp = int(($imgh * (1.0 - ($y3 - $y1)/$vh)) + 0.5);
# Now plot ($xp, $yp), provided it is inside the graphic!
+0
非常好!有用!谢谢!!:) – Edward83 2013-04-11 14:37:00
相关问题
- 1. Zooming Distortation
- 2. Angular 4 Zooming
- 3. Phonegap Build Inappbrowser Zooming
- 4. Android Zooming For Graphs
- 5. Phonegap iOS InAppBrowser Zooming
- 6. Javascript Cursor Zooming
- 7. zooming后arrayindexoutofbound mapview
- 8. Highstock:xy zooming with panning
- 9. OpenGL Smooth Zooming
- 10. Zooming Out Breaks Navigation CSS
- 11. Highcharts Zooming with Scroll Bar
- 12. Tkinter,canvas,create_text和zooming
- 13. UIScrollView contentLayoutGuide and zooming centered
- 14. android zooming and paning图像画布绘图
- 15. PDF ZOOMING正在褪色的文本
- 16. zooming android image关于图像中心
- 17. Zooming on HTML5 <canvas> and no pixelation for text?
- 18. 如何在Mac上实现Deep Zooming(如Seadragon)?
- 19. Android Image Zooming为什么不使用滚动视图
- 20. 在chart.js类别缩放zooming/blowup和平移选项
- 21. 将2D矢量2D QVector C++
- 22. unity3d(2d)
- 23. 用于手机的2D 2D UIScrollView?
- 24. opencv - 简单的2D <-> 2D变换
- 25. 将2D String数组转换为2D double
- 26. Unity3D 2D重置2D物体位置
- 27. 2D蟒蛇名单2D numpy的阵列
- 28. C++ 2d地图?像2d数组一样?
- 29. 转换2D双到2D浮动
- 30. 查找三对2D/2D记者的Homography
你需要知道的最大x'的'和'之后y'协调 – gaussblurinc 2013-04-11 11:20:16
只取一小部分:'X_MAX = 1024,your_timestamp = x' =>'x = 1024/x_max * your_timestamp' – gaussblurinc 2013-04-11 11:22:05
看起来更像pan而不是zoom?但一般而言,您希望从一个2D空间映射到另一个空间,您需要对这两个空间进行全面描述。图像空间的完整描述很简单。您的“查看窗口”的完整描述(即,您想要在图像上显示的所有可能的时间和y2的值的限制)缺失。定义这一点,并为您提供答案会很简单! – 2013-04-11 12:28:06