|
Last change
on this file since 9bfa8c8 was d7f7a4a, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago |
|
Replace some license headers with SPDX identifier
Headers are replaced using tools/transorm-copyright.sh only
when it can be matched verbatim with the license header used
throughout most of the codebase.
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * SPDX-FileCopyrightText: 2011 Petr Koupy
|
|---|
| 3 | * SPDX-FileCopyrightText: 2014 Martin Sucha
|
|---|
| 4 | *
|
|---|
| 5 | * SPDX-License-Identifier: BSD-3-Clause
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /** @addtogroup libc
|
|---|
| 9 | * @{
|
|---|
| 10 | */
|
|---|
| 11 | /**
|
|---|
| 12 | * @file
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | #ifndef _LIBC_IO_PIXELMAP_H_
|
|---|
| 16 | #define _LIBC_IO_PIXELMAP_H_
|
|---|
| 17 |
|
|---|
| 18 | #include <types/common.h>
|
|---|
| 19 | #include <stdbool.h>
|
|---|
| 20 | #include <stddef.h>
|
|---|
| 21 | #include <io/pixel.h>
|
|---|
| 22 |
|
|---|
| 23 | typedef struct {
|
|---|
| 24 | sysarg_t width;
|
|---|
| 25 | sysarg_t height;
|
|---|
| 26 | pixel_t *data;
|
|---|
| 27 | } pixelmap_t;
|
|---|
| 28 |
|
|---|
| 29 | static inline pixel_t *pixelmap_pixel_at(
|
|---|
| 30 | pixelmap_t *pixelmap,
|
|---|
| 31 | sysarg_t x,
|
|---|
| 32 | sysarg_t y)
|
|---|
| 33 | {
|
|---|
| 34 | if (x < pixelmap->width && y < pixelmap->height) {
|
|---|
| 35 | size_t offset = y * pixelmap->width + x;
|
|---|
| 36 | pixel_t *pixel = pixelmap->data + offset;
|
|---|
| 37 | return pixel;
|
|---|
| 38 | } else {
|
|---|
| 39 | return NULL;
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | static inline void pixelmap_put_pixel(
|
|---|
| 44 | pixelmap_t *pixelmap,
|
|---|
| 45 | sysarg_t x,
|
|---|
| 46 | sysarg_t y,
|
|---|
| 47 | pixel_t pixel)
|
|---|
| 48 | {
|
|---|
| 49 | pixel_t *target = pixelmap_pixel_at(pixelmap, x, y);
|
|---|
| 50 | if (target != NULL) {
|
|---|
| 51 | *target = pixel;
|
|---|
| 52 | }
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | static inline pixel_t pixelmap_get_pixel(
|
|---|
| 56 | pixelmap_t *pixelmap,
|
|---|
| 57 | sysarg_t x,
|
|---|
| 58 | sysarg_t y)
|
|---|
| 59 | {
|
|---|
| 60 | pixel_t *source = pixelmap_pixel_at(pixelmap, x, y);
|
|---|
| 61 | if (source != NULL) {
|
|---|
| 62 | return *source;
|
|---|
| 63 | } else {
|
|---|
| 64 | return 0;
|
|---|
| 65 | }
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | #endif
|
|---|
| 69 |
|
|---|
| 70 | /** @}
|
|---|
| 71 | */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.