[swift-users] How do I turn an array into a bitmap image?
Nevin Brackett-Rozinsky
nevin.brackettrozinsky at gmail.com
Wed Mar 15 11:56:32 CDT 2017
For one of my programs, I need to take an array of Floats and use the
underlying bytes as the RGBA data for a bitmap image. In particular, the 32
bits of each Float must be treated as the color of the corresponding pixel.
So the result is an image of height 1 and width the length of the array.
In particular, I need to be able to save the image as a PNG file, then
later load it from disk and reconstruct each Float from its pixel, with no
loss or change to the value of the Floats. So, how do I go from [Float] to
a bitmap image suitable for saving to disk, without altering the underlying
bytes?
(Yes, I understand this is an odd sort of thing to do. I can explain the
purpose if anyone is interested.)
Thanks,
Nevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170315/e49031cc/attachment.html>
More information about the swift-users
mailing list