How do I save an UIImage as BMP?

前端 未结 4 743
遥遥无期
遥遥无期 2020-12-20 07:40

Can I save (write to file) UIImage object as bitmap file (.bmp extension) in iPhone’s document directory?

Thanks in advance.

4条回答
  •  再見小時候
    2020-12-20 08:16

    I don’t think BMP is supported on iPhone. Maybe somebody wrote a category for UIImage that does saving into BMP, but I don’t know about any. I guess You’ll have to get the bitmap data from the UIImage and write them yourself, BMP is quite a simple file format. All you have to do is write out the header and then the uncompressed data. The header is a structure called BITMAPINFOHEADER, see MSDN. Getting the bitmap data of an UIImage is described in Apple’s Technical Q&A1509.

提交回复
热议问题