Ultralight  1.0.0
A fast, lightweight, HTML UI engine for native apps.
Bitmap.h
Go to the documentation of this file.
1 #pragma once
15 #include <Ultralight/Defines.h>
16 #include <Ultralight/RefPtr.h>
17 #include <Ultralight/Geometry.h>
18 
19 namespace ultralight {
20 
21 #pragma pack(push, 1)
22 
26 enum UExport BitmapFormat {
29 
31  kBitmapFormat_RGBA8
32 };
33 
37 #define GetBytesPerPixel(x) (x == kBitmapFormat_A8? 1 : 4)
38 
42 class UExport Bitmap : public RefCounted {
43  public:
47  static Ref<Bitmap> Create();
48 
61  static Ref<Bitmap> Create(uint32_t width, uint32_t height, BitmapFormat format);
62 
86  static Ref<Bitmap> Create(uint32_t width, uint32_t height, BitmapFormat format,
87  uint32_t row_bytes, const void* pixels, size_t size, bool should_copy = true);
88 
92  static Ref<Bitmap> Create(const Bitmap& bitmap);
93 
97  virtual uint32_t width() const = 0;
98 
102  virtual uint32_t height() const = 0;
103 
107  virtual IntRect bounds() const = 0;
108 
112  virtual BitmapFormat format() const = 0;
113 
117  virtual uint32_t bpp() const = 0;
118 
122  virtual uint32_t row_bytes() const = 0;
123 
127  virtual size_t size() const = 0;
128 
133  virtual bool owns_pixels() const = 0;
134 
140  virtual void* LockPixels() = 0;
141 
145  virtual void UnlockPixels() = 0;
146 
152  virtual const void* LockPixels() const = 0;
153 
157  virtual void UnlockPixels() const = 0;
158 
164  virtual void* raw_pixels() = 0;
165 
169  virtual bool IsEmpty() const = 0;
170 
174  virtual void Erase() = 0;
175 
181  virtual void Set(Ref<Bitmap> bitmap) = 0;
182 
203  virtual bool DrawBitmap(IntRect src_rect, IntRect dest_rect,
204  Ref<Bitmap> src, bool pad_repeat) = 0;
205 
213  virtual bool WritePNG(const char* path) = 0;
214 
215 protected:
216  Bitmap();
217  virtual ~Bitmap();
218  Bitmap(const Bitmap&);
219  void operator=(const Bitmap&);
220 };
221 
222 #pragma pack(pop)
223 
224 } // namespace ultralight
The header for various geometry definitions and helpers.
A non-nullable smart pointer.
Definition: RefPtr.h:64
Bitmap container with basic blitting and conversion routines.
Definition: Bitmap.h:42
This is a set of common JavaScriptCore Helper functions to simplify sample code.
Definition: App.h:19
The header for all ref-counting utilities.
Interface for all ref-counted objects that will be managed using the Ref<> and RefPtr<> smart pointer...
Definition: RefPtr.h:53
kBitmapFormat_A8
Alpha-channel only, 8-bits per channel (8-bits in total per pixel)
Definition: Bitmap.h:28
Integer Rectangle Helper.
Definition: Geometry.h:536