Android利用BitMap获得图片像素数据的方法
作者:fengyee_zju 时间:2023-06-19 15:50:47
本文实例讲述了Android利用BitMap获得图片像素数据的方法。分享给大家供大家参考,具体如下:
网上看到的参考是:
int[] pixels = new int[bit.getWidth()*bit.getHeight()];//保存所有的像素的数组,图片宽×高
bit.getPixels(pixels,0,bit.getWidth(),0,0,bit.getWidth(),bit.getHeight());
for(int i = 0; i < pixels.length; i++){
int clr = pixels[i];
int red = (clr & 0x00ff0000) >> 16; //取高两位
int green = (clr & 0x0000ff00) >> 8; //取中两位
int blue = clr & 0x000000ff; //取低两位
System.out.println("r="+red+",g="+green+",b="+blue);
}
其中getPixels中第三个参数要为图片的宽度
实际上有个更好的函数是
Bitmap bm = "得到bitmap图片"
bm.getPixels(x,y);
直接获得x,y坐标处的像素点数据。
希望本文所述对大家Android程序设计有所帮助。
标签:Android,BitMap,图片
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android 接收微信、QQ其他应用打开第三方分享功能
2022-06-12 18:11:58
![](https://img.aspxhome.com/file/2023/7/113287_0s.jpg)
Java贪吃蛇游戏完善版
2023-04-12 03:07:53
![](https://img.aspxhome.com/file/2023/6/128846_0s.jpg)
Java的JDBC中Statement与CallableStatement对象实例
2022-11-14 17:22:08
C# WinForm程序完全退出的问题解决
2023-07-02 07:29:34
Android开发实例之多点触控程序
2023-06-19 00:25:09
![](https://img.aspxhome.com/file/2023/2/137762_0s.jpg)
分享安装Android Studio3.6的经验教训
2021-12-24 07:39:29
![](https://img.aspxhome.com/file/2023/4/137424_0s.png)
Java深入理解代码块的使用细节
2023-06-13 04:45:59
![](https://img.aspxhome.com/file/2023/0/76610_0s.png)
JavaWeb中JavaMail创建邮件和发送邮件
2022-01-29 02:54:09
![](https://img.aspxhome.com/file/2023/8/110918_0s.png)
详解Java 自动装箱与拆箱的实现原理
2022-08-16 11:35:51
Android 8.0系统中通知栏的适配详解
2022-03-03 07:38:20
![](https://img.aspxhome.com/file/2023/4/139314_0s.png)
Android开发中软键盘的显示和隐藏
2023-10-03 06:00:20
![](https://img.aspxhome.com/file/2023/3/138003_0s.jpg)
搭建MyBatis-Plus框架并进行数据库增删改查功能
2023-11-09 04:33:43
![](https://img.aspxhome.com/file/2023/7/59167_0s.png)
spring boot如何指定启动端口
2021-06-27 19:52:14
![](https://img.aspxhome.com/file/2023/0/65370_0s.png)
Java信号量Semaphore原理及代码实例
2021-10-02 21:55:08
Spring Boot @Conditional注解用法示例介绍
2023-04-18 22:51:51
新手初学Java数组
2023-12-01 11:18:40
![](https://img.aspxhome.com/file/2023/3/101753_0s.jpg)
c# 开发语音识别程序
2022-03-23 04:55:57
![](https://img.aspxhome.com/file/2023/3/91313_0s.png)
java实现List中对象排序的方法
2023-11-08 21:36:29
c# AcceptEx与完成端口(IOCP)结合的示例
2023-07-29 01:46:24
Java窗口精细全方位讲解
2023-03-05 15:35:15
![](https://img.aspxhome.com/file/2023/5/121435_0s.jpg)