docs
Loading...
Searching...
No Matches
Bitmap.h
Go to the documentation of this file.
1///
2/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3/// A license is required for commercial use. https://ultralig.ht
4///
5#pragma once
7#include <Ultralight/RefPtr.h>
9#include <Ultralight/Buffer.h>
10
11namespace ultralight {
12
13///
14/// The various Bitmap formats.
15///
16enum class BitmapFormat : uint8_t {
17 ///
18 /// Alpha channel only, 8-bits per pixel.
19 ///
20 /// Encoding: 8-bits per channel, unsigned normalized.
21 ///
22 /// Color-space: Linear (no gamma), alpha-coverage only.
23 ///
25
26 ///
27 /// Blue Green Red Alpha channels, 32-bits per pixel.
28 ///
29 /// Encoding: 8-bits per channel, unsigned normalized.
30 ///
31 /// Color-space: sRGB gamma with premultiplied linear alpha channel.
32 ///
34
35 ///
36 /// Red Green channels, 16-bits per pixel.
37 ///
38 /// Encoding: 8-bits per channel, unsigned normalized.
39 ///
40 /// Color-space: Linear (no gamma).
41 ///
42 /// Not PNG-encodable.
43 ///
45
46 ///
47 /// BC1 block-compressed color (4x4 blocks, 8 bytes/block). Optional 1-bit alpha.
48 ///
49 /// Color-space: sRGB gamma with optional alpha.
50 ///
52
53 ///
54 /// BC2 block-compressed color (4x4 blocks, 16 bytes/block). Explicit 4-bit alpha.
55 ///
56 /// Color-space: sRGB gamma with premultiplied alpha.
57 ///
59
60 ///
61 /// BC3 block-compressed color (4x4 blocks, 16 bytes/block). Interpolated alpha.
62 ///
63 /// Color-space: sRGB gamma with premultiplied alpha.
64 ///
66
67 ///
68 /// BC7 block-compressed color (4x4 blocks, 16 bytes/block). High-quality RGB(A).
69 ///
70 /// Color-space: sRGB gamma with premultiplied alpha.
71 ///
73
74 ///
75 /// Four half-precision float channels (16 bits per channel, 64 bits per pixel).
76 ///
77 /// This is a raw data format: GPUDriver should create these as sampleable
78 /// textures without filtering or mipmaps and upload rows exactly as stored.
79 ///
81
82 ///
83 /// Four unsigned integer channels (16 bits per channel, 64 bits per pixel).
84 ///
85 /// This is a raw data format: GPUDriver should create these as sampleable
86 /// textures without filtering or mipmaps and upload rows exactly as stored.
87 ///
89
90 ///
91 /// Four float channels (32 bits per channel, 128 bits per pixel).
92 ///
93 /// This is a raw data format: GPUDriver should create these as sampleable
94 /// textures without filtering or mipmaps and upload rows exactly as stored.
95 ///
97};
98
99///
100/// Macro to get the bytes per pixel from a BitmapFormat.
101///
102/// @note This is only meaningful for non-block-compressed formats. Block-compressed (BCn) formats
103/// have no per-pixel size-- use GetBitmapFormatInfo() and row_bytes() / size() for storage
104/// math instead.
105///
106#define GetBytesPerPixel(x) ((x) == BitmapFormat::A8_UNORM ? 1 \
107 : (x) == BitmapFormat::RG8_UNORM ? 2 \
108 : (x) == BitmapFormat::RGBA16F ? 8 \
109 : (x) == BitmapFormat::RGBA16UI ? 8 \
110 : (x) == BitmapFormat::RGBA32F ? 16 \
111 : 4)
112
113///
114/// Block geometry for a BitmapFormat.
115///
116/// Uncompressed formats have a 1x1 block whose block_bytes equals the bytes-per-pixel.
117/// Block-compressed (BCn) formats have a 4x4 block. A bitmap's row pitch and surface size are
118/// derived from the block geometry:
119///
120/// ```
121/// row_pitch = ceil(width / block_width) * block_bytes
122/// surface_size = row_pitch * ceil(height / block_height)
123/// ```
124///
125/// For a 1x1 block this reduces to `width * block_bytes` and `row_pitch * height`.
126///
128 ///
129 /// Width of one block, in pixels (1 for uncompressed, 4 for BCn).
130 ///
131 uint32_t block_width;
132
133 ///
134 /// Height of one block, in pixels (1 for uncompressed, 4 for BCn).
135 ///
136 uint32_t block_height;
137
138 ///
139 /// Size of one block, in bytes (equals bytes-per-pixel when the block is 1x1).
140 ///
141 uint32_t block_bytes;
142};
143
144///
145/// Get the block geometry for a given BitmapFormat.
146///
147/// @param format The pixel format to query.
148///
149/// @return Returns the block width, block height, and block size in bytes for the format.
150///
152
153///
154/// Whether or not a given BitmapFormat is block-compressed (a BCn format).
155///
156/// @param format The pixel format to query.
157///
159
160///
161/// Forward declaration for the LockedPixels class.
162///
163template<typename T>
164class LockedPixels;
165
166///
167/// Function signature for a user-defined destruction callback to be optionally called when the
168/// Bitmap is destroyed.
169///
170/// @param user_data Pointer to user-defined user-data (this will be the same value as what was
171/// passed to Bitmap::Create, if any)
172///
173/// @param data Pointer to raw Bitmap pixel data.
174///
175typedef void (*DestroyBitmapCallback)(void* user_data, void* data);
176
177///
178/// A container for pixel data.
179///
180/// The bitmap class is used to store pixel data in a variety of formats. It intelligently manages
181/// the lifetime of the pixel buffer and serializes access to it while the Bitmap owns the pixels.
182///
183/// ## Thread Safety
184///
185/// LockPixels() and UnlockPixels() take the Bitmap's internal lock only when the Bitmap owns its
186/// pixel buffer, ie. one created by a Create() overload that allocates, or one that copied the
187/// pixels you passed in. A Bitmap that wraps memory you still own-- created with
188/// `should_copy = false`, or with a destruction callback-- does no locking at all, so you must
189/// serialize access to that buffer yourself.
190///
191/// ## Accessing Pixel Data
192///
193/// You can access the underlying pixel data by using the LockPixelsSafe() method. An example
194/// follows:
195///
196/// ```
197/// auto bitmap = Bitmap::Create(100, 100, BitmapFormat::BGRA8_UNORM_SRGB);
198/// auto pixels = bitmap->LockPixelsSafe();
199/// if (pixels && pixels.data()) {
200/// // Zero out the pixel buffer by setting every byte to 0.
201/// memset(pixels.data(), 0, pixels.size());
202/// }
203///
204/// // 'pixels' is automatically unlocked when it goes out of scope.
205/// ```
207 public:
208 ///
209 /// Maximum supported width or height, in pixels.
210 ///
211 /// Create() returns a null ref-pointer if either dimension exceeds this limit.
212 ///
213 /// The largest possible allocation, MaxDimension by MaxDimension at 4 bytes per pixel, is
214 /// about 1 GB.
215 ///
216 static constexpr uint32_t MaxDimension = 16384;
217
218 ///
219 /// Create an empty Bitmap. No pixels will be allocated.
220 ///
221 /// @return Returns a ref-pointer to a new Bitmap instance.
222 ///
224
225 ///
226 /// Create a Bitmap with a certain configuration. Pixels will be allocated but not initialized.
227 ///
228 /// @param width The width in pixels.
229 ///
230 /// @param height The height in pixels.
231 ///
232 /// @param format The pixel format to use.
233 ///
234 /// @return Returns a ref-pointer to a new Bitmap instance.
235 ///
237
238 ///
239 /// Create an aligned Bitmap with a certain configuration. Pixels will be allocated but not
240 /// initialized. Row bytes will be padded to reach the specified alignment.
241 ///
242 /// @param width The width in pixels.
243 ///
244 /// @param height The height in pixels.
245 ///
246 /// @param format The pixel format to use.
247 ///
248 /// @param alignment The alignment (in bytes) to use. Row bytes will be padded to reach a
249 /// multiple of this value and the underlying storage will be allocated with
250 /// this alignment.
251 ///
252 /// @return Returns a ref-pointer to a new Bitmap instance.
253 ///
255 uint32_t alignment);
256
257 ///
258 /// Create a Bitmap with existing pixel data, a copy will be made unless should_copy is false.
259 ///
260 /// @param width The width in pixels.
261 ///
262 /// @param height The height in pixels.
263 ///
264 /// @param format The pixel format to use.
265 ///
266 /// @param row_bytes The number of bytes between each row of pixels. This should be at least
267 /// `width * bytes_per_pixel`, or for a block-compressed format, the width
268 /// in 4x4 blocks times the block size (see GetBitmapFormatInfo()).
269 ///
270 /// @param pixels Pointer to raw pixel buffer.
271 ///
272 /// @param size Size of the raw pixel buffer.
273 ///
274 /// @param should_copy Whether or not a copy should be made of the pixels. If this is false
275 /// the returned Bitmap will use the raw pixels passed in as its own, but
276 /// you are still responsible for destroying your buffer afterwards.
277 ///
278 /// @return Returns a ref-pointer to a new Bitmap instance.
279 ///
281 uint32_t row_bytes, const void* pixels, size_t size,
282 bool should_copy = true);
283
284 ///
285 /// Create a Bitmap that wraps existing pixel data, a user-defined destruction callback will be
286 /// called when the Bitmap wants to destroy the data.
287 ///
288 /// @param width The width in pixels.
289 ///
290 /// @param height The height in pixels.
291 ///
292 /// @param format The pixel format to use.
293 ///
294 /// @param row_bytes The number of bytes between each row of pixels. This should be at least
295 /// `width * bytes_per_pixel`, or for a block-compressed format, the width
296 /// in 4x4 blocks times the block size (see GetBitmapFormatInfo()).
297 ///
298 /// @param pixels Pointer to raw pixel buffer.
299 ///
300 /// @param size Size of the raw pixel buffer.
301 ///
302 /// @param user_data Optional user data that will be passed to destruction_callback when the
303 /// Bitmap wants to destroy the pixel data. (Pass nullptr to ignore)
304 ///
305 /// @param destruction_callback Callback that will be called upon destruction.
306 ///
307 /// @return Returns a ref-pointer to a new Bitmap instance.
308 ///
310 uint32_t row_bytes, const void* pixels, size_t size,
311 void* user_data, DestroyBitmapCallback destruction_callback);
312
313 ///
314 /// Create a bitmap from a deep copy of another Bitmap.
315 ///
316 /// @param bitmap The bitmap to copy from.
317 ///
318 /// @return Returns a ref-pointer to a new Bitmap instance.
319 ///
320 static RefPtr<Bitmap> Create(const Bitmap& bitmap);
321
322 ///
323 /// Get the width in pixels.
324 ///
325 virtual uint32_t width() const = 0;
326
327 ///
328 /// Get the height in pixels.
329 ///
330 virtual uint32_t height() const = 0;
331
332 ///
333 /// Get the bounds as an IntRect.
334 ///
335 virtual IntRect bounds() const = 0;
336
337 ///
338 /// Get the pixel format.
339 ///
340 virtual BitmapFormat format() const = 0;
341
342 ///
343 /// Get the number of bytes per pixel.
344 ///
345 virtual uint32_t bpp() const = 0;
346
347 ///
348 /// Get the number of bytes between each row of pixels.
349 ///
350 /// @note This value is usually calculated as width * bytes_per_pixel (bpp) but it may be larger
351 /// due to alignment rules in the allocator.
352 ///
353 virtual uint32_t row_bytes() const = 0;
354
355 ///
356 /// Get the size in bytes of the pixel buffer.
357 ///
358 /// @note Size is calculated as row_bytes() * height().
359 ///
360 virtual size_t size() const = 0;
361
362 ///
363 /// Whether or not this Bitmap owns the pixel buffer and will destroy it at the end of its
364 /// lifetime.
365 ///
366 virtual bool owns_pixels() const = 0;
367
368 ///
369 /// Lock the pixel buffer for reading/writing (safe version, automatically unlocks).
370 ///
371 /// @return Returns a managed container that can be used to access the pixels
372 /// (LockedPixels::data()). This container will automatically unlock the pixels when it
373 /// goes out of scope.
374 ///
376
377 ///
378 /// Lock the pixel buffer for reading/writing.
379 ///
380 /// @return Returns a pointer to the pixel buffer.
381 ///
382 virtual void* LockPixels() = 0;
383
384 ///
385 /// Unlock the pixel buffer.
386 ///
387 virtual void UnlockPixels() = 0;
388
389 ///
390 /// Lock the pixel buffer for reading/writing. (const)
391 ///
392 /// @return Returns a const pointer to the pixel buffer.
393 ///
394 virtual const void* LockPixels() const = 0;
395
396 ///
397 /// Unlock the pixel buffer. (const)
398 ///
399 virtual void UnlockPixels() const = 0;
400
401 ///
402 /// Get the raw pixel buffer.
403 ///
404 /// @note You should only call this if pixels are already locked.
405 ///
406 virtual void* raw_pixels() = 0;
407
408 ///
409 /// Whether or not this Bitmap is empty (no pixels allocated).
410 ///
411 virtual bool IsEmpty() const = 0;
412
413 ///
414 /// Erase the Bitmap (set all pixels to 0).
415 ///
416 virtual void Erase() = 0;
417
418 ///
419 /// Assign another bitmap to this one.
420 ///
421 /// @param bitmap The bitmap to copy from.
422 ///
423 /// @note The source pixels are deep-copied in every case but one: a source that wraps memory
424 /// you still own (created with `should_copy = false` and no destruction callback) is
425 /// aliased instead, so that buffer must outlive this Bitmap.
426 ///
427 virtual void Set(RefPtr<Bitmap> bitmap) = 0;
428
429 ///
430 /// Draw another bitmap to this bitmap.
431 ///
432 /// @note Formats do not need to match. Bitmap formats will be converted to one another
433 /// automatically.
434 ///
435 /// @param src_rect The source rectangle, relative to src bitmap.
436 ///
437 /// @param dest_rect The destination rectangle, relative to this bitmap.
438 ///
439 /// @param src The source bitmap.
440 ///
441 /// @param pad_repeat Whether or not we should pad the drawn bitmap by one pixel of repeated
442 /// edge pixels from the source bitmap.
443 ///
444 /// @return Returns whether or not the operation succeeded (this can fail if the src_rect and/or
445 /// dest_rect are invalid).
446 ///
447 virtual bool DrawBitmap(IntRect src_rect, IntRect dest_rect, RefPtr<Bitmap> src, bool pad_repeat)
448 = 0;
449
450 ///
451 /// Encode this Bitmap as a PNG image and store the encoded bytes in a Buffer.
452 ///
453 /// @param convert_to_rgba The PNG format expects RGBA format but our bitmap is stored as BGRA,
454 /// set this to true to perform the conversion automatically.
455 ///
456 /// @param convert_to_straight_alpha The PNG format expects semi-transparent values to be
457 /// stored as straight alpha instead of premultiplied alpha,
458 /// set this to true to perform the conversion automatically.
459 ///
460 /// @return Returns a buffer containing the encoded bytes, or a null ref-pointer on failure.
461 ///
462 virtual RefPtr<Buffer> EncodePNG(bool convert_to_rgba = true,
463 bool convert_to_straight_alpha = true) const = 0;
464
465 ///
466 /// Write this Bitmap out to a PNG image.
467 ///
468 /// @param path The filepath to write to (opened with fopen())
469 ///
470 /// @param convert_to_rgba The PNG format expects RGBA format but our bitmap is stored as BGRA,
471 /// set this to true to perform the conversion automatically.
472 ///
473 /// @param convert_to_straight_alpha The PNG format expects semi-transparent values to be
474 /// stored as straight alpha instead of premultiplied alpha,
475 /// set this to true to perform the conversion automatically.
476 ///
477 /// @return Returns whether or not the operation succeeded.
478 ///
479 virtual bool WritePNG(const char* path, bool convert_to_rgba = true,
480 bool convert_to_straight_alpha = true) const = 0;
481
482 ///
483 /// Make a resized copy of this bitmap by writing to a pre-allocated destination bitmap.
484 ///
485 /// @param destination The bitmap to store the result in, the width and height of the
486 /// destination will be used.
487 ///
488 /// @param high_quality Whether or not a high quality resampling will be used during the
489 /// resize. (Otherwise, just uses fast nearest-neighbor sampling)
490 ///
491 /// @return Returns whether or not the operation succeeded. This operation is only valid if both
492 /// formats are BitmapFormat::BGRA8_UNORM_SRGB and the source and destination are
493 /// non-empty.
494 ///
495 virtual bool Resample(RefPtr<Bitmap> destination, bool high_quality) = 0;
496
497 ///
498 /// Convert a BGRA bitmap to RGBA bitmap and vice-versa by swapping the red and blue channels.
499 ///
500 /// @note Only valid if the format is BitmapFormat::BGRA8_UNORM_SRGB.
501 ///
502 virtual void SwapRedBlueChannels() = 0;
503
504 ///
505 /// Convert a BGRA bitmap from premultiplied alpha (the default) to straight alpha.
506 ///
507 /// @note Only valid if the format is BitmapFormat::BGRA8_UNORM_SRGB.
508 ///
509 virtual void ConvertToStraightAlpha() = 0;
510
511 ///
512 /// Convert a BGRA bitmap from straight alpha to premultiplied alpha.
513 ///
514 /// @note Only valid if the format is BitmapFormat::BGRA8_UNORM_SRGB.
515 ///
516 virtual void ConvertToPremultipliedAlpha() = 0;
517
518 ///
519 /// Whether or not this Bitmap uses a block-compressed (BCn) format.
520 ///
521 /// @note Compressed bitmaps store 4x4 pixel blocks and don't support per-pixel operations.
522 /// Erase(), DrawBitmap(), Resample(), and the channel/alpha conversions are no-ops or
523 /// fail on a compressed Bitmap.
524 ///
525 virtual bool is_compressed() const = 0;
526
527 protected:
529 virtual ~Bitmap();
530 Bitmap(const Bitmap&);
531 void operator=(const Bitmap&);
532};
533
534///
535/// Managed container that keeps a pixel buffer locked for the duration of its lifetime.
536///
537/// You obtain an instance via Bitmap::LockPixelsSafe() or Surface::LockPixelsSafe(). The pixel
538/// buffer is automatically unlocked when this object goes out of scope. This class can be moved
539/// but not copied.
540///
541/// The template parameter `T` is the lockable type, `RefPtr<Bitmap>` or `Surface*`.
542///
543template <typename T>
545 public:
546 LockedPixels(const LockedPixels&) = delete;
548 LockedPixels(int) = delete;
549 explicit LockedPixels(T& lockable) : lockable_(lockable), data_(nullptr), size_(0) { lock(); }
550
552 if (lockable_)
553 lockable_->UnlockPixels();
554 }
555
556 ///
557 /// Access the locked pixel data.
558 ///
559 void* data() { return data_; }
560
561 ///
562 /// Access the size of the locked pixel data.
563 ///
564 size_t size() { return size_; }
565
566 explicit operator bool() const { return !!lockable_; }
567
568 LockedPixels(LockedPixels&& other) : lockable_(other.lockable_), data_(other.data_),
569 size_(other.size_) {
570 other.lockable_ = nullptr;
571 other.data_ = nullptr;
572 other.size_ = 0;
573 }
574
576 if (lockable_)
577 lockable_->UnlockPixels();
578 lockable_ = other.lockable_;
579 data_ = other.data_;
580 size_ = other.size_;
581 other.lockable_ = nullptr;
582 other.data_ = nullptr;
583 other.size_ = 0;
584 return *this;
585 }
586
587 private:
588 void lock() {
589 if (lockable_) {
590 data_ = lockable_->LockPixels();
591 size_ = lockable_->size();
592 }
593 }
594
595 T lockable_;
596 void* data_;
597 size_t size_;
598};
599
600
601} // namespace ultralight
#define UExport
Definition Exports.h:22
virtual RefPtr< Buffer > EncodePNG(bool convert_to_rgba=true, bool convert_to_straight_alpha=true) const =0
Encode this Bitmap as a PNG image and store the encoded bytes in a Buffer.
virtual bool owns_pixels() const =0
Whether or not this Bitmap owns the pixel buffer and will destroy it at the end of its lifetime.
static RefPtr< Bitmap > Create()
Create an empty Bitmap.
virtual bool DrawBitmap(IntRect src_rect, IntRect dest_rect, RefPtr< Bitmap > src, bool pad_repeat)=0
Draw another bitmap to this bitmap.
void operator=(const Bitmap &)
virtual uint32_t height() const =0
Get the height in pixels.
virtual bool IsEmpty() const =0
Whether or not this Bitmap is empty (no pixels allocated).
static RefPtr< Bitmap > Create(const Bitmap &bitmap)
Create a bitmap from a deep copy of another Bitmap.
virtual uint32_t row_bytes() const =0
Get the number of bytes between each row of pixels.
Bitmap(const Bitmap &)
virtual void Set(RefPtr< Bitmap > bitmap)=0
Assign another bitmap to this one.
static RefPtr< Bitmap > Create(uint32_t width, uint32_t height, BitmapFormat format)
Create a Bitmap with a certain configuration.
static RefPtr< Bitmap > Create(uint32_t width, uint32_t height, BitmapFormat format, uint32_t row_bytes, const void *pixels, size_t size, void *user_data, DestroyBitmapCallback destruction_callback)
Create a Bitmap that wraps existing pixel data, a user-defined destruction callback will be called wh...
virtual uint32_t width() const =0
Get the width in pixels.
static RefPtr< Bitmap > Create(uint32_t width, uint32_t height, BitmapFormat format, uint32_t alignment)
Create an aligned Bitmap with a certain configuration.
virtual void SwapRedBlueChannels()=0
Convert a BGRA bitmap to RGBA bitmap and vice-versa by swapping the red and blue channels.
virtual void Erase()=0
Erase the Bitmap (set all pixels to 0).
virtual void * LockPixels()=0
Lock the pixel buffer for reading/writing.
virtual bool WritePNG(const char *path, bool convert_to_rgba=true, bool convert_to_straight_alpha=true) const =0
Write this Bitmap out to a PNG image.
virtual IntRect bounds() const =0
Get the bounds as an IntRect.
virtual void ConvertToPremultipliedAlpha()=0
Convert a BGRA bitmap from straight alpha to premultiplied alpha.
virtual void UnlockPixels()=0
Unlock the pixel buffer.
static RefPtr< Bitmap > Create(uint32_t width, uint32_t height, BitmapFormat format, uint32_t row_bytes, const void *pixels, size_t size, bool should_copy=true)
Create a Bitmap with existing pixel data, a copy will be made unless should_copy is false.
virtual uint32_t bpp() const =0
Get the number of bytes per pixel.
virtual bool is_compressed() const =0
Whether or not this Bitmap uses a block-compressed (BCn) format.
virtual LockedPixels< RefPtr< Bitmap > > LockPixelsSafe() const =0
Lock the pixel buffer for reading/writing (safe version, automatically unlocks).
virtual const void * LockPixels() const =0
Lock the pixel buffer for reading/writing.
virtual void UnlockPixels() const =0
Unlock the pixel buffer.
virtual size_t size() const =0
Get the size in bytes of the pixel buffer.
virtual bool Resample(RefPtr< Bitmap > destination, bool high_quality)=0
Make a resized copy of this bitmap by writing to a pre-allocated destination bitmap.
virtual void ConvertToStraightAlpha()=0
Convert a BGRA bitmap from premultiplied alpha (the default) to straight alpha.
virtual BitmapFormat format() const =0
Get the pixel format.
static constexpr uint32_t MaxDimension
Maximum supported width or height, in pixels.
Definition Bitmap.h:216
virtual void * raw_pixels()=0
Get the raw pixel buffer.
Forward declaration for the LockedPixels class.
Definition Bitmap.h:544
void * data()
Access the locked pixel data.
Definition Bitmap.h:559
size_t size()
Access the size of the locked pixel data.
Definition Bitmap.h:564
~LockedPixels()
Definition Bitmap.h:551
LockedPixels(const LockedPixels &)=delete
LockedPixels & operator=(LockedPixels &&other)
Definition Bitmap.h:575
LockedPixels & operator=(const LockedPixels &)=delete
LockedPixels(T &lockable)
Definition Bitmap.h:549
LockedPixels(LockedPixels &&other)
Definition Bitmap.h:568
A nullable smart pointer.
Definition RefPtr.h:126
Interface for ref-counted objects that can additionally be observed via the WeakPtr<> smart pointer.
Definition RefPtr.h:83
Root namespace for every public Ultralight type, function, and enumeration.
bool IsCompressedFormat(BitmapFormat format)
Whether or not a given BitmapFormat is block-compressed (a BCn format).
BitmapFormatInfo GetBitmapFormatInfo(BitmapFormat format)
Get the block geometry for a given BitmapFormat.
void(*) DestroyBitmapCallback(void *user_data, void *data)
Function signature for a user-defined destruction callback to be optionally called when the Bitmap is...
Definition Bitmap.h:175
BitmapFormat
The various Bitmap formats.
Definition Bitmap.h:16
@ BC1_UNORM
BC1 block-compressed color (4x4 blocks, 8 bytes/block).
Definition Bitmap.h:51
@ RGBA32F
Four float channels (32 bits per channel, 128 bits per pixel).
Definition Bitmap.h:96
@ BC2_UNORM
BC2 block-compressed color (4x4 blocks, 16 bytes/block).
Definition Bitmap.h:58
@ RGBA16F
Four half-precision float channels (16 bits per channel, 64 bits per pixel).
Definition Bitmap.h:80
@ A8_UNORM
Alpha channel only, 8-bits per pixel.
Definition Bitmap.h:24
@ BGRA8_UNORM_SRGB
Blue Green Red Alpha channels, 32-bits per pixel.
Definition Bitmap.h:33
@ RG8_UNORM
Red Green channels, 16-bits per pixel.
Definition Bitmap.h:44
@ BC7_UNORM
BC7 block-compressed color (4x4 blocks, 16 bytes/block).
Definition Bitmap.h:72
@ RGBA16UI
Four unsigned integer channels (16 bits per channel, 64 bits per pixel).
Definition Bitmap.h:88
@ BC3_UNORM
BC3 block-compressed color (4x4 blocks, 16 bytes/block).
Definition Bitmap.h:65
Block geometry for a BitmapFormat.
Definition Bitmap.h:127
uint32_t block_width
Width of one block, in pixels (1 for uncompressed, 4 for BCn).
Definition Bitmap.h:131
uint32_t block_height
Height of one block, in pixels (1 for uncompressed, 4 for BCn).
Definition Bitmap.h:136
uint32_t block_bytes
Size of one block, in bytes (equals bytes-per-pixel when the block is 1x1).
Definition Bitmap.h:141
Integer Rectangle Helper.
Definition Geometry.h:533