2013-08-25 38 views

回答

0

我建議製作一些較小的圖像(Mipmapping http://en.wikipedia.org/wiki/Mipmap)或/並將它們剪切成較小的部分。 (Slice up an image into tiles

想一想,你看不到500MB數據的所有像素。只傳輸你實際看到的內容。

+0

如果我們去切片然後放大和縮小什麼如果用戶想看到完整的圖像 –

+0

結合的方法。做一個piramid。 1圖像縮小爲1024x768(頂級),然後將其切片爲1024x768(第二級)的4幅圖像等。縮放級別決定了您的開啓級別。 (這是谷歌地圖的工作原理)你只需要考慮你應該發送給gui /客戶端的圖像。下面是一些示例:graphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/...請參閱圖像金字塔。 –

+1

正如@JeroenvanLangen所說,你需要某種「地圖平鋪系統」。要獲得一個好的概述,請查看[Bing Maps Tile System](https://msdn.microsoft.com/en-us/library/bb259689.aspx) – SSchuette

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