---
title: "Android中硬件图片如何转换成软图片"
author: "zhy20045923"
date: "2020-02-29T16:00:25Z"
tags: []
categories: ["移动开发"]
slug: "android"
draft: false
lastmod: "2020-02-29T16:00:25Z"
id: 2512695
url: "https://null-point.iteye.com/blog/2512695"
---

在使用通过系统方式获得的Bitmap时，比如你要通过Canvas操作Bitmap时，就会报错，提示你软硬转换异常。
通过系统方式获取的Bitmap主要是通过HardWareBuffer方式得到的图片，如屏幕截图，TAsk任务截图等
转换的话只需要

Bitmap mutableBimtap = result.copy(Bitmap.Config.ARGB_8888, result.isMutable());

result就是hardWare格式的Bitmap对象
即可