【问题标题】:get bitmap from bitmapdescriptor从位图描述符中获取位图
【发布时间】:2013-02-06 00:14:19
【问题描述】:

是否可以从BitmapDescriptor 获取位图?

我正在尝试使用 googles api 使我的应用程序更加简洁,但我可以制作自定义标记选项对象...我认为 BitmapDescriptor 会扩展 FileDescriptor 但我没有看到。

【问题讨论】:

  • 找到这个运气好吗?

标签: android google-maps


【解决方案1】:

所有的 BitmapDescriptor 都来自 BitmapDescriptorFactory。

MediaStore 中 imageId 的自定义标记示例。

final BitmapFactory.Options bmOptions = new BitmapFactory.Options();
            bmOptions.inSampleSize = 8;  //about the size of standard marker

Bitmap bm = MediaStore.Images.Thumbnails.getThumbnail(
                            context.getContentResolver(), newImageId,
                            MediaStore.Images.Thumbnails.MINI_KIND,
                            bmOptions);
                    if (bm != null) {
                        BitmapDescriptor bd = BitmapDescriptorFactory
                                .fromBitmap(bm);
                        if (bd != null) {
                            markeroptions.icon(bd);

【讨论】:

  • 您不能从文件描述符转换为位图描述符。这是您从媒体存储中的缩略图获取位图描述符的方式(只是实际获取正确大小的位图以显示在谷歌地图上的中间步骤。如果您想在文件中显示位图,则必须加载它进入位图,然后调整大小,然后仍然使用 bitmapFactory 来获取位图描述符,然后将标记的图标更改为并将标记添加到地图中。
  • 当我回答时,您必须使用 bitmapfactory 将自定义图像添加到标记。也许它已经改变了最近没有做太多的android。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-04
  • 2018-07-13
  • 2023-03-09
  • 1970-01-01
  • 2012-02-20
相关资源
最近更新 更多