Skip to main content

Posts

Showing posts from April 20, 2017

Pick Color from Image

Picking the Color from the Image in Android in HEX and RGB In android we use HEX for color code and in ios we use RGB so here we are gonna work on both. You can download the full source code from github PickColorFromImageAndroid . ImageView picked_imageView ; picked_imageView = (ImageView) findViewById(R.id. imageView2 ) ; picked_imageView .setOnTouchListener( this ) ; picked_imageView .setImageBitmap(bitmapImage) ; OnTouch of picked_imageView we can get the color code in onTouch method. When we touch the imageView we will get the color code from the image and here you can format it in HEX and RGB. @Override public boolean onTouch (View v , MotionEvent event) { Matrix inverse = new Matrix() ; picked_imageView .getImageMatrix().invert(inverse) ; float [] touchPoint = new float [] {event.getX() , event.getY()} ; inverse.mapPoints(touchPoint) ; int x = Integer. valueOf (( int )touchPoint[ 0 ]) ; int y = Integer. valueOf (( int