mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:52:45 +00:00 
			
		
		
		
	 751cb094ff
			
		
	
	
		751cb094ff
		
	
	
	
	
		
			
			To transparently support multi-frame images, all decoder plugins have already been updated to return their only bitmap for frame(0). This patch completes the remaining cleanup work by removing the ImageDecoder::bitmap() API and having all clients call frame() instead.
		
			
				
	
	
		
			81 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibGfx/BMPLoader.h>
 | |
| #include <LibGfx/DDSLoader.h>
 | |
| #include <LibGfx/GIFLoader.h>
 | |
| #include <LibGfx/ICOLoader.h>
 | |
| #include <LibGfx/ImageDecoder.h>
 | |
| #include <LibGfx/JPGLoader.h>
 | |
| #include <LibGfx/PBMLoader.h>
 | |
| #include <LibGfx/PGMLoader.h>
 | |
| #include <LibGfx/PNGLoader.h>
 | |
| #include <LibGfx/PPMLoader.h>
 | |
| 
 | |
| namespace Gfx {
 | |
| 
 | |
| RefPtr<ImageDecoder> ImageDecoder::try_create(ReadonlyBytes bytes)
 | |
| {
 | |
|     auto* data = bytes.data();
 | |
|     auto size = bytes.size();
 | |
| 
 | |
|     auto plugin = [](auto* data, auto size) -> OwnPtr<ImageDecoderPlugin> {
 | |
|         OwnPtr<ImageDecoderPlugin> plugin;
 | |
| 
 | |
|         plugin = make<PNGImageDecoderPlugin>(data, size);
 | |
|         if (plugin->sniff())
 | |
|             return plugin;
 | |
| 
 | |
|         plugin = make<GIFImageDecoderPlugin>(data, size);
 | |
|         if (plugin->sniff())
 | |
|             return plugin;
 | |
| 
 | |
|         plugin = make<BMPImageDecoderPlugin>(data, size);
 | |
|         if (plugin->sniff())
 | |
|             return plugin;
 | |
| 
 | |
|         plugin = make<PBMImageDecoderPlugin>(data, size);
 | |
|         if (plugin->sniff())
 | |
|             return plugin;
 | |
| 
 | |
|         plugin = make<PGMImageDecoderPlugin>(data, size);
 | |
|         if (plugin->sniff())
 | |
|             return plugin;
 | |
| 
 | |
|         plugin = make<PPMImageDecoderPlugin>(data, size);
 | |
|         if (plugin->sniff())
 | |
|             return plugin;
 | |
| 
 | |
|         plugin = make<ICOImageDecoderPlugin>(data, size);
 | |
|         if (plugin->sniff())
 | |
|             return plugin;
 | |
| 
 | |
|         plugin = make<JPGImageDecoderPlugin>(data, size);
 | |
|         if (plugin->sniff())
 | |
|             return plugin;
 | |
| 
 | |
|         plugin = make<DDSImageDecoderPlugin>(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<ImageDecoderPlugin> plugin)
 | |
|     : m_plugin(move(plugin))
 | |
| {
 | |
| }
 | |
| 
 | |
| ImageDecoder::~ImageDecoder()
 | |
| {
 | |
| }
 | |
| 
 | |
| }
 |