"Java CV and Android" JAVACV enables Iplimage and bitmap to be converted to each other

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.