社区
Android
帖子详情
如何把Bitmap.createBitmap替换为BitmapFactory.decodeStream
ZGDZKJ22
2020-09-15 07:33:27
源代码为:Bitmap bitmap = Bitmap.createBitmap(mDIBPixels, mDIBWidth, mDIBHeight, Bitmap.Config.ARGB_8888);
mDIBPixels为int数组。由于createBitmap GC太严重,想替换成BitmapFactory.decodeStream(),如何实现?
...全文
8377
10
打赏
收藏
如何把Bitmap.createBitmap替换为BitmapFactory.decodeStream
源代码为:Bitmap bitmap = Bitmap.createBitmap(mDIBPixels, mDIBWidth, mDIBHeight, Bitmap.Config.ARGB_8888); mDIBPixels为int数组。由于createBitmap GC太严重,想替换成BitmapFactory.decodeStream(),如何实现?
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
10 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ZGDZKJ22
2020-09-17
打赏
举报
回复
public static Bitmap createBitmap(int[] colors, int width, int height, Bitmap.Config config) 这个函数根据颜色数组来创建位图,注意:颜色数组的长度>=width*height
ZGDZKJ22
2020-09-17
打赏
举报
回复
mDIBPixels用的int数组并且实时是变化的,没法用BitmapFactory.decodeByteArray
z71274520
2020-09-16
打赏
举报
回复
可以,来学习下~
weixin_43845112
2020-09-16
打赏
举报
回复
BitmapFactory.decodeByteArray这个呢?draw的频率应该会比你图片变化的频率高吧?你这样不是很容易outofmomary?
武雅姝
2020-09-16
打赏
举报
回复
回家可好可好
引用
ZGDZKJ22
2020-09-16
打赏
举报
回复
对啊,每次都是变化的
诉平生
2020-09-16
打赏
举报
回复
娄山说的没到了
weixin_43845112
2020-09-16
打赏
举报
回复
你再draw里面实时的创建bitmap去绘制,你难道每次draw,bitmap都变化,把bitmap弄成全局变量应该就行吧?
ZGDZKJ22
2020-09-15
打赏
举报
回复
上图是原函数
ZGDZKJ22
2020-09-15
打赏
举报
回复
public void drawDIB(Canvas canvas) { Bitmap bitmap = Bitmap.createBitmap(mDIBPixels, mDIBWidth, mDIBHeight, Bitmap.Config.ARGB_8888); Rect srcR, dstR; srcR = new Rect(0, 0, 0, 0); dstR = new Rect(0, 0, 0, 0); dstR = getDibShowRect(); srcR.right = mDIBWidth; srcR.left = mDIBWidth - dstR.width(); if (srcR.left < 0) srcR.left = 0; srcR.top = 0; srcR.bottom = mDIBHeight; MyApplication app; app = (MyApplication) (getContext().getApplicationContext()); int scanL; scanL = app.mRadarDevice.getScanLength(); if (scanL < mDIBHeight) srcR.bottom = scanL; canvas.drawBitmap(bitmap, srcR, dstR, null); bitmap.recycle(); boolean mBitMap = bitmap.isRecycled(); if (!mBitMap) { bitmap.recycle(); } else { bitmap = null; } // DebugUtil.i(TAG, // "srcR:="+srcR.left+";"+srcR.right+";"+srcR.top+";"+srcR.bottom); // DebugUtil.i(TAG,"dstR:="+dstR.left+";"+dstR.right+";"+dstR.top+";"+dstR.bottom); }
android
bitmap
主要包括计算缩放比例、创建Matrix对象以及使用`
Bitmap
.
create
Bitmap
`方法创建新的
Bitmap
。 #### 六、
Bitmap
的采样加载 ```java
Bitmap
Factory
.Options option = new
Bitmap
Factory
.Options(); option....
Android应用源码之图片倒影效果源码.zip
这通常通过
Bitmap
Factory
.
decode
Resource() 或
Bitmap
Factory
.
decode
Stream
() 方法完成,传入相应的资源ID或输入流。例如: ```java
Bitmap
original
Bitmap
=
Bitmap
Factory
.
decode
Resource(getResources(), R....
安卓Android源码——(
Bitmap
位图渲染与操作).rar
Bitmap
可以通过多种方式创建,如`
Bitmap
Factory
.
decode
Resource()`从资源文件中解码,`
Bitmap
Factory
.
decode
File()`从文件系统中读取,或者`
Bitmap
Factory
.
decode
Stream
()`从输入流中解码。这些方法会根据指定的...
Android程序研发源码Android 图片倒影效果源码.rar
1. **读取原始
Bitmap
**:首先,需要加载要添加倒影效果的原始图片,这通常通过`
Bitmap
Factory
.
decode
Resource()`或`
Bitmap
Factory
.
decode
Stream
()`完成。 2. **创建倒影
Bitmap
**:使用`
Bitmap
.
create
Bitmap
()`创建...
初中级Android开发社招面试之
Bitmap
- 使用
Bitmap
.
create
Bitmap
()动态创建
Bitmap
时,要考虑内存预算,避免内存溢出。 - 使用完
Bitmap
后,调用recycle()方法回收内存,但需要注意,一旦回收,不能再使用。 - 使用软引用(SoftReference)或弱引用...
Android
80,471
社区成员
91,384
社区内容
发帖
与我相关
我的任务
Android
移动平台 Android
复制链接
扫一扫
分享
社区描述
移动平台 Android
android
android-studio
androidx
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章