2013-08-25 35 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); 
       } 
      } 
    } 
}