Create CImage from Byte array

后端 未结 4 762
面向向阳花
面向向阳花 2020-12-21 12:02

I need to create a CImage from a byte array (actually, its an array of unsigned char, but I can cast to whatever form is necessary). The byte array is in the fo

4条回答
  •  有刺的猬
    2020-12-21 12:32

    Use memcpy to copy the data, then SetDIBits or SetDIBitsToDevice depending on what you need to do. Take care though, the scanlines of the raw image data are aligned on 4-byte boundaries (IIRC, it's been a few years since I did this) so the data you get back from GetDIBits will never be exactly the same as the original data (well it might, depending on the image size).

    So most likely you will need to memcpy scanline by scanline.

提交回复
热议问题