mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 22:02:44 +00:00 
			
		
		
		
	LibGfx/ILBM: Add support for uncompressed files
This commit is contained in:
		
							parent
							
								
									80a78c4deb
								
							
						
					
					
						commit
						b8f8b22aa5
					
				
					 3 changed files with 21 additions and 8 deletions
				
			
		|  | @ -95,7 +95,20 @@ TEST_CASE(test_ilbm) | ||||||
|     EXPECT(Gfx::ILBMImageDecoderPlugin::sniff(file->bytes())); |     EXPECT(Gfx::ILBMImageDecoderPlugin::sniff(file->bytes())); | ||||||
|     auto plugin_decoder = MUST(Gfx::ILBMImageDecoderPlugin::create(file->bytes())); |     auto plugin_decoder = MUST(Gfx::ILBMImageDecoderPlugin::create(file->bytes())); | ||||||
| 
 | 
 | ||||||
|     expect_single_frame_of_size(*plugin_decoder, { 320, 200 }); |     auto frame = expect_single_frame_of_size(*plugin_decoder, { 320, 200 }); | ||||||
|  | 
 | ||||||
|  |     EXPECT_EQ(frame.image->get_pixel(8, 0), Gfx::Color(0xee, 0xbb, 0, 255)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | TEST_CASE(test_ilbm_uncompressed) | ||||||
|  | { | ||||||
|  |     auto file = MUST(Core::MappedFile::map(TEST_INPUT("ilbm/gradient-uncompressed.iff"sv))); | ||||||
|  |     EXPECT(Gfx::ILBMImageDecoderPlugin::sniff(file->bytes())); | ||||||
|  |     auto plugin_decoder = MUST(Gfx::ILBMImageDecoderPlugin::create(file->bytes())); | ||||||
|  | 
 | ||||||
|  |     auto frame = expect_single_frame_of_size(*plugin_decoder, { 320, 200 }); | ||||||
|  | 
 | ||||||
|  |     EXPECT_EQ(frame.image->get_pixel(8, 0), Gfx::Color(0xee, 0xbb, 0, 255)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TEST_CASE(test_jpeg_sof0_one_scan) | TEST_CASE(test_jpeg_sof0_one_scan) | ||||||
|  |  | ||||||
							
								
								
									
										
											BIN
										
									
								
								Tests/LibGfx/test-inputs/ilbm/gradient-uncompressed.iff
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/LibGfx/test-inputs/ilbm/gradient-uncompressed.iff
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -193,17 +193,17 @@ static ErrorOr<void> decode_body_chunk(Chunk body_chunk, ILBMLoadingContext& con | ||||||
| { | { | ||||||
|     dbgln_if(ILBM_DEBUG, "decode_body_chunk {}", body_chunk.data.size()); |     dbgln_if(ILBM_DEBUG, "decode_body_chunk {}", body_chunk.data.size()); | ||||||
| 
 | 
 | ||||||
|     if (context.bm_header.compression == CompressionType::ByteRun) { |     ByteBuffer pixel_data; | ||||||
|         // these are the uncompressed interleaved bitmap planes
 |  | ||||||
|         auto plane_data = TRY(uncompress_byte_run(body_chunk.data, context)); |  | ||||||
|         // that we need to convert to chunky pixel data
 |  | ||||||
|         auto pixel_data = TRY(planar_to_chunky(plane_data, context)); |  | ||||||
| 
 | 
 | ||||||
|         context.bitmap = TRY(chunky_to_bitmap(context, pixel_data)); |     if (context.bm_header.compression == CompressionType::ByteRun) { | ||||||
|  |         auto plane_data = TRY(uncompress_byte_run(body_chunk.data, context)); | ||||||
|  |         pixel_data = TRY(planar_to_chunky(plane_data, context)); | ||||||
|     } else { |     } else { | ||||||
|         return Error::from_string_literal("Uncompress body not supported yet"); |         pixel_data = TRY(planar_to_chunky(body_chunk.data, context)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     context.bitmap = TRY(chunky_to_bitmap(context, pixel_data)); | ||||||
|  | 
 | ||||||
|     return {}; |     return {}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nicolas Ramz
						Nicolas Ramz