2 ms·
I'm surprised too; in the Windows world, two decades ago, "skins" were popular and those essentially turned every single UI element into a bitmap. On the hardwa
by userbinator 5y ago
I'm surprised too; in the Windows world, two decades ago, "skins" were popular and those essentially turned every single UI element into a bitmap. On the hardware of that time, their impact on performance was pretty minimal.
Of course, "every UI element is a bitmap" is not a good idea anyway, for other reasons, but seems to have someone become the norm for web and mobile.
- rp1 5y agoBitmaps take memory, but are quite efficient from a runtime perspective because they aren’t encoded.
- Retric 5y agoBitmaps take both bandwidth and space, either can be an issue.
- giantrobot 5y ago> Bitmaps take memory, but are quite efficient from a runtime perspective because they aren’t encoded. Memory and bandwidth. To decode/display an image it's got to be loaded from storage. In the case of a Retina display iPad that's 2048x1536px. With a 24-bit color depth that's a 9MB bitmap to load from disk (SSD or whatever). I just did a test with ImageMagick. The same 2048x1536 image encoded to an uncompressed Windows bitmap is 9MB while the same image as a PNG (PNG24, zlib level 9, with adaptive scanline filtering) is only 4MB. That's less than half the data to load off disk. Unless CPU power is at an absolute premium you're probably better off with an image with lossless compression rather than completely uncompressed.
- rp1 5y agoTrue, bandwidth is a concern. It might be possible to copy memory directly from disk to the GPU, which may be more efficient.
- giantrobot 5y agoAssuming the on-disk version of a graphic is compatible with your particular GPU. Even within the same manufacturer two generations of GPUs might not use the same image format. A generalized on-disk representation is safer and likely more forwards compatible.
- seoaeu 5y ago> Unless CPU power is at an absolute premium you're probably better off with an image with lossless compression rather than completely uncompressed. Really depends on the exact situation. If your image decompression algorithm runs at 100 MB/s, but your disk bandwidth is 250 MB/s and you have plenty of space...
- mirashii 5y agoBitmaps are special in that they don’t require a decompression step, so of course they don’t have the overhead of a decompression step.
- Lammy 5y agoThe alternative isn't a different raster image format — it's the native drawing commands of the underlying graphics system, like QuickDraw on classic Macs or GDI on classic Windows. They work like a plotter: moving a cursor to a position on the pixel grid and giving it drawing commands. You can see the residue of those old graphics systems in the various "metafile" image formats like PICT/WMF/EMF: https://en.wikipedia.org/wiki/PICT https://en.wikipedia.org/wiki/PICT https://en.wikipedia.org/wiki/Windows_Metafile https://en.wikipedia.org/wiki/Windows_Metafile
- Talanes 5y ago> The alternative isn't a different raster image format Except that we're in a conversation about the relative resource consumption of bitmaps and png, not a conversation about what the best way to draw UI elements is.
- charcircuit 5y ago>They work like a plotter: moving a cursor to a position on the pixel grid and giving it drawing commands. This isn't how GPUs work meaning it will be slow.