|

- UID
- 12014
- 帖子
- 27
- 精华
- 0
- 积分
- 143
- e望
- 0 点
- e币
- 51 元
- e脉
- 0 条
- 在线时间
- 65 小时
|
我想对现有的一个Bitmap进行操作,比如改变像素!该如何做,期望高人之指点!贴段我需要操作的代码:- public boolean imgdrawimage(Bitmap imgDst,int xDst,int yDst,int widthDst,int heightDst,
- Bitmap imgsrc,int xSrc,int ySrc,int rop,byte r,byte g,byte b,boolean is){
-
- if(imgDst==null||imgsrc==null) return false;
- //rop RO_OR 0,|或运算,RO_XOR 1, ^异或,RO_COPY 2,RO_NOT 3,
-
-
- int[] DstPixels =new int[widthDst*heightDst]; //目标位图区域像素数组
-
- imgDst.getPixels(DstPixels, 0, widthDst, xDst, yDst, widthDst, heightDst);
-
- Log.v("565", ""+imgDst.getPixel(0, 0));
-
- int[] SrcPixels = new int[widthDst*heightDst] ; //源位图 区域像素数组
-
- imgsrc.getPixels(SrcPixels, 0, widthDst, xSrc, ySrc, widthDst, heightDst);
-
- // 将 源图片按照一定方式 绘制到目标图片上
- switch(rop){
- case 0: // |
- for(int i=0;i<SrcPixels.length;i++){
- SrcPixels[i]=SrcPixels[i]|DstPixels[i];
- }
- break;
- case 1: //^
- for(int i=0;i<SrcPixels.length;i++){
- SrcPixels[i]=SrcPixels[i]^DstPixels[i];
- }
- break;
- case 2: // copy
- for(int i=0;i<SrcPixels.length;i++){
- SrcPixels[i]=SrcPixels[i];
- }
- break;
- case 3: // not
- for(int i=0;i<SrcPixels.length;i++){
- SrcPixels[i]=~SrcPixels[i];
- }
- break;
- }
- // 将 改变后的像素点 重置到目标图片上
-
- if(is){ // 如果is 为true ,那么颜色值存在 将源图片数组和此颜色相同的变为完全透明
-
- int rgb = getRGB(r,g,b);
-
- for(int i=0;i<SrcPixels.length;i++){
-
- if(SrcPixels[i]==rgb){
-
- SrcPixels[i] =DstPixels[i];
-
- }
- }
- }
-
-
- // bmap = Bitmap.createBitmap(widthDst, heightDst, Config.ARGB_8888);
-
-
-
- imgDst.setPixels(SrcPixels, 0, widthDst, 0, 0, widthDst, heightDst);
-
- return true;
- }
-
复制代码 |
|