根据提供的截图信息无法定位是哪个环节的问题,可以提供一份示例代码给你参考,看看能否正常出图。
def mapToPng(): Unit = {
val map = new DMap()
val wsPath = "D:\\ProgramFiles\\SuperMap\\SampleData\\ThemeMap\\Population\\Population.smwu"
// val mapName = "PopulationDistribution"
val mapName = "Country"
val initied = map.initialize(wsPath, mapName, sc)
println("初始化:" + initied)
val layerName = map.m_map.getLayers().get(0).getName()
println("第一个图层名称:" + layerName)
val d = new Dimension(1300, 900)
val scale = 3.06958996816252e-8
val center = new Point2D(11221274.9288006, 4324988.60305797)
// val bytes = map.outputMapToBitmap(d, scale, center)
val bounds = new Rectangle2D(5694019.9914705455, 1336176.6739832237, 16563210.597276606, 7318110.2825711742)
val bytes = map.outputMapToBitmap(d, bounds)
println("长度:" + bytes.length)
import javax.imageio.ImageIO
val input = new ByteArrayInputStream(bytes);
val image = ImageIO.read(input);
//todo 出白图
val ff = new File("data\\map.png");
ImageIO.write(image, "png", ff)
println("完成")
}