1

我有 500MB 大小的大图像我想在 ASP.net 中显示这个图像,比如带有缩放和平移功能的地图。我为此找到了 OpenLayers,但任何人都可以使用任何框架/库共享任何工作示例,以在 ASP.net 中实现此功能

4

2 回答 2

0

我建议制作一些较小的图像(Mipmapping http://en.wikipedia.org/wiki/Mipmap)或/并将它们切成更小的部分。(将图像切片成图块

想一想,500mb 数据的所有像素都看不到。仅传输您实际看到的内容。

于 2013-08-25T21:09:49.583 回答
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);
                }
            }
    }
}
于 2015-08-05T09:14:46.010 回答