Android will perform some type conversion when processing a write image resource. Now I have time to sort it out:
1. drawable → bitmap
Java code
- Public static bitmap drawabletobitmap (drawable ){
- Bitmap bitmap = bitmap
- . Createbitmap (
- Drawable. getintrinsicwidth (),
- Drawable. getintrinsicheight (),
- Drawable. getopacity ()! = Pixelformat. opaque? Bitmap. config. argb_8888
- : Bitmap. config. rgb_565 );
- Canvas canvas = new canvas (Bitmap );
- // Canvas. setbitmap (Bitmap );
- Drawable. setbounds (0, 0, drawable. getintrinsicwidth (), drawable. getintrinsicheight ());
- Drawable. Draw (canvas );
- Return bitmap;
- }
- 2. Obtain bitmap from a resource
- Java code
- Resources res = getresources ();
- Bitmap BMP = bitmapfactory. decoderesource (Res, R. drawable. PIC );
- 3. Bitmap → byte []
- Java code
- Private byte [] bitmap2bytes (Bitmap BM ){
- Bytearrayoutputstream baos = new bytearrayoutputstream ();
- BM. Compress (bitmap. compressformat. PNG, 100, baos );
- Return baos. tobytearray ();
- }
- 4. byte [] → bitmap
- Java code
- Private bitmap bytes2bimap (byte [] B ){
- If (B. length! = 0 ){
- Return bitmapfactory. decodebytearray (B, 0, B. Length );
- }
- Else {
- Return NULL;
- }
- }
Some activity styles:
• Android: theme = "@ Android: style/theme. Dialog" shows an activity as a dialog box
• Android: theme = "@ Android: style/theme. notitlebar" does not display the application title bar
• Android: theme = "@ Android: style/theme. notitlebar. fullscreen": The application title bar is not displayed and displayed in full screen.
• Android: theme = "@ Android: style/theme. Light" the background is white
• Android: theme = "@ Android: style/theme. Light. notitlebar" the white background does not have a title bar.
• Android: theme = "@ Android: style/theme. Light. notitlebar. fullscreen" white background, no title bar, full screen
• Android: theme = "@ Android: style/theme. Black" background black
• Android: theme = "@ Android: style/theme. Black. notitlebar" the black background does not have a title bar.
• Android: theme = "@ Android: style/theme. Black. notitlebar. fullscreen" black background, no title bar, full screen
• Android: theme = "@ Android: style/theme. Wallpaper" uses the system desktop as the background of the application
• Android: theme = "@ Android: style/theme. wallpaper. notitlebar" uses the system desktop as the background of the application without a title bar.
• Android: theme = "@ Android: style/theme. wallpaper. notitlebar. fullscreen" uses the system desktop as the background of the application, with no title bar and full screen
• Android: theme = "@ Android: style/translucent" Translucent Effect
• Android: theme = "@ Android: style/theme. translucent. notitlebar" translucent and no title bar
• Android: theme = "@ Android: style/theme. translucent. notitlebar. fullscreen" Translucent effect, no title bar, full screen
• Android: theme = "@ Android: style/theme. Panel"
• Android: theme = "@ Android: style/theme. Light. Panel"
From: http://makeyouown.iteye.com/blog/1273319