/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id: $ * * Copyright (C) 2007 Mark Arigo * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ****************************************************************************/ #include "gui_img.h" #include "bmp.h" int gui_image_load(char* filename, struct gui_img* img, unsigned char* buffer, int bufsize, int format) { int ret; img->bm.data = buffer; ret = read_bmp_file(filename, &img->bm, bufsize, format); if (ret > 0) { img->loaded = true; img->width = img->bm.width; img->height = img->bm.height; img->subimg_index = 0; if (img->nb_subimg > 0) { img->height = img->bm.height / img->nb_subimg; } else img->nb_subimg = 1; #if LCD_DEPTH == 16 /* Always consume an even number of bytes */ if (ret % 2) ret++; #endif } else img->loaded = false; return ret; } void gui_image_draw(struct screen *display, struct gui_img* img) { if(img->always_display) display->set_drawmode(DRMODE_FG); else display->set_drawmode(DRMODE_SOLID); if (img->nb_subimg > 1) { #if LCD_DEPTH > 1 if(img->bm.format == FORMAT_MONO) { #endif display->mono_bitmap_part(img->bm.data, 0, img->subimg_index * img->height, img->width, img->x, img->y, img->width, img->height); #if LCD_DEPTH > 1 } else { display->transparent_bitmap_part((fb_data *)img->bm.data, 0, img->subimg_index * img->height, img->width, img->x, img->y, img->width, img->height); } #endif return; } #if LCD_DEPTH > 1 if(img->bm.format == FORMAT_MONO) { #endif display->mono_bitmap(img->bm.data, img->x, img->y, img->width, img->height); #if LCD_DEPTH > 1 } else { display->transparent_bitmap((fb_data *)img->bm.data, img->x, img->y, img->width, img->height); } #endif display->set_drawmode(DRMODE_SOLID); }