How to Write bitmap data to the surface

Source: Internet
Author: User

After the buffer of the surface is ready, you can write bitmap data to the buffer,
The buffer of the surface is the same as the ordinary image data. It is also a scanned line data organized in a certain format.

The following example assumes that the source and target formats are both 32-bit and the size does not exceed the standard.

Uint8_t * sbits;
Sbits = (uint8_t *) Bitmap-> getpixels ();

Int sstride;
Sstride = Bitmap-> rowbytes ();
Int sbpp; // bytes per pixel
Sbpp = Bitmap-> bytesperpixel ();
Uint8_t * Sline;
Sline = sbits + (INT) Src-> ftop * sstride + (INT) Src-> fleft *
Sbpp;

Uint8_t * dBits;
DBits = static_cast (mbufferheap. Heap-> base ());
// Memcpy (dBits, sbits, 800*480*4 );

// Need check format

Int dstride;
Dstride = 800*4; // color: abgr
Int dbpp; // bytes per pixel
Dbpp = 4;
Uint8_t * dline;
Dline = dBits + (INT) DST. ftop * dstride + (INT) DST. fleft *
Dbpp;

Int width;
Int height;

Width = (INT) (DST. fright-dst. fleft );
Height = (INT) (DST. fbottom-dst. ftop );

While (height --)
{
Memcpy (dline, Sline, width * sbpp );
Dline + = dstride;
Sline + = sstride;
}

 

Http://blog.sina.com.cn/s/blog_53d1e55b0100ne4v.html

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.