参考以下代码可以将 String 转换成 PixelMap
public static PixelMap getMapPixelMap(String urlString) {
InputStream is = null;
PixelMap pixelMap = null;
try {
URL url = new URL(urlString);
URLConnection con = url.openConnection();
con.setConnectTimeout(TIME_OUT);
is = con.getInputStream();
ImageSource source = ImageSource.create(is, new ImageSource.SourceOptions());
ImageSource.DecodingOptions options = new ImageSource.DecodingOptions();
options.desiredSize = new Size(TILE_LENGTH, TILE_LENGTH);
pixelMap = source.createPixelmap(options);
return pixelMap;
} catch (IOException exception) {
LogUtils.info(TAG, "getImagePixelMap:" + exception.getMessage());
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
LogUtils.info(TAG, "getImagePixelMap:" + e.getMessage());
}
}
}
return pixelMap;
}
参考以下代码可以将 String 转换成 PixelMap
public static PixelMap getMapPixelMap(String urlString) {
InputStream is = null;
PixelMap pixelMap = null;
try {
URL url = new URL(urlString);
URLConnection con = url.openConnection();
con.setConnectTimeout(TIME_OUT);
is = con.getInputStream();
ImageSource source = ImageSource.create(is, new ImageSource.SourceOptions());
ImageSource.DecodingOptions options = new ImageSource.DecodingOptions();
options.desiredSize = new Size(TILE_LENGTH, TILE_LENGTH);
pixelMap = source.createPixelmap(options);
return pixelMap;
} catch (IOException exception) {
LogUtils.info(TAG, "getImagePixelMap:" + exception.getMessage());
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
LogUtils.info(TAG, "getImagePixelMap:" + e.getMessage());
}
}
}
return pixelMap;
}
举报