Wednesday, February 5, 2014

How to get Imageview of R in the picture dynamically created (Imageview)


            
I dynamically generated images (a large figure was cut a little)
Resources (such as R.drawable.XXXXXX) How to get the generated image

imgg.setImageResource (resId); / / resId-> what I want to enter the R.drawable
.imgg.getDrawable () setColorFilter (new ColorMatrixColorFilter (BT_SELECTED));.
imgg.setImageDrawable (imgg.getDrawable ());

imgg is a imageview.
Reply:
R This is the time to compile the project will have created, your approach is generated at run time seems impossible.
Touches can generate Bitmap, then img.setImageBitmap
Reply:
cited a floor birdsaction reply:
R this is the time to compile the project has generated good, your method is generated at runtime seems impossible .
Touches can generate Bitmap, then img.setImageBitmap


How raw the imageview's Bitmap?
With Bitmap mBitmap = BitmapFactory.decodeResource (getResources (), R.xxx); do?
R. ah still have needs
Reply:
You say the picture is split inside the Android division?
Well split should be able to generate a lot of small Bitmap object.

Create a picture
Bitmap bitmap = Bitmap.createBitmap (100,100, Config.ARGB_8888);
Canvas canvas = new Canvas (bitmap);
canvas.drawColor (Color.argb (0x33, 0xff, 0, 0));
Drawable drawable = new BitmapDrawable (getResources (), bitmap);
Reply:
reference to the third floor birdsaction reply:
you say inside picture segmentation is divided in Android?
Well split should be able to generate a lot of small Bitmap object.

Create a picture
Bitmap bitmap = Bitmap.createBitmap (100,100, Config.ARGB_8888);
Canvas canvas = new Canvas (bitmap);
canvas.drawColor (Color.argb (0x33, 0xff, 0, 0));
Drawable drawable = new BitmapDrawable (getResources (), bitmap);


Is not. I'll tell you what.
I have a full figure
Then they cut the bitmap to nine after
They upset the order and then credited to the ImageView mImages [] [] a two-dimensional array
After the random composition of a map.
Then start the puzzle.
I want to achieve, I can click on the little puzzle labeled him (such as his lighter, darker or the color)
So I used
imgg.setImageResource (resId); / / resId-> what I want to enter the R.drawable
.imgg.getDrawable () setColorFilter (new ColorMatrixColorFilter (BT_SELECTED));.
imgg.setImageDrawable (imgg.getDrawable ());
His color.
So you have to get a new generation of R. imageview
Reply:
Seeking master ah! ! ! ! ! ! ! ! !
Reply:
Upstairs has said very clearly, R resource file is generated when compiling the project, only direct help your exploded into a bitmap, then himself draw, like how to change color on how color :)
Reply:
 / ** 
* Obtained from view in the picture
* @ Param view the component
* @ Return Bitmap
* /
public Bitmap getViewBitmap (View view) {
view.destroyDrawingCache ();
view.measure (View.MeasureSpec.makeMeasureSpec (0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec (0, View.MeasureSpec.UNSPECIFIED));
view.layout (0, 0, view.getMeasuredWidth (), view.getMeasuredHeight ());
view.setDrawingCacheEnabled (true);
return view.getDrawingCache (true);
}

No comments:

Post a Comment