首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >大尺寸图像通向OufOfMemoryException

大尺寸图像通向OufOfMemoryException
EN

Stack Overflow用户
提问于 2011-06-16 20:18:18
回答 1查看 204关注 0票数 1

我使用的是OpenMap,必须加载非常大尺寸的图像。

我试图将这些图像加载为大光栅,但使用OufOfMemoryException失败了。在调试模式下,层构造函数告诉我图像尺寸太大。

在OpenMap邮件列表中,我找到了MyJAIPlugin,它允许我加载和显示GeoTiff文件。

如何在OpenMap中显示300mb的GeoTiff?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-16 20:52:03

通过加载文件大小至少为690mb的高清地图,我也遇到了几乎相同的情况。

我还使用了邮件列表中的JAIPlugIn,而且他们内部使用的是与BufferedImage一起工作的OMScalingRaster。这些限制了您的映像大小,并导致调试消息。

我已经通过修改OMScalingRaster解决了这个问题。我已经将BufferedImage更改为TiledImage以处理大图像,并修复了即将出现的错误。在这里,重要的是要更改scaleTo(Projection thisProj)-method,以与JAI一起缩放。

现在,我可以加载文件并将其渲染到地图上。

这是mod。在scaleTo方法的末尾:

代码语言:javascript
复制
            // Now we can grab the bit we want out of the source
            // and
            // scale it to fit the intersection.

            // Calc width adjustment
            float widthAdj = (float) ((double) iRect.width
                    / (double) clipRect.width);
            // Calc height adjustment
            float heightAdj = (float) ((double) iRect.height
                    / (double) clipRect.height);

            // Create the transform
            // JAI-Version
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(sourceImage.getSubImage(clipRect.x,
                    clipRect.y,
                    clipRect.width,
                    clipRect.height).getAsBufferedImage());
            pb.add(widthAdj);          // The xScale
            pb.add(heightAdj);          // The yScale
            pb.add(0.0F);           // The x translation
            pb.add(0.0F);           // The y translation
            RenderedOp newImage = JAI.create("scale",pb, null);

            bitmap = newImage.getAsBufferedImage();


            point1.setLocation(iRect.x, iRect.y);
            // setVisible(currentVisibility);
        }
    } else {
        bitmap = null;
    }
}

对于其他错误,可以用TiledImage替换BufferedImage,使用等效的TiledImage方法。但是为了节省内存,您应该使用带有sharedDataBuffer标志= true的TiledImage构造函数。

对于Exsample this mod。我可以处理比例为1:50000的地图(压缩的690mb),并且我可以在图层显示内存不足之前缩小到1:600000。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6371652

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档