/** * Draw a fillet figure * * @param bitmap * @param roundpx * @return/public static bitmap Getroundedcornerbitmap (Bi TMap bitmap, float roundpx) {Bitmap output = Bitmap.createbitmap (Bitmap.getwidth (), Bitmap.getheight (), Config.argb
_8888);
Canvas Canvas = new Canvas (output);
final int color = 0xff424242;
Final Paint Paint = new Paint ();
Final Rect Rect = new Rect (0, 0, bitmap.getwidth (), Bitmap.getheight ());
Final RECTF RECTF = new RECTF (rect);
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, rect, rect, paint);
return output; /** * Create a reflection effect * * @return/public boolean createreflectedimages () {//The distance between the reflection and the original image final int reflection
Gap = 4;
int index = 0; for (Gallerywith3ddata imageid:mimageids) {//returns the Bitmap object after decoding the original image Bitmap Originalimage = bitmapfactory.decodEResource (Mcontext.getresources (), Imageid.getinteger ());
int width = originalimage.getwidth ();
int height = originalimage.getheight ();
Create a Matrix object matrices = the new Matrix ();
Specifies the matrix (x-axis invariant, y-axis opposite) Matrix.prescale (1,-1); Apply the matrix to the original image, return a width unchanged, height of the original 1/2 reflection bitmap Bitmap reflectionimage = Bitmap.createbitmap (originalimage, 0, HEIGHT/2, W
Idth, HEIGHT/2, Matrix, false); Create a bitmap Bitmap bitmapwithreflection = bitmap.createbitmap (width, height + height/2), Config with a width unchanged, height as the original image + reflection height.
argb_8888);
Initializes the bitmap created above to the canvas Canvas Canvas = new Canvas (bitmapwithreflection);
Canvas.drawbitmap (Getroundedcornerbitmap (Originalimage), 0, 0, NULL);
int len = IMAGEID.GETSTR (). Length ();
Double lenweght = len * 50 * 0.9;
int ban = WIDTH/2;
int ban1 = (int) (LENWEGHT/2);
int hua = ban-ban1;
if (Imageid.getflagrecommend ()) {canvas.rotate (30);
Canvas.drawtext (Mstrrecommend, hua-20, Createpaint (color.red)); Canvas.rotate (-30);
} Paint deafaultpaint = new Paint ();
Deafaultpaint.setantialias (FALSE);
Canvas.drawbitmap (Getroundedcornerbitmap (Reflectionimage), 0, height + reflectiongap, null);
Paint Paint = new Paint ();
Paint.setantialias (FALSE); /** * Parameter one: for the gradient at first point coordinates x position, parameter two: the Y axis position, parameters three and four: resolution of the corresponding gradient end, the last parameter is tiled, * this is set to mirror gradient is based on the shader class, so we use Paint Setshader method to set this Gradient/lineargradient shader = new LinearGradient (0, Originalimage.getheight (), 0, Bitmapwithreflection.gethe
ight () + Reflectiongap, 0x70ffffff, 0X00FFFFFF, Tilemode.mirror);
Set Shadow Paint.setshader (shader);
Paint.setxfermode (New Porterduffxfermode (Android.graphics.PorterDuff.Mode.DST_IN)); Constructs a rectangular shadow gradient effect with a defined brush canvas.drawrect (0, height, width, bitmapwithreflection.getheight ()
+ reflectiongap, paint);
Canvas.drawtext (Imageid.getstr (), Hua, 430, Createpaint (Color.White)); Create a ImageView to display the bitmapwithreflection Ima that has been painted wellGeview ImageView = new ImageView (mcontext);
Imageview.setimagebitmap (bitmapwithreflection);
Set the ImageView size, which is the final picture size imageview.setlayoutparams (new Gallerywith3d.layoutparams (150, 250));
Imageview.setscaletype (Scaletype.matrix);
mimages[index++] = ImageView;
return true; }