mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:12:43 +00:00 
			
		
		
		
	 8324ffefe7
			
		
	
	
		8324ffefe7
		
	
	
	
	
		
			
			This adds very simple support for storing BMP files with BITMAPV3INFOHEADER and BITMAPV4HEADER. This in turn allows us to store alpha channels which is nice for our .pp file format. For the moment no data regarding colorspace is saved, only the bare minimum to make a valid file. Some small restructuring of the code is made to hopefully make it easier to implement more DIB-headers and support for colorspace/gamma correction in the future.
		
			
				
	
	
		
			40 lines
		
	
	
	
		
			745 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
	
		
			745 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, Ben Jilks <benjyjilks@gmail.com>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/ByteBuffer.h>
 | |
| 
 | |
| namespace Gfx {
 | |
| 
 | |
| class Bitmap;
 | |
| 
 | |
| class BMPWriter {
 | |
| public:
 | |
|     BMPWriter() = default;
 | |
| 
 | |
|     enum class Compression : u32 {
 | |
|         BI_RGB = 0,
 | |
|         BI_BITFIELDS = 3,
 | |
|     };
 | |
| 
 | |
|     enum class DibHeader : u32 {
 | |
|         Info = 40,
 | |
|         V3 = 56,
 | |
|         V4 = 108,
 | |
|     };
 | |
| 
 | |
|     ByteBuffer dump(const RefPtr<Bitmap>, DibHeader dib_header = DibHeader::V4);
 | |
| 
 | |
|     inline void set_compression(Compression compression) { m_compression = compression; }
 | |
| 
 | |
| private:
 | |
|     Compression m_compression { Compression::BI_BITFIELDS };
 | |
|     int m_bytes_per_pixel { 4 };
 | |
|     bool m_include_alpha_channel { true };
 | |
| };
 | |
| 
 | |
| }
 |