Friday, February 14, 2014

Crop circle picture of the code how can I add ah? ? ? ? There code ~!





All the above three methods, such as charts, pie cutting the code below:
public Bitmap toRoundBitmap (Bitmap bitmap) {
int width = bitmap.getWidth ();
int height = bitmap.getHeight ();
float roundPx;
float left, top, right, bottom, dst_left, dst_top, dst_right, dst_bottom;
if (width <= height) {
roundPx = width / 2;
top = 0;
bottom = width;
left = 0;
right = width;
height = width;
dst_left = 0;
dst_top = 0;
dst_right = width;
dst_bottom = width;} else {
roundPx = height / 2;
float clip = (width - height) / 2;
left = clip;
right = width - clip;
top = 0;
bottom = height;
width = height;
dst_left = 0;
dst_top = 0;
dst_right = height;
dst_bottom = height;}
Bitmap output = Bitmap.createBitmap (width,
height, Config.ARGB_8888);
Canvas canvas = new Canvas (output);
final int color = 0xff424242;
final Paint paint = new Paint ();
final Rect src = new Rect ((int) left, (int) top, (int) right, (int) bottom);
final Rect dst = new Rect ((int) dst_left, (int) dst_top, (int) dst_right, (int) dst_bottom); final RectF rectF = new RectF (dst);
paint.setAntiAlias ​​(true);
canvas.drawARGB (0, 0, 0, 0);
paint.setColor (color);
canvas.drawRoundRect (rectF, roundPx, roundPx, paint);
paint.setXfermode (new PorterDuffXfermode (Mode.SRC_IN)); canvas.drawBitmap (bitmap, src, dst, paint);
return output;
}

How much more should be no need to write code, the key I 搞不太清楚 "logical" relationship,,
What about the great God to break ~! !<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:

This function in doDisplay
 if (bitmap! = null) {
bitmap = toRoundBitmap (bitmap); / / add this one
imageView.setImageBitmap (bitmap);
}

Reply:
toRoundBitmap () where to write this code it?
Reply:
reference to the second floor qiyungang1230 reply:
toRoundBitmap () then write this code where?

DoDisplay this function with the same class as a function of applied inside the line.
Reply:
Write this sentence errors ah. . android there span?

Reply:
Well, no need to add span ~ ~ direct bitmap = toRoundBitmap (bitmap) on the line, hey ・ or their foundation is not solid, ah, thank you! ! !
Reply:
But now there is a small problem, that is just the beginning when loading or rectangular image refresh to display the drop-down round, which is why?
Reply:
reference to the 6th floor qiyungang1230 reply:
but now there is a small problem that started when loading or rectangular pictures, pull down to refresh appear as round, which is why?


I just started loading it directly call this function to display the circle
Reply:
And ah, I get up again once the method is carried out in accordance with the above, why can not round display it? ?

No comments:

Post a Comment