Tag Archives: pixel

1,372 views

Pixel to density independent pixel to pixel conversion

Physical pixel (px) Density independent pixel (dp) Dots per inch (dpi) .. physical pixels per inch px = dp * (dpi / 160) public static int dpToPx(int dp) { return (int) (dp * Resources.getSystem().getDisplayMetrics().density); }   public static int pxToDp(int … Continue reading

Posted in Android Examples Code | Tagged | Comments Off on Pixel to density independent pixel to pixel conversion
7,807 views

Get the color of a specific pixel Java Android example

ImputStream is = this.getResources().openRawResource(R.drawable.colors); Bitmap mBitmap2 = BitmapFactory.decodeStream(is);   int w = mBitmap2.getWidth(); int h = mBitmap2.getHeight(); // int x , y have to be smaller as w , h int _color = mBitmap2.getPixel(x, y);

Posted in Android Examples Code, Bitmap, drawing | Tagged , , , | Comments Off on Get the color of a specific pixel Java Android example