| 
									
										
										
										
											2020-04-21 23:49:51 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-04-21 23:49:51 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibGfx/Forward.h>
 | 
					
						
							|  |  |  | #include <LibJS/Heap/Handle.h>
 | 
					
						
							|  |  |  | #include <LibWeb/Bindings/Wrappable.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-28 18:20:36 +02:00
										 |  |  | namespace Web::HTML { | 
					
						
							| 
									
										
										
										
											2020-04-21 23:49:51 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class ImageData | 
					
						
							|  |  |  |     : public RefCounted<ImageData> | 
					
						
							|  |  |  |     , public Bindings::Wrappable { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     using WrapperType = Bindings::ImageDataWrapper; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static RefPtr<ImageData> create_with_size(JS::GlobalObject&, int width, int height); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ~ImageData(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-21 15:57:10 +02:00
										 |  |  |     unsigned width() const; | 
					
						
							|  |  |  |     unsigned height() const; | 
					
						
							| 
									
										
										
										
											2020-04-21 23:49:51 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Gfx::Bitmap& bitmap() { return m_bitmap; } | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     Gfx::Bitmap const& bitmap() const { return m_bitmap; } | 
					
						
							| 
									
										
										
										
											2020-04-21 23:49:51 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     JS::Uint8ClampedArray* data(); | 
					
						
							|  |  |  |     const JS::Uint8ClampedArray* data() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     explicit ImageData(NonnullRefPtr<Gfx::Bitmap>, JS::Handle<JS::Uint8ClampedArray>); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     NonnullRefPtr<Gfx::Bitmap> m_bitmap; | 
					
						
							|  |  |  |     JS::Handle<JS::Uint8ClampedArray> m_data; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |