/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id: helloworld.c,v 1.2 2004/08/01 00:00:00 zeekoe Exp $ * * Copyright (C) 2004 Ronald Teune * * 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 "plugin.h" static struct plugin_api* rb; int BMP_HEADER_SIZE = 62; int BMP_SIZE = 62 + 112*64; char* file; int f; int i; int truepix; int tx; int ty; bool done; void bmp_display(char buffer[BMP_SIZE]) { rb->lcd_clear_display(); for (i = BMP_HEADER_SIZE; i < BMP_SIZE; i++) { /* rb->lcd_framebuffer[i] = buffer[BMP_HEADER_SIZE+i-1]; */ truepix = i - BMP_HEADER_SIZE; /* True Pixel (R) (C) TM */ if (buffer[truepix]) { ty = truepix / 112; tx = truepix - (ty*112); rb->lcd_drawpixel(tx,ty); } } rb->lcd_update(); } /* doesnt really work correctly, i think i have to put a reverse of this in here, somewhere: rb->memset(buf2, 0, sizeof(buf2)); for(y = 0;y < 64;y++) { shift = y & 7; for(x = 0;x < 112/8;x++) { for(i = 0;i < 8;i++) { buf2[y*112/8+x] |= ((buf[y/8*112+x*8+i] >> shift) & 0x01) << (7-i); } } } */ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { char buffer[BMP_SIZE]; TEST_PLUGIN_API(api); file = (char*)parameter; /* the jpeg viewer did something like this */ if (!file) { rb->splash(HZ*2, true, "nofile"); return PLUGIN_ERROR; } rb = api; /* the wps-display had some nice loading code... */ f = rb->open(file, O_RDONLY); if (f >= 0) { int numread = rb->read(f, buffer, sizeof(buffer) - 1); if (numread > 0) { buffer[numread] = 0; bmp_display(buffer); } rb->close(f); } else { rb->splash(HZ*2, true, "open file error"); return PLUGIN_ERROR; } rb->splash(HZ*8, true, "yay!"); return PLUGIN_OK; }