简体   繁体   中英

Android imageview to bitmap

I have an app in which i use a function to change a color into another color.The function works only on bitmaps, but it works great.

I want to implement the same function inside of a gridview. Therefore i converted the imageview to a bitmap, applied the function, and reconverted the bitmap to an imageview but nothing happens.

//here i get the picture to the imageview
imageView = new ImageView(mContext);
imageView.setScaleType(ImageView.ScaleType.CENTER);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setAdjustViewBounds(true);
imageView.setMaxWidth(20);
imageView.setMaxHeight(100);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(10,10,10,10);       

ImageView imgv=new ImageView(mContext);
imgv.buildDrawingCache();
Bitmap bmap = imgv.getDrawingCache();
Bitmap bmap2 = imgv.getDrawingCache();

bmap=Square3.repleceIntervalColor(bmap2, 240, 255, 240, 255, 240, 255,Project.getColor());

imageView.setImageBitmap(bmap);

The problem was solved.The code is corect only, that it's in the wrong place.The entire code should have been after imageView.setImageResource(mThumbIds4[position]); .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM