Changeset 0576df9 in mainline for uspace/app/barber/barber.c


Ignore:
Timestamp:
2020-11-14T21:28:35Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63b35c7
Parents:
38f5598
Message:

Decoding images without libdraw

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/barber/barber.c

    r38f5598 r0576df9  
    3434 */
    3535
    36 #include <draw/surface.h>
    37 #include <draw/codec.h>
    3836#include <device/led_dev.h>
    3937#include <errno.h>
    4038#include <fibril_synch.h>
     39#include <gfximage/tga_gz.h>
    4140#include <io/pixel.h>
    4241#include <loc.h>
     
    9493static fibril_timer_t *frame_timer = NULL;
    9594static ui_image_t *frame_img;
    96 static surface_t *frames[FRAMES];
    9795static gfx_bitmap_t *frame_bmp[FRAMES];
    9896
     
    123121static bool decode_frames(gfx_context_t *gc)
    124122{
    125         gfx_bitmap_alloc_t alloc;
    126         surface_coord_t w, h;
    127         gfx_bitmap_params_t params;
     123        gfx_rect_t rect;
    128124        errno_t rc;
    129125
    130126        for (unsigned int i = 0; i < FRAMES; i++) {
    131                 frames[i] = decode_tga_gz(images[i].addr, images[i].size,
    132                     SURFACE_FLAG_SHARED);
    133                 if (frames[i] == NULL) {
     127                rc = decode_tga_gz(gc, images[i].addr, images[i].size,
     128                    &frame_bmp[i], &rect);
     129                if (rc != EOK) {
    134130                        printf("Unable to decode frame %u.\n", i);
    135131                        return false;
    136132                }
    137133
    138                 surface_get_resolution(frames[i], &w, &h);
    139                 gfx_bitmap_params_init(&params);
    140                 params.rect.p1.x = w;
    141                 params.rect.p1.y = h;
    142 
    143                 alloc.pitch = sizeof(uint32_t) * w;
    144                 alloc.off0 = 0;
    145                 alloc.pixels = surface_direct_access(frames[i]);
    146 
    147                 rc = gfx_bitmap_create(gc, &params, &alloc, &frame_bmp[i]);
    148                 if (rc != EOK) {
    149                         printf("Error creating bitmap.\n");
    150                         return false;
    151                 }
     134                (void) rect;
    152135        }
    153136
     
    162145                gfx_bitmap_destroy(frame_bmp[i]);
    163146                frame_bmp[i] = NULL;
    164 
    165                 surface_destroy(frames[i]);
    166                 frames[i] = NULL;
    167147        }
    168148}
Note: See TracChangeset for help on using the changeset viewer.