Changeset d2100e2 in mainline for uspace/lib/gfxfont/src/glyph.c


Ignore:
Timestamp:
2020-08-09T18:40:28Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
06b8383
Parents:
5592c56
Message:

Finish glyph bitmap operations and tests

Setting/getting pixel, opening/saving glyph bitmap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gfxfont/src/glyph.c

    r5592c56 rd2100e2  
    3636#include <assert.h>
    3737#include <errno.h>
     38#include <gfx/bitmap.h>
    3839#include <gfx/glyph.h>
     40#include <io/pixelmap.h>
    3941#include <mem.h>
    4042#include <stdlib.h>
     
    252254}
    253255
     256/** Transfer glyph to new font bitmap.
     257 *
     258 * @param glyph Glyph
     259 * @param offs Offset in new font bitmap
     260 * @param dest New font bitmap
     261 * @param drect Bounding rectangle for @a dest
     262 *
     263 * @return EOK on success or an error code
     264 */
     265errno_t gfx_glyph_transfer(gfx_glyph_t *glyph, gfx_coord_t offs,
     266    gfx_bitmap_t *dest, gfx_rect_t *drect)
     267{
     268        pixelmap_t smap;
     269        pixelmap_t dmap;
     270        gfx_bitmap_alloc_t salloc;
     271        gfx_bitmap_alloc_t dalloc;
     272        gfx_coord_t x, y;
     273        pixel_t pixel;
     274        errno_t rc;
     275
     276        rc = gfx_bitmap_get_alloc(glyph->font->bitmap, &salloc);
     277        if (rc != EOK)
     278                return rc;
     279
     280        rc = gfx_bitmap_get_alloc(dest, &dalloc);
     281        if (rc != EOK)
     282                return rc;
     283
     284        smap.width = glyph->font->rect.p1.x;
     285        smap.height = glyph->font->rect.p1.y;
     286        smap.data = salloc.pixels;
     287
     288        dmap.width = drect->p1.x;
     289        dmap.height = drect->p1.y;
     290        dmap.data = dalloc.pixels;
     291
     292        for (y = drect->p0.y; y < drect->p1.y; y++) {
     293                for (x = drect->p0.x; x < drect->p1.x; x++) {
     294                        pixel = pixelmap_get_pixel(&smap, x, y);
     295                        pixelmap_put_pixel(&dmap, x + offs, y, pixel);
     296                }
     297        }
     298
     299        return EOK;
     300}
     301
    254302/** @}
    255303 */
Note: See TracChangeset for help on using the changeset viewer.