我有大型500MB大小的圖像我想在ASP.net中使用縮放和平移功能來顯示此圖像。我找到了OpenLayers,但任何人都可以使用任何框架/庫共享任何工作示例,以實現ASP.net中的此功能。使用平移&縮放和註釋流式傳輸大圖像
1
A
回答
0
我建議製作一些較小的圖像(Mipmapping http://en.wikipedia.org/wiki/Mipmap)或/並將它們剪切成較小的部分。 (Slice up an image into tiles)
想一想,你看不到500MB數據的所有像素。只傳輸你實際看到的內容。
0
我找到了一個我喜歡和你分享的答案。這裏是代碼
private static void Split(string fileName, int width, int height)
{
using (Bitmap source = new Bitmap(fileName))
{
bool perfectWidth = source.Width % width == 0;
bool perfectHeight = source.Height % height == 0;
int lastWidth = width;
if (!perfectWidth)
{
lastWidth = source.Width - ((source.Width/width) * width);
}
int lastHeight = height;
if (!perfectHeight)
{
lastHeight = source.Height - ((source.Height/height) * height);
}
int widthPartsCount = source.Width/width + (perfectWidth ? 0 : 1);
int heightPartsCount = source.Height/height + (perfectHeight ? 0 : 1);
for (int i = 0; i < widthPartsCount; i++)
for (int j = 0; j < heightPartsCount; j++)
{
int tileWidth = i == widthPartsCount - 1 ? lastWidth : width;
int tileHeight = j == heightPartsCount - 1 ? lastHeight : height;
using (Bitmap tile = new Bitmap(tileWidth, tileHeight))
{
using (Graphics g = Graphics.FromImage(tile))
{
g.DrawImage(source, new Rectangle(0, 0, tile.Width, tile.Height), new Rectangle(i * width, j * height, tile.Width, tile.Height), GraphicsUnit.Pixel);
}
tile.Save(string.Format("{0}-{1}.png", i + 1, j + 1), ImageFormat.Png);
}
}
}
}
相關問題
- 1. 圖像縮放和平移
- 2. 圖像平移和縮放
- 3. 使用d3.js縮放平移圖像
- 4. 使用SDL平滑縮放大圖像
- 5. 在Silverlight中放大平移和縮放圖像
- 6. 縮放和平移QScrollArea中的圖像
- 7. 縮放和平移圖像畫布
- 8. 平移和縮放圖像的jQuery Mobile
- 9. Direct3D是否適用於縮放和平移大圖像?
- 10. 如何使用縮放縮放封面流圖像放大android
- 11. 圖像放大鏡 - 放大圖像懸停和平移圖像鼠標移動
- 12. 用畫布縮放大圖像。平滑
- 13. 圖像縮放和平滑
- 14. 使用ffmpeg平移和縮放多個圖像
- 15. 移動和縮放圖像
- 16. 圖像縮放,平移和切片圖像
- 17. 就像在Bing地圖控件中平移和縮放大圖像
- 18. 縮放/平移framelayout有圖像瀏覽
- 19. Android - WebView縮放/平移圖像
- 20. 縮放和平移的平移和縮放順序
- 21. 2D縮放,縮放和平移
- 22. 如何放大和縮小圖像並移動所有圖像
- 23. 捏放大圖像和縮小圖像
- 24. 使用ASP.Net Webapi流式傳輸大圖像
- 25. 使用CSS縮放圖像中的縮放圖像和/或縮小圖像以適合圖像的最大面
- 26. AChartEngine Android - 重置縮放和平移圖?
- 27. 在Bing地圖上平移和縮放
- 28. 試圖獲得顯示圖像縮放和平移的句柄
- 29. 實現平移和縮放
- 30. 單張縮放和平移
如果我們去切片然後放大和縮小什麼如果用戶想看到完整的圖像 –
結合的方法。做一個piramid。 1圖像縮小爲1024x768(頂級),然後將其切片爲1024x768(第二級)的4幅圖像等。縮放級別決定了您的開啓級別。 (這是谷歌地圖的工作原理)你只需要考慮你應該發送給gui /客戶端的圖像。下面是一些示例:graphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/...請參閱圖像金字塔。 –
正如@JeroenvanLangen所說,你需要某種「地圖平鋪系統」。要獲得一個好的概述,請查看[Bing Maps Tile System](https://msdn.microsoft.com/en-us/library/bb259689.aspx) – SSchuette