Bitmap from view with opaque/semi transparent background
-
I'm using the code below to create a filled rounded rectangle with border of a view. The problem is: 1. If Alpha is set high, the bitmap of the view is no longer visible 2. If Alpha is medium, the bitmap of the view is also dulled I want the foreground to be as the original on top of the background that is controlled by the Alpha value
Bitmap bitmap = getBitmapFromView(view); Canvas canvas = new Canvas(bitmap); Paint background = new Paint(); RectF rectF = new RectF(1, 1, bitmap.getWidth() - 2, bitmap.getHeight() - 2); // draw background background.setStyle(Paint.Style.FILL); background.setColor(BACKGROUND\_COLOUR); background.setAlpha(ALPHA); canvas.drawRoundRect(rectF, ROUNDING, ROUNDING, background); // draw border background.setStyle(Paint.Style.STROKE); background.setStrokeWidth(LINE\_THICKNESS); background.setColor(BORDER\_COLOUR); canvas.drawRoundRect(rectF, ROUNDING, ROUNDING, background); // draw foreground Paint foreground = new Paint(); canvas.drawBitmap(bitmap, 0, 0, foreground); return bitmap;
Dave
Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) -
I'm using the code below to create a filled rounded rectangle with border of a view. The problem is: 1. If Alpha is set high, the bitmap of the view is no longer visible 2. If Alpha is medium, the bitmap of the view is also dulled I want the foreground to be as the original on top of the background that is controlled by the Alpha value
Bitmap bitmap = getBitmapFromView(view); Canvas canvas = new Canvas(bitmap); Paint background = new Paint(); RectF rectF = new RectF(1, 1, bitmap.getWidth() - 2, bitmap.getHeight() - 2); // draw background background.setStyle(Paint.Style.FILL); background.setColor(BACKGROUND\_COLOUR); background.setAlpha(ALPHA); canvas.drawRoundRect(rectF, ROUNDING, ROUNDING, background); // draw border background.setStyle(Paint.Style.STROKE); background.setStrokeWidth(LINE\_THICKNESS); background.setColor(BORDER\_COLOUR); canvas.drawRoundRect(rectF, ROUNDING, ROUNDING, background); // draw foreground Paint foreground = new Paint(); canvas.drawBitmap(bitmap, 0, 0, foreground); return bitmap;
Dave
Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)I am trying to use your valuable code but it gives me some errors . 03-31 11:57:20.533: W/dalvikvm(2117): threadid=11: thread exiting with uncaught exception (group=0xa4c35648) 03-31 11:57:20.533: E/AndroidRuntime(2117): FATAL EXCEPTION: Thread-183 03-31 11:57:20.533: E/AndroidRuntime(2117): java.lang.UnsupportedOperationException 03-31 11:57:20.533: E/AndroidRuntime(2117): at java.lang.Thread.stop(Thread.java:1052) 03-31 11:57:20.533: E/AndroidRuntime(2117): at java.lang.Thread.stop(Thread.java:1042) 03-31 11:57:20.533: E/AndroidRuntime(2117): at com.yourname.main.SplashScreen$2.run(SplashScreen.java:59) What is the problem? I download & run your project dmo so there is no chance to mistake myself .
-
I am trying to use your valuable code but it gives me some errors . 03-31 11:57:20.533: W/dalvikvm(2117): threadid=11: thread exiting with uncaught exception (group=0xa4c35648) 03-31 11:57:20.533: E/AndroidRuntime(2117): FATAL EXCEPTION: Thread-183 03-31 11:57:20.533: E/AndroidRuntime(2117): java.lang.UnsupportedOperationException 03-31 11:57:20.533: E/AndroidRuntime(2117): at java.lang.Thread.stop(Thread.java:1052) 03-31 11:57:20.533: E/AndroidRuntime(2117): at java.lang.Thread.stop(Thread.java:1042) 03-31 11:57:20.533: E/AndroidRuntime(2117): at com.yourname.main.SplashScreen$2.run(SplashScreen.java:59) What is the problem? I download & run your project dmo so there is no chance to mistake myself .
No idea I'm afraid without seeing your code... You need to put a breakpoint at line 59 in SplashScreen.java and see what's going wrong
Dave
Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)