|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Sub-rectangle nearest-neighbour integer-zoom blit for packed gray4 images. More...
Go to the source code of this file.
Enumerations | |
| enum | ra8_gfx_g4_const_t : uint32_t { k_ra8_g4_nib_lo = 0x0FU , k_ra8_g4_nib_sh = 4U , k_ra8_g4_rgb_g_sh = 8U , k_ra8_g4_rgb_r_sh = 16U } |
| Nibble-unpack + gray-to-colour expansion constants for the gray4 blit. More... | |
Functions | |
| static uint32_t | internal_gray4_color (const uint8_t *src, int32_t src_w, int32_t x, int32_t y) |
Expand the packed gray4 pixel at (x, y) to a 0x00RRGGBB gray colour. | |
| static void | internal_gray4_block (int32_t bx, int32_t by, int32_t zoom, uint32_t color) |
Fill the zoom x zoom framebuffer block at (bx, by) with color. | |
| ra8_err_t | ra8_gfx_blit_gray4_zoom (const uint8_t *src, int32_t src_w, int32_t src_h, int32_t sx, int32_t sy, int32_t sw, int32_t sh, int32_t zoom, int32_t dst_x, int32_t dst_y) |
| Nearest-neighbour integer-zoom blit of a sub-rectangle of a packed 4-bit grayscale image into the framebuffer (no scale-to-fit). | |
Sub-rectangle nearest-neighbour integer-zoom blit for packed gray4 images.
Implements ra8_gfx_blit_gray4_zoom(): the one primitive the reader loupe (#211) needs that the scale-to-fit blitters deliberately lack – a source-rect -> dest-rect copy that magnifies (or reproduces 1:1) without decimating source pixels. It shares the single ra8_gfx framebuffer binding and the clipped per-pixel plotter (priv_gfx_text_plot) with the rest of the rasteriser, so a lens window is clipped to the active clip rectangle exactly like every other draw.
The source pixel format is the reader's native 4-bit grayscale: two pixels per byte at flat nibble index y * src_w + x, even index in the high nibble, odd index in the low nibble – the same packing ra8_gfx_blit_gray8() consumers unpack a row at a time out of the demand-paged image pool.
Definition in file ra8_gfx_blit_gray4.c.
| enum ra8_gfx_g4_const_t : uint32_t |
Nibble-unpack + gray-to-colour expansion constants for the gray4 blit.
Definition at line 34 of file ra8_gfx_blit_gray4.c.
|
static |
Fill the zoom x zoom framebuffer block at (bx, by) with color.
Writes one magnified source pixel: a solid zoom-square block whose top-left is (bx, by). Each destination pixel is plotted through priv_gfx_text_plot(), which clips against the active clip rectangle, so a block straddling a clip edge writes only its visible pixels.
| [in] | bx | Block left edge in framebuffer pixels. |
| [in] | by | Block top edge in framebuffer pixels. |
| [in] | zoom | Block edge length in pixels; caller-guaranteed >= 1. |
| [in] | color | 0x00RRGGBB colour to write to every pixel of the block. |
zoom >= 1 so the block is non-empty. color. Definition at line 95 of file ra8_gfx_blit_gray4.c.
References priv_gfx_text_plot().
Referenced by ra8_gfx_blit_gray4_zoom().
|
static |
Expand the packed gray4 pixel at (x, y) to a 0x00RRGGBB gray colour.
Reads the byte holding flat nibble index y * src_w + x, selects the high nibble for an even index and the low nibble for an odd one, replicates the 4-bit level into 8 bits, then broadcasts it across R, G and B – the identical gray level ra8_gfx_blit_gray8() would produce for the same nibble.
| [in] | src | Packed gray4 base pointer (two pixels per byte). |
| [in] | src_w | Source width in pixels (nibble stride); caller-guaranteed > 0. |
| [in] | x | Source column, caller-clamped to [0, src_w). |
| [in] | y | Source row, caller-clamped to [0, src_h). |
| 0x00000000 | The sampled nibble is 0 (black). |
| 0x00FFFFFF | The sampled nibble is 0xF (white). |
src addresses at least (y * src_w + x) / 2 + 1 readable bytes. x and y are already clamped to the image bounds by the caller. Definition at line 64 of file ra8_gfx_blit_gray4.c.
References k_ra8_g4_nib_lo, k_ra8_g4_nib_sh, k_ra8_g4_rgb_g_sh, and k_ra8_g4_rgb_r_sh.
Referenced by ra8_gfx_blit_gray4_zoom().
|
nodiscard |
Nearest-neighbour integer-zoom blit of a sub-rectangle of a packed 4-bit grayscale image into the framebuffer (no scale-to-fit).
Samples the source sub-rectangle [sx, sx + sw) x [sy, sy + sh) of a packed gray4 image and writes every sampled source pixel as a zoom x zoom nearest-neighbour block, so the destination spans sw * zoom by sh * zoom pixels (before clipping). Unlike ra8_gfx_blit() or the reflow engine's scale-to-fit path, no source pixels are decimated – this is the 1:1 (zoom == 1) or magnified (zoom >= 2) view a reader loupe uses to inspect a full-resolution page window without resolution loss.
The source is packed two pixels per byte at flat nibble index y * src_w + x: an even flat index occupies the high nibble, an odd flat index the low nibble. Each 4-bit sample n is expanded to the 8-bit gray (n << 4) | n, then to (g << 16) | (g << 8) | g before down-conversion to the bound pixel format – byte-identical to ra8_gfx_blit_gray8()'s expansion of the same gray level.
The sampled window is clamped to the source image bounds [0, src_w) x [0, src_h): a sub-rectangle that runs off an image edge draws only the in-image portion at its natural destination offset (the off-image remainder is left untouched). Destination pixels are additionally confined to the active clip rectangle, so a lens window near a panel edge is clipped, never wrapped.
| [in] | src | Packed gray4 source image, >= (src_w * src_h + 1) / 2 bytes. |
| [in] | src_w | Source image width in pixels (> 0); also the nibble stride. |
| [in] | src_h | Source image height in pixels (> 0). |
| [in] | sx | Sub-rectangle left in source pixels (may be negative). |
| [in] | sy | Sub-rectangle top in source pixels (may be negative). |
| [in] | sw | Sub-rectangle width in source pixels (<= 0 draws nothing). |
| [in] | sh | Sub-rectangle height in source pixels (<= 0 draws nothing). |
| [in] | zoom | Integer magnification factor (>= 1; <= 0 rejected). |
| [in] | dst_x | Destination column of the sub-rectangle's top-left. |
| [in] | dst_y | Destination row of the sub-rectangle's top-left. |
| k_ra8_ok | Visible pixels written (or fully clipped out). |
| k_ra8_err_not_initialized | ra8_gfx_init() was not called. |
| k_ra8_err_invalid_arg | src is NULL, src_w / src_h <= 0, or zoom <= 0. |
src holds at least (src_w * src_h + 1) / 2 readable bytes. Definition at line 104 of file ra8_gfx_blit_gray4.c.
References g_gfx_text_state, internal_gray4_block(), internal_gray4_color(), k_ra8_err_invalid_arg, k_ra8_err_not_initialized, and k_ra8_ok.
Referenced by internal_emit_strip(), and sh_image_loupe().