The code is simple, as follows:
/** * Iplimage converted to bitmap * @param iplimage * @return * * PublicBitmapIplimagetobitmap(Iplimage iplimage) {Bitmap Bitmap =NULL; Bitmap = Bitmap.createbitmap (Iplimage.width (), Iplimage.height (), Bitmap.Config.ARGB_8888); Bitmap.copypixelsfrombuffer (Iplimage.getbytebuffer ());returnBitmap }/** * Bitmap converted to Iplimage * @param bitmap * @return * * PublicIplimageBitmaptoiplimage(Bitmap Bitmap) {Iplimage iplimage; Iplimage = Iplimage.create (Bitmap.getwidth (), Bitmap.getheight (), ipl_depth_8u,4); Bitmap.copypixelstobuffer (Iplimage.getbytebuffer ());returnIplimage; }
The main use of the bitmap two functions:
public void Copypixelsfrombuffer (Buffer src)
Copying a point from buffer to bitmap and overwriting the original point in the bitmap from the initial position, the point of buffer in the copy process will not change in any way, regardless of how the original bitmap format will eventually be written in 32-bit mode
public void Copypixelstobuffer (Buffer DST)
Copy the points in the bitmap to the specified buffer, if the DST space is not large enough to accommodate all the points in bitmap, or DST is not bytebuffer, Shortbuffer, Intbuffer one of the three, the function throws an exception
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Java CV and Android" JAVACV enables Iplimage and bitmap to be converted to each other