/* * Copyright (c) 2018-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include #include #include #include #include namespace Gfx { RefPtr ImageDecoder::try_create(ReadonlyBytes bytes) { auto* data = bytes.data(); auto size = bytes.size(); auto plugin = [](auto* data, auto size) -> OwnPtr { OwnPtr plugin; plugin = make(data, size); if (plugin->sniff()) return plugin; plugin = make(data, size); if (plugin->sniff()) return plugin; plugin = make(data, size); if (plugin->sniff()) return plugin; plugin = make(data, size); if (plugin->sniff()) return plugin; plugin = make(data, size); if (plugin->sniff()) return plugin; plugin = make(data, size); if (plugin->sniff()) return plugin; plugin = make(data, size); if (plugin->sniff()) return plugin; plugin = make(data, size); if (plugin->sniff()) return plugin; plugin = make(data, size); if (plugin->sniff()) return plugin; return {}; }(data, size); if (!plugin) return {}; return adopt_ref_if_nonnull(new (nothrow) ImageDecoder(plugin.release_nonnull())); } ImageDecoder::ImageDecoder(NonnullOwnPtr plugin) : m_plugin(move(plugin)) { } ImageDecoder::~ImageDecoder() { } }