检查,如果一个像素是透明的或不 - 的Andr​​oid [英] Check if a pixel is transparent or NOT - Android

查看:167
本文介绍了检查,如果一个像素是透明的或不 - 的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PNG图片(随着弯道透明像素),我试图提取这些透明像素的颜色code,我用一个XXXX的网站,让我的手,选择一个像素,它返回它的颜色code;

选择透明像素我得到后:
RGB code:R:34 G:62乙:74

这不是逻辑

我用BitmapDrawable与我的PNG图像//不是一个正确的方法,我认为

位图位图=((BitmapDrawable)image.getDrawable())getBitmap();

有没有什么办法来检查,如果一个像素是透明的或不?

感谢您


解决方案

 位图位图=((BitmapDrawable)image.getDrawable())getBitmap()。
INT透明度=((bitmap.getPixel(X,Y)及0xff000000)GT;> 24);

透明度之间会 0 完全透明)和 255 完全不透明)。

I have a PNG picture (With transparent pixels in the corners), i am trying to extract the color code of these transparent pixels , i used a xxxx website that gives me the hand to select a pixel and it returns its color code ;

after selecting the transparent pixels i get : RGB code: R: 34 G: 62 B: 74

that's not logic

i used BitmapDrawable with my PNG Image // Not a right method i think

Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();

Is there any way to check if a pixel is transparent or not ?

Thank you

解决方案

Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();
int transparency = ((bitmap.getPixel(x,y) & 0xff000000) >> 24);

transparency will be between 0 (completely transparent) and 255 (completely opaque).

这篇关于检查,如果一个像素是透明的或不 - 的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆