I have an image file (.jpg) which contains image like Face. From my application i want to capture that particular Face part and copy that part into a new bitmap file. I have a rectangular co-ordinates of that Face part, so how do i capture only Face part from the image file and copy that into a bitmap file??
Could any body help me to get rid of this problem....
Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height) will do the creation. For save, read this: Save bitmap to location
You could use
bitmap1.getPixel(x,y)
on the source image and using
bitmap2.setPixel(x,y,color)
on the destination image.
There is also a respective
bitmap1.getPixels( pixelArray, offset, stride, x, y, width, height)
which is undoubtedly faster.
Related
In my application. There's section select block of apartment. In there a A and B block. So i want to choose A or B block from single image. Image is
There is what way to do this?
I guess you could use getLocationOnScreen()and hardcode the values you want. If user clicks on certain part of the image it prompts one response, if they click somewhere else it prompts another response. More info here Android: How do I get the x y coordinates within an image / ImageView?
Use BitMap concept. Convert full image as bitmap the crop the bitmap based on (x,y) positions.
Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.myimage);
Bitmap cropbitmap=Bitmap.createBitmap(bitmap, xpoint,ypoint,width, height);
//default android method createBitmap(Bitmap source, int x, int y, int width, int height)
other simple way use library like this from github
android-crop
uCrop
Android-Image-Cropper
I'm just a beginner with android. I want to divide a bitmap image into chunks and then display the image in the same way but divided. is this possible?
Instead of trying to break the image up into chunks you should just use:
canvas.drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint)
This will draw parts of the image. So to give the effect of breaking it up you are really just using the src and dest rectangles to draw specified parts of the images. Where src is the rectangle in local image coordinates of the part you want to draw and dest is the rectangle used to position it on the screen.
You can use the following method to get an area of an source bitmap:
Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height)
I need to develop an android application which do some image processing on the image input. For this, I need to get the pixel values of the bitmap in either an array or an object. Can anyone help me to grab the pixel-level details of a bitmap image.
Thanks !
to get pixel array of bitmap
bitmap.getPixels(pixels, offset, stride, x, y, width, height);
every pixel/value in array will be represented as Color with ARGB value.
if you want to get the value of on pixel do this
int pixel = bitmap.getPixel(x, y);
How do i get a part of a bitmap (which is in a imageview) saved as shown in the picture. All i need to do is to crop a particular image using (x,y) coordinates. all that i have is x,y coordinates and nothing else to select the cropped area. Between, user doesnt select the crop area. So its enough if its static. yellow part is an imageview(not the whole activity)
just create a new Bitmap and use the original one as the source.
Insert as x and y coordinates 0 and your custom width and hight.
public static Bitmap createBitmap (Bitmap source, int x, int y, int width, int height) .
This post describes how to get a Bitmap from a view, in your case the imageview you want to crop.
Converting a view to Bitmap without displaying it in Android?
I want to know how to cut an image in jigsaw form in android at run time. What i actually want is user can enter any image and then made puzzle of it.
Any API or method for doing this in android ?
Thanks in Advance.
You can use this method in Bitmap to cut it into a new BitMap of specified width and height pixels
starting from specified pixel location of x and y
public static Bitmap createBitmap (Bitmap source,
int x,
int y, int width, int height)
Assuming your puzzle piece is square, you can use createBitmap() function.
Returns an immutable bitmap from the specified subset of the source
bitmap. The new bitmap may be the same object as source, or a copy may
have been made. It is initialized with the same density as the
original bitmap.