我需要在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