iOS saves bmp with “Flip row order” format. Can this option be removed in Swift?

六眼飞鱼酱① 提交于 2020-01-06 06:45:51

问题


UPDATE: When taking an iOS-created .bmp and using "Save As..." in Photoshop with "Flip row order" unchecked, this .bmp will then work on the Adafruit PyPortal (thanks John Park for this lead). I've searched in iOS and don't find anything that looks like a "Flip row order" command for bmp image data. Is anyone familiar with how to get iOS data into this "unflipped row order" format? Thanks! John

-- The 8-bit bmps I'm creating in Swift on an iOS device aren't showing on an Adafruit PyPortal, but when I run the same bmp (or any other 320 x 240 png or jpeg) through an online bmp converter, it then shows on the PyPortal. Both the before and after bmps are readable by Photoshop & Mac Preview and both show as 8-bit "Windows BMP Image" format files. PyPortal requires "a 320 x 240 pixel RGB 16-bit raster graphic in .bmp format" but going down to 8 bit doesn't make a difference. The bmp file that works (the one run through the online converter) shows on my Mac as a 231 KB file, while the bmp that doesn't (the one as created in Swift) shows as 230 KB.

I've put both files in a Google Drive at: https://drive.google.com/open?id=1DQYes-cJXKm3ue8Z9cACDLEN5bxnnkJc

The one that works (created in Swift, but then run through the bmp converter) is named: adafruit-log-as-iOS-created-bmp-then-converted-online-shows-in-PyPortal.bmp

And the one that doesn't work (just created in Swift) is named: adafruit-log-as-iOS-created.bmp (On Google Drive they both show as 225 KB files

The technique I use to create the bmp in Swift is the one employed when I answered the question at: How to convert UIImage to BMP and save as Data (not JPG or PNG)

and uses the helpful extension from @vasily-bodnarchuk via: Convert UIImage to NSData and convert back to UIImage in Swift?

When I run the files through a byte-by-byte comparison engine like https://www.diffnow.com show there are differences between the files.

I'm hopeful someone can quickly size up the difference between the formats of these two bmps and offer insight in getting the Swift code to create something that the Adafruit PyPortal can use. Thanks to anyone with the stamina to follow this far. Cheers!

来源:https://stackoverflow.com/questions/57241391/ios-saves-bmp-with-flip-row-order-format-can-this-option-be-removed-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!