1

I'm using Swift in iOS and used the code based on this SO post to save a UIImage as a bmp Convert UIImage to NSData and convert back to UIImage in Swift?

The data I create and save is recognized as a bmp in Photoshop and Preview but can’t be read by the Adafruit PyPortal. The only diff I can find is that when I resave the bmp in Photoshop as a bmp again, it shows as “Flip row order” selected in the BMP options screen that appears right after the main save screen.

BMP Options Dialog

If I uncheck this option and save the file, the PyPortal can then read this resaved file. This post above was great for getting the UIImage into .bmp format, but I need to get this additional file change done programmatically on iOS, so opening in a third-party product, or working with shell commands won't work as a solution. I’ve not been able to find anything in Apple’s docs that looks like it corresponds to Flip row order and there isn’t much online about this option within Photoshop so it’s unclear even what this does.

For the curious I have samples of the bmp my app creates as well as options resaved or run through an online converter (both these options work on PyPortal).

https://drive.google.com/drive/folders/1DQYes-cJXKm3ue8Z9cACDLEN5bxnnkJc

Any suggestions are appreciated. Thx!

Gallaugher
  • 1,593
  • 16
  • 27

1 Answers1

1

The “Flip row order” option tells the bmp reader software to read the first row of pixels first and the last row of pixels last. This is not the “normal” way most bmp reader interpret a bmp format image. Most implementations read from the last row first and then work its way up to the first row of pixels.

Your options are either, rewrite the bitmap creating software so that it matches the abilities of the bmp reader software or change the bmp reader software so it can read the bmp file.

I’m fully aware this doesn’t solve the issue but can help understanding what it going wrong and guide you in the right direction.

claes
  • 76
  • 5