Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Bitmap get Bitmap from resource Android example


AD MOB

PNG, GIF, BMP, JPG

// //www.apache.org/licenses/LICENSE-2.0

// 1.)  Bitmap from stream
            InputStream is = context.getResources().openRawResource(R.drawable.my_image);
            mBitmap = BitmapFactory.decodeStream(is);
           

// 2.) 
            Bitmap ball = BitmapFactory.decodeResource(getResources(), R.drawable.ball);
            int dstWidth =120;
            int dstHeight = 120;
            mBitmap = Bitmap.createScaledBitmap(ball, dstWidth, dstHeight, true);

// 3.)
Bitmap  mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);


        Bitmap  mBitmap;
        Canvas  mCanvas;
        Paint   mBitmapPaint;
            
            mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);
            mCanvas = new Canvas(mBitmap);
            mBitmapPaint = new Paint(Paint.DITHER_FLAG);

// 4.)
          Bitmap  mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);
          Canvas  mCanvas.setBitmap(mBitmap);
            mCanvas.drawColor(0xFFFFFFFF);


397LW NO topic_id




AD

Další témata ....(Topics)


116

AlertDialog - MessageBox - Alert - Toast - Android sample | alertdialog-like-messagebox-android-sample


AlertDialog like MessageBox by WinApi:
If error: Unable to add window -- token null is not for an application
try change get Context.

// you can put this text into some function body or case in switch statement
                new AlertDialog.Builder(this)
                    .setMessage("Hello boys!!!")
                    .setPositiveButton("OK", null)
                    .show();



Context context = getApplicationContext();
	AlertDialog.Builder builder = new AlertDialog.Builder(context);
	builder.setTitle("Select font size");
	final CharSequence[] chsSize= { "Small", "Medium", "Large"};
	builder.setSingleChoiceItems(chsSize, 0 /*sel.item*/, 
	new DialogInterface.OnClickListener() {
 	    public void onClick(DialogInterface dialog, int item) {
	    		 Toast.makeText(context, "Hello from dialog!!!", Toast.LENGTH_SHORT).show();
	        dialog.dismiss();
	    }
	});
	AlertDialog alert = builder.create();
	alert.show();
    
124

Resource int R.string.app_name to String Android example | resource-int-r-string-app_name-to-string-android-example


R.string.app_name to String example.
MyActivity.java

Resources res = getResources();
String sText = res.getString(R.string.app_name);


res/values/string.xml


<resources>
    <string name="app_name">My app name</string>
</resources>

201

Samsung Galaxy Y (S5360) | samsung-galaxy-y-s5360






























Brand Samsung
Model (codename) Galaxy Y (S5360)
Cena, včetně DPH 2400 / 06.2012
Display size (v palcích) 3
Display-resolution 240x320
Dotek-typ kapacitní
CPU typ BCM21553
CPU MHz 832
CPU core
L2 cache ?
RAM 256
ROM 512
GPU VideoCore IV
NenaMark2 Benchmark 12
GPU-GLBenchmark
Baterie mAh 1200
Foto MPx 2
Autofocus ne
Video
Official Android ICS Android OS v 2.3
CyanogenMod support
Dotek-prstů-max
Display-ppi 133
Display-retina 41%
Network čîtyřpásmový GSM 850/900/1800/1900 MHz , HSDPA 2100 MHz
Connectivity Bluetooth v2.0 plus EDR plus support A2DP, USB host
Pozn. CPU ARMv6, GPU 20MT/s OpenGL ES 2.0


samsung galaxy y smartphone
182

Motorola Droid RAZR | motorola-droid-razr


Motorola Droid RAZR cena od 12 000 KCZ Kč (únor.2012)
Spokojenost uživatelů nadprůměrná.
Motorola Droid RAZR je chytrý telefon s operačním systémem Android.
Motorola Droid RAZR je (22.února2012) 9. nejpoužívanějším chytrým telefonem u programu Sky Map viz tabulka.



Motorola Droid RAZR photo pic image
Motorola Droid RAZR
Zdroj obrázku: wikipedia
8

Display screen size resolution density dimension Android | display-screen-dimension


Get display, screen resolution - dimension Android phone development example source code.

 Display display = getWindowManager().getDefaultDisplay();
int nWidth = display.getWidth();
int nHeight = display.getHeight();

          DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            //get density per inch for example: 120 , 160 , 240
            mXDpi = metrics.xdpi; // 160 The exact physical pixels per inch of the screen in the X dimension. 
            mYDpi = metrics.ydpi;

// density
int nDensity = metrics.densityDpi; // 160 screen density expressed as dots-per-inch

          float  mMetersToPixelsX = mXDpi / 0.0254f; // 1 inch == 0.0254 metre
          float  mMetersToPixelsY = mYDpi / 0.0254f;
          
// Resolution
// The total number of physical pixels on a screen.
int wPix = metrics.widthPixels; // 320 The absolute width of the display in pixels.
int hPix = metrics.heightPixels; // 480 The absolute height of the display in pixels.
int nWidthDisplay = (wPix < hPix)? wPix : hPix;

float nWidthScreenInInch = wPix / mXDpi; //320 / 160 == 2.0 in inch.
float nHeightScreenInInch = hPix / mYDpi; //480 / 160 == 3.0 in inch.

// for example:
// density 120 per inch
//width 320 pix / 120 dpi == width 2.66 inch
//height 480 pix / 120 dpi == height 4.0 inch 

// density 240 per inch
//width 320 pix / 240 dpi == width 1.33 inch
//height 480 pix / 240 dpi == height 2.0 inch 




Example:
HTC Desire HD
11 (4.3) Diagonal cm (in)
480×800 Resolution
85 (217) ppcm (PPI - Pixels per inch)

480 / 217 = 2.21 inch
800 / 217 = 3.69 inch
Math.sqrt( 2.21*2.21 + 3.69 * 3.69) = 4.3 inch - diagonal

//en.wikipedia.org/wiki/Pixels_per_inch
//en.wikipedia.org/wiki/Dots_per_inch

Typical screen widths:

320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).


Emulator skins in the Android SDK
//developer.android.com/guide/practices/screens_support.html









































Low density (120), ldpi

Medium density (160), mdpi

High density (240), hdpi

Extra high density (320), xhdpi

Small screen
QVGA (240x320) 480x640

Normal screen
WQVGA400 (240x400)

WQVGA432 (240x432)
HVGA (320x480) WVGA800 (480x800)

WVGA854 (480x854)

600x1024
640x960

Large screen
WVGA800** (480x800)

WVGA854** (480x854)
WVGA800* (480x800)

WVGA854* (480x854)

600x1024

Extra Large screen
1024x600 WXGA (1280x800)

1024x768
1280x768
1536x1152
1920x1152

1920x1200
2048x1536
2560x1536

2560x1600
* To emulate this configuration, specify a
custom density of 160 when creating an AVD that uses a WVGA800 or WVGA854 skin.

** To emulate this configuration, specify a custom density of 120 when creating an AVD that
uses a WVGA800 or WVGA854 skin.

† This skin is available with the Android 3.0 platform


Editace: 2013-12-09 13:12:32
Počet článků v kategorii: 397
Url:bitmap-get-bitmap-from-resource-android-example

AD
11 Share
Share
Tweet