| 105 | } |
| 106 | |
| 107 | ByteArray MemoryAssetSource::read(String const& path) { |
| 108 | auto p = m_files.ptr(path); |
| 109 | if (!p) |
| 110 | throw AssetSourceException::format("Requested file '{}' does not exist in memory", path); |
| 111 | else if (auto bytes = p->ptr<ByteArray>()) |
| 112 | return *bytes; |
| 113 | else { |
| 114 | Image const* image = p->get<ImagePtr>().get(); |
| 115 | return ByteArray((char const*)image->data(), image->width() * image->height() * image->bytesPerPixel()); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | ImageConstPtr MemoryAssetSource::image(String const& path) { |
| 120 | auto p = m_files.ptr(path); |