I am trying to save a very large image (around 1M x 1M size) into a single file.
Because the most of pixels in the image are white, so after encoding it to a zipped format like png or jpeg, it only takes a little spaces(like 10MB).
However, during the encoding, it will takes memory as much as the number of its pixels(1M x 1M x 4Bytes = 1GB), which is too much to handle. I am an iOS developer so I need use least memory as I could.
I am trying to split the large image to grids, encoding each tiles and merge them together. But the problem is, when I try to merge tiles into a single picture, it will decode itself again and then encode. Memory peak still exists.
so how can I merge two pictures without decoding and encoding?
I also tried some format like HEIF, which says it supports grid image, but I didn’t work well on that 🙁