Index: apps/plugins/test_resize.c =================================================================== --- apps/plugins/test_resize.c (Revision 18151) +++ apps/plugins/test_resize.c (Arbeitskopie) @@ -43,13 +43,13 @@ #define SIZE_DECREASE PLA_DOWN #define SIZE_DECREASE_REPEAT PLA_DOWN_REPEAT -#define WIDTH_INCREASE PLA_RIGHT -#define WIDTH_INCREASE_REPEAT PLA_RIGHT_REPEAT -#define WIDTH_DECREASE PLA_LEFT -#define WIDTH_DECREASE_REPEAT PLA_LEFT_REPEAT +#define SINGLE_INCREASE PLA_RIGHT +#define SINGLE_INCREASE_REPEAT PLA_RIGHT_REPEAT +#define SINGLE_DECREASE PLA_LEFT +#define SINGLE_DECREASE_REPEAT PLA_LEFT_REPEAT #define BUTTON_QUIT PLA_QUIT -#define CHANGE_MODE PLA_MENU +#define CHANGE_DIRECTION PLA_MENU #define MAX_OUTPUT_WIDTH LCD_WIDTH #define MAX_OUTPUT_HEIGHT LCD_HEIGHT @@ -92,23 +92,18 @@ DEBUGF("input_bmp_data starts at %p\n", input_bmp_data); DEBUGF("output_bmp_data starts at %p\n", output_bmp_data); - int scale_algorithm = 0; + unsigned short direction = 0; while(1) { rb->lcd_clear_display(); rb->lcd_bitmap(input_bmp_data, 0, 0, input_bmp.width, input_bmp.height); - switch ( scale_algorithm ) { - case 0: - smooth_resize_bitmap(&input_bmp, &output_bmp); - rb->lcd_putsxy(0,0,"smooth_resize_bitmap"); - break; - case 1: - simple_resize_bitmap(&input_bmp, &output_bmp); - rb->lcd_putsxy(0,0,"simple_resize_bitmap"); - break; - } - + rb->resize_bitmap(&input_bmp, &output_bmp); +#ifdef HAVE_LCD_COLOR + rb->lcd_putsxy(0,0, "smooth resize (LCD_COLOR)"); +#else + rb->lcd_putsxy(0,0,"simple resize !(LCD_COLOR)"); +#endif rb->lcd_bitmap(output_bmp_data, 0, 100, output_bmp.width, output_bmp.height); @@ -132,19 +127,35 @@ if (output_bmp.height > 2) output_bmp.height -= 2; break; - case WIDTH_INCREASE: - case WIDTH_INCREASE_REPEAT: - if (output_bmp.width < MAX_OUTPUT_WIDTH - 2) - output_bmp.width += 2; + case SINGLE_INCREASE: + case SINGLE_INCREASE_REPEAT: + if (direction == 0) + { + if (output_bmp.width < MAX_OUTPUT_WIDTH - 2) + output_bmp.width += 2; + } + else + { + if (output_bmp.height < MAX_OUTPUT_HEIGHT - 2) + output_bmp.height += 2; + } break; - - case WIDTH_DECREASE: - case WIDTH_DECREASE_REPEAT: - if (output_bmp.width > 2) output_bmp.width -= 2; + case SINGLE_DECREASE: + case SINGLE_DECREASE_REPEAT: + if (direction == 0) + { + if (output_bmp.width > 2) + output_bmp.width -= 2; + } + else + { + if (output_bmp.height > 2) + output_bmp.height -= 2; + } break; - case CHANGE_MODE: - scale_algorithm = (scale_algorithm+1)%2; + direction = (direction+1)%2; + DEBUGF("%d\n",direction); break; } } Index: apps/plugins/sliding_puzzle.c =================================================================== --- apps/plugins/sliding_puzzle.c (Revision 18151) +++ apps/plugins/sliding_puzzle.c (Arbeitskopie) @@ -170,13 +170,13 @@ #ifndef PUZZLE_PICTURE #define PUZZLE_PICTURE BUTTON_CENTER #endif -#ifndef PUZZLE_QUIT_TEXT +#ifndef PUZZLE_QUIT_TEXT #define PUZZLE_QUIT_TEXT "[TOPLEFT]" #endif -#ifndef PUZZLE_SHUFFLE_TEXT +#ifndef PUZZLE_SHUFFLE_TEXT #define PUZZLE_SHUFFLE_TEXT "[BOTTOMLEFT]" #endif -#ifndef PUZZLE_PICTURE_TEXT +#ifndef PUZZLE_PICTURE_TEXT #define PUZZLE_PICTURE_TEXT "[CENTER]" #endif #endif @@ -324,11 +324,7 @@ FORMAT_NATIVE ); if( rc > 0 ) { -#ifdef HAVE_LCD_COLOR - smooth_resize_bitmap( &temp_bitmap, &main_bitmap ); -#else - simple_resize_bitmap( &temp_bitmap, &main_bitmap ); -#endif + rb->resize_bitmap( &temp_bitmap, &main_bitmap ); puzzle_bmp_ptr = (const fb_data *)img_buf; rb->strcpy( img_buf_path, filename ); return true; Index: apps/plugins/ppmviewer.c =================================================================== --- apps/plugins/ppmviewer.c (Revision 18151) +++ apps/plugins/ppmviewer.c (Arbeitskopie) @@ -51,7 +51,7 @@ ppm_error( "Error reading magic number from ppm image stream. "\ "Most often, this means your input file is empty." ); return PLUGIN_ERROR; - } + } return i1 * 256 + i2; } @@ -63,7 +63,7 @@ ppm_error("EOF. Read error reading a byte"); return PLUGIN_ERROR; } - + if (ch == '#') { do { if (!rb->read(fd, &ch, 1)) { @@ -103,7 +103,7 @@ i = i * 10 + digitVal; ch = ppm_getc(fd); - + } while (ch >= '0' && ch <= '9'); return i; @@ -138,9 +138,9 @@ } } -int read_ppm_init_rest(int fd, - int * const cols, - int * const rows, +int read_ppm_init_rest(int fd, + int * const cols, + int * const rows, int * const maxval) { /* Read size. */ @@ -150,14 +150,14 @@ if ((long unsigned int)(*cols * *rows) > PPM_MAXSIZE) { ppm_error("Imagesize (%ld pixels) is too large. "\ "The maximum allowed is %ld.", - (long unsigned int)(*cols * *rows), + (long unsigned int)(*cols * *rows), (long unsigned int)PPM_MAXSIZE); return PLUGIN_ERROR; } /* Read maxval. */ *maxval = ppm_getuint(fd); - + if (*maxval > PPM_OVERALLMAXVAL) { ppm_error("maxval of input image (%u) is too large. "\ "The maximum allowed by the PPM is %u.", @@ -171,15 +171,15 @@ return 1; } -void read_ppm_init(int fd, - int * const cols, - int * const rows, - int * const maxval, +void read_ppm_init(int fd, + int * const cols, + int * const rows, + int * const maxval, int * const format) { /* Check magic number. */ *format = ppm_read_magic_number( fd ); - + if (*format == PLUGIN_ERROR) return; switch (*format) { case PPM_FORMAT: @@ -195,10 +195,10 @@ } } -int read_ppm_row(int fd, - int const row, - int const cols, - int const maxval, +int read_ppm_row(int fd, + int const row, + int const cols, + int const maxval, int const format) { int col; @@ -214,7 +214,7 @@ b == PLUGIN_ERROR) { return PLUGIN_ERROR; - } + } buffer[(cols * row) + col] = LCD_RGBPACK( (255 / maxval) * r, (255 / maxval) * g, @@ -232,7 +232,7 @@ b == PLUGIN_ERROR) { return PLUGIN_ERROR; - } + } buffer[(cols * row) + col] = LCD_RGBPACK( (255 / maxval) * r, (255 / maxval) * g, @@ -247,20 +247,20 @@ return 1; } -int read_ppm(int fd, - int * const cols, - int * const rows, +int read_ppm(int fd, + int * const cols, + int * const rows, int * const maxval) { int row; int format; read_ppm_init(fd, cols, rows, maxval, &format); - + if(format == PLUGIN_ERROR) { return PLUGIN_ERROR; } - + for (row = 0; row < *rows; ++row) { if( read_ppm_row(fd, row, *cols, *maxval, format) == PLUGIN_ERROR) { return PLUGIN_ERROR; @@ -275,20 +275,20 @@ static char filename[MAX_PATH]; int fd; - int cols; - int rows; - int maxval; - + int cols; + int rows; + int maxval; + int result; - + struct bitmap small_bitmap, orig_bitmap; - + if(!parameter) return PLUGIN_ERROR; rb = api; rb->strcpy(filename, parameter); - + fd = rb->open(filename, O_RDONLY); if (fd < 0) { @@ -304,32 +304,32 @@ orig_bitmap.width = cols; orig_bitmap.height = rows; orig_bitmap.data = (char*)buffer; - + if (cols > LCD_WIDTH || rows > LCD_HEIGHT) { if (cols > LCD_WIDTH) { small_bitmap.width = LCD_WIDTH; - small_bitmap.height = + small_bitmap.height = (int)(((float)LCD_WIDTH / (float)cols) * (float)rows); - + } else { /* rows > LCD_HEIGHT */ - - small_bitmap.width = + + small_bitmap.width = (int)(((float)LCD_HEIGHT / (float)rows) * (float)cols); - small_bitmap.height = LCD_HEIGHT; - } + small_bitmap.height = LCD_HEIGHT; + } small_bitmap.data = (char*)lcd_buf; - smooth_resize_bitmap( &orig_bitmap, &small_bitmap ); - + rb->resize_bitmap( &orig_bitmap, &small_bitmap ); + rb->lcd_bitmap((fb_data*)small_bitmap.data, 0, 0, small_bitmap.width, small_bitmap.height); } else { - rb->lcd_bitmap((fb_data*)orig_bitmap.data, 0, 0, cols, rows); + rb->lcd_bitmap((fb_data*)orig_bitmap.data, 0, 0, cols, rows); } rb->lcd_update(); rb->button_get(true); - + return PLUGIN_OK; } Index: apps/plugins/pictureflow.c =================================================================== --- apps/plugins/pictureflow.c (Revision 18151) +++ apps/plugins/pictureflow.c (Arbeitskopie) @@ -459,7 +459,7 @@ /* now fix the track list order */ l = 0; track_count = 0; - while (l < heighest_index && + while (l < heighest_index && string_index < MAX_TRACKS*AVG_TRACK_NAME_LENGTH) { if (temp_titles[l][0] != '\0') @@ -913,7 +913,7 @@ /* resize image */ output_bmp.width = config.avg_album_width; output_bmp.height = config.avg_album_width; - simple_resize_bitmap(input_bmp, &output_bmp); + rb->resize_bitmap(input_bmp, &output_bmp); /* Resized bitmap is now in the output buffer, copy it back to the input buffer */ @@ -1792,7 +1792,7 @@ rb->lcd_getstringsize(albumtxt, NULL, &albumtxt_h); titletxt_y = ((LCD_HEIGHT-albumtxt_h-10)-(track_count*albumtxt_h))/2; } - + int track_i; for (i=0; i < track_list_visible_entries; i++) { track_i = i+start_index_track_list; Index: apps/plugins/lib/SOURCES =================================================================== --- apps/plugins/lib/SOURCES (Revision 18151) +++ apps/plugins/lib/SOURCES (Arbeitskopie) @@ -33,10 +33,7 @@ #if LCD_DEPTH>1 bmp.c #endif -#ifdef HAVE_LCD_COLOR -bmp_smooth_scale.c #endif -#endif pluginlib_actions.c helper.c #ifdef HAVE_TOUCHPAD Index: apps/plugins/lib/bmp.c =================================================================== --- apps/plugins/lib/bmp.c (Revision 18151) +++ apps/plugins/lib/bmp.c (Arbeitskopie) @@ -86,36 +86,3 @@ return 1; } #endif - -/** - Very simple image scale from src to dst (nearest neighbour). - Source and destination dimensions are read from the struct bitmap. -*/ -void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) -{ - const int srcw = src->width; - const int srch = src->height; - const int dstw = dst->width; - const int dsth = dst->height; - const fb_data *srcd = (fb_data*)(src->data); - const fb_data *dstd = (fb_data*)(dst->data); - - const long xrstep = ((srcw-1) << 8) / (dstw-1); - const long yrstep = ((srch-1) << 8) / (dsth-1); - fb_data *src_row, *dst_row; - long xr, yr = 0; - int src_x, src_y, dst_x, dst_y; - for (dst_y=0; dst_y < dsth; dst_y++) - { - src_y = (yr >> 8); - src_row = (fb_data*)&srcd[src_y * srcw]; - dst_row = (fb_data*)&dstd[dst_y * dstw]; - for (xr=0,dst_x=0; dst_x < dstw; dst_x++) - { - src_x = (xr >> 8); - dst_row[dst_x] = src_row[src_x]; - xr += xrstep; - } - yr += yrstep; - } -} Index: apps/plugins/lib/bmp_smooth_scale.c =================================================================== --- apps/plugins/lib/bmp_smooth_scale.c (Revision 18151) +++ apps/plugins/lib/bmp_smooth_scale.c (Arbeitskopie) @@ -1,446 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Code for the scaling algorithm: - * Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code - * is by Willem Monsuwe . Additional modifications are by - * (C) Daniel M. Duley. - * - * Port to Rockbox - * Copyright (C) 2007 Jonas Hurrelmann (j@outpo.st) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* - * Copyright (C) 2004, 2005 Daniel M. Duley - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* OTHER CREDITS: - * - * This is the normal smoothscale method, based on Imlib2's smoothscale. - * - * Originally I took the algorithm used in NetPBM and Qt and added MMX/3dnow - * optimizations. It ran in about 1/2 the time as Qt. Then I ported Imlib's - * C algorithm and it ran at about the same speed as my MMX optimized one... - * Finally I ported Imlib's MMX version and it ran in less than half the - * time as my MMX algorithm, (taking only a quarter of the time Qt does). - * After further optimization it seems to run at around 1/6th. - * - * Changes include formatting, namespaces and other C++'ings, removal of old - * #ifdef'ed code, and removal of unneeded border calculation code. - * - * Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code - * is by Willem Monsuwe . All other modifications are - * (C) Daniel M. Duley. - */ - -#include "bmp.h" -#include "lcd.h" - -void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) -{ - fb_data *sptr, *dptr; - int x, y, end; - int val_y = 0, val_x; - const int sw = src_bmp->width; - const int sh = src_bmp->height; - const int dw = dest_bmp->width; - const int dh = dest_bmp->height; - const int inc_x = (sw << 16) / dw; - const int inc_y = (sh << 16) / dh; - const int Cp_x = ((dw << 14) / sw) + 1; - const int Cp_y = ((dh << 14) / sh) + 1; - const int xup_yup = (dw >= sw) + ((dh >= sh) << 1); - const int dow = dw; - const int sow = sw; - fb_data *src = (fb_data*)src_bmp->data; - fb_data *dest = (fb_data*)dest_bmp->data; - int XAP, YAP, INV_YAP, INV_XAP; - int xpoint; - fb_data *ypoint; - - end = dw; - /* scaling up both ways */ - if (xup_yup == 3) { - /* go through every scanline in the output buffer */ - for (y = 0; y < dh; y++) { - /* calculate the source line we'll scan from */ - ypoint = src + ((val_y >> 16) * sw); - YAP = ((val_y >> 16) >= (sh - 1)) ? 0 : (val_y >> 8) - ((val_y >> 8) & 0xffffff00); - INV_YAP = 256 - YAP; - - val_y += inc_y; - val_x = 0; - - dptr = dest + (y * dow); - sptr = ypoint; - if (YAP > 0) { - for (x = 0; x < end; x++) { - int r = 0, g = 0, b = 0; - int rr = 0, gg = 0, bb = 0; - fb_data *pix; - - xpoint = (val_x >> 16); - XAP = ((val_x >> 16) >= (sw - 1)) ? 0 : (val_x >> 8) - ((val_x >> 8) & 0xffffff00); - INV_XAP = 256 - XAP; - val_x += inc_x; - - if (XAP > 0) { - pix = ypoint + xpoint; - r = RGB_UNPACK_RED(*pix) * INV_XAP; - g = RGB_UNPACK_GREEN(*pix) * INV_XAP; - b = RGB_UNPACK_BLUE(*pix) * INV_XAP; - pix++; - r += RGB_UNPACK_RED(*pix) * XAP; - g += RGB_UNPACK_GREEN(*pix) * XAP; - b += RGB_UNPACK_BLUE(*pix) * XAP; - pix += sow; - rr = RGB_UNPACK_RED(*pix) * XAP; - gg = RGB_UNPACK_GREEN(*pix) * XAP; - bb = RGB_UNPACK_BLUE(*pix) * XAP; - pix--; - rr += RGB_UNPACK_RED(*pix) * INV_XAP; - gg += RGB_UNPACK_GREEN(*pix) * INV_XAP; - bb += RGB_UNPACK_BLUE(*pix) * INV_XAP; - r = ((rr * YAP) + (r * INV_YAP)) >> 16; - g = ((gg * YAP) + (g * INV_YAP)) >> 16; - b = ((bb * YAP) + (b * INV_YAP)) >> 16; - *dptr++ = LCD_RGBPACK(r, g, b); - } else { - pix = ypoint + xpoint; - r = RGB_UNPACK_RED(*pix) * INV_YAP; - g = RGB_UNPACK_GREEN(*pix) * INV_YAP; - b = RGB_UNPACK_BLUE(*pix) * INV_YAP; - pix += sow; - r += RGB_UNPACK_RED(*pix) * YAP; - g += RGB_UNPACK_GREEN(*pix) * YAP; - b += RGB_UNPACK_BLUE(*pix) * YAP; - r >>= 8; - g >>= 8; - b >>= 8; - *dptr++ = LCD_RGBPACK(r, g, b); - } - } - } else { - for (x = 0; x < end; x++) { - int r = 0, g = 0, b = 0; - fb_data *pix; - - xpoint = (val_x >> 16); - XAP = ((val_x >> 16) >= (sw - 1)) ? 0 : (val_x >> 8) - ((val_x >> 8) & 0xffffff00); - INV_XAP = 256 - XAP; - val_x += inc_x; - - if (XAP > 0) { - pix = ypoint + xpoint; - r = RGB_UNPACK_RED(*pix) * INV_XAP; - g = RGB_UNPACK_GREEN(*pix) * INV_XAP; - b = RGB_UNPACK_BLUE(*pix) * INV_XAP; - pix++; - r += RGB_UNPACK_RED(*pix) * XAP; - g += RGB_UNPACK_GREEN(*pix) * XAP; - b += RGB_UNPACK_BLUE(*pix) * XAP; - r >>= 8; - g >>= 8; - b >>= 8; - *dptr++ = LCD_RGBPACK(r, g, b); - } else - *dptr++ = sptr[xpoint]; - } - } - } - } - /* if we're scaling down vertically */ - else if (xup_yup == 1) { - /*\ 'Correct' version, with math units prepared for MMXification \ */ - int Cy, j; - fb_data *pix; - int r, g, b, rr, gg, bb; - int yap; - - /* go through every scanline in the output buffer */ - for (y = 0; y < dh; y++) { - ypoint = src + ((val_y >> 16) * sw); - YAP = (((0x100 - ((val_y >> 8) & 0xff)) * Cp_y) >> 8) | (Cp_y << 16); - INV_YAP = 256 - YAP; - val_y += inc_y; - val_x = 0; - - Cy = YAP >> 16; - yap = YAP & 0xffff; - - - dptr = dest + (y * dow); - for (x = 0; x < end; x++) { - xpoint = (val_x >> 16); - XAP = ((val_x >> 16) >= (sw - 1)) ? 0 : (val_x >> 8) - ((val_x >> 8) & 0xffffff00); - INV_XAP = 256 - XAP; - val_x += inc_x; - - pix = ypoint + xpoint; - r = (RGB_UNPACK_RED(*pix) * yap) >> 10; - g = (RGB_UNPACK_GREEN(*pix) * yap) >> 10; - b = (RGB_UNPACK_BLUE(*pix) * yap) >> 10; - pix += sow; - for (j = (1 << 14) - yap; j > Cy; j -= Cy) { - r += (RGB_UNPACK_RED(*pix) * Cy) >> 10; - g += (RGB_UNPACK_GREEN(*pix) * Cy) >> 10; - b += (RGB_UNPACK_BLUE(*pix) * Cy) >> 10; - pix += sow; - } - if (j > 0) { - r += (RGB_UNPACK_RED(*pix) * j) >> 10; - g += (RGB_UNPACK_GREEN(*pix) * j) >> 10; - b += (RGB_UNPACK_BLUE(*pix) * j) >> 10; - } - if (XAP > 0) { - pix = ypoint + xpoint + 1; - rr = (RGB_UNPACK_RED(*pix) * yap) >> 10; - gg = (RGB_UNPACK_GREEN(*pix) * yap) >> 10; - bb = (RGB_UNPACK_BLUE(*pix) * yap) >> 10; - pix += sow; - for (j = (1 << 14) - yap; j > Cy; j -= Cy) { - rr += (RGB_UNPACK_RED(*pix) * Cy) >> 10; - gg += (RGB_UNPACK_GREEN(*pix) * Cy) >> 10; - bb += (RGB_UNPACK_BLUE(*pix) * Cy) >> 10; - pix += sow; - } - if (j > 0) { - rr += (RGB_UNPACK_RED(*pix) * j) >> 10; - gg += (RGB_UNPACK_GREEN(*pix) * j) >> 10; - bb += (RGB_UNPACK_BLUE(*pix) * j) >> 10; - } - r = r * INV_XAP; - g = g * INV_XAP; - b = b * INV_XAP; - r = (r + ((rr * XAP))) >> 12; - g = (g + ((gg * XAP))) >> 12; - b = (b + ((bb * XAP))) >> 12; - } else { - r >>= 4; - g >>= 4; - b >>= 4; - } - *dptr = LCD_RGBPACK(r, g, b); - dptr++; - } - } - } - /* if we're scaling down horizontally */ - else if (xup_yup == 2) { - /*\ 'Correct' version, with math units prepared for MMXification \ */ - int Cx, j; - fb_data *pix; - int r, g, b, rr, gg, bb; - int xap; - - /* go through every scanline in the output buffer */ - for (y = 0; y < dh; y++) { - ypoint = src + ((val_y >> 16) * sw); - YAP = ((val_y >> 16) >= (sh - 1)) ? 0 : (val_y >> 8) - ((val_y >> 8) & 0xffffff00); - INV_YAP = 256 - YAP; - val_y += inc_y; - val_x = 0; - - dptr = dest + (y * dow); - for (x = 0; x < end; x++) { - xpoint = (val_x >> 16); - XAP = (((0x100 - ((val_x >> 8) & 0xff)) * Cp_x) >> 8) | (Cp_x << 16); - INV_XAP = 256 - XAP; - - val_x += inc_x; - - Cx = XAP >> 16; - xap = XAP & 0xffff; - - pix = ypoint + xpoint; - r = (RGB_UNPACK_RED(*pix) * xap) >> 10; - g = (RGB_UNPACK_GREEN(*pix) * xap) >> 10; - b = (RGB_UNPACK_BLUE(*pix) * xap) >> 10; - pix++; - for (j = (1 << 14) - xap; j > Cx; j -= Cx) { - r += (RGB_UNPACK_RED(*pix) * Cx) >> 10; - g += (RGB_UNPACK_GREEN(*pix) * Cx) >> 10; - b += (RGB_UNPACK_BLUE(*pix) * Cx) >> 10; - pix++; - } - if (j > 0) { - r += (RGB_UNPACK_RED(*pix) * j) >> 10; - g += (RGB_UNPACK_GREEN(*pix) * j) >> 10; - b += (RGB_UNPACK_BLUE(*pix) * j) >> 10; - } - if (YAP > 0) { - pix = ypoint + xpoint + sow; - rr = (RGB_UNPACK_RED(*pix) * xap) >> 10; - gg = (RGB_UNPACK_GREEN(*pix) * xap) >> 10; - bb = (RGB_UNPACK_BLUE(*pix) * xap) >> 10; - pix++; - for (j = (1 << 14) - xap; j > Cx; j -= Cx) { - rr += (RGB_UNPACK_RED(*pix) * Cx) >> 10; - gg += (RGB_UNPACK_GREEN(*pix) * Cx) >> 10; - bb += (RGB_UNPACK_BLUE(*pix) * Cx) >> 10; - pix++; - } - if (j > 0) { - rr += (RGB_UNPACK_RED(*pix) * j) >> 10; - gg += (RGB_UNPACK_GREEN(*pix) * j) >> 10; - bb += (RGB_UNPACK_BLUE(*pix) * j) >> 10; - } - r = r * INV_YAP; - g = g * INV_YAP; - b = b * INV_YAP; - r = (r + ((rr * YAP))) >> 12; - g = (g + ((gg * YAP))) >> 12; - b = (b + ((bb * YAP))) >> 12; - } else { - r >>= 4; - g >>= 4; - b >>= 4; - } - *dptr = LCD_RGBPACK(r, g, b); - dptr++; - } - } - } - /* fully optimized (i think) - only change of algorithm can help */ - /* if we're scaling down horizontally & vertically */ - else { - /*\ 'Correct' version, with math units prepared for MMXification \ */ - int Cx, Cy, i, j; - fb_data *pix; - int r, g, b, rx, gx, bx; - int xap, yap; - - for (y = 0; y < dh; y++) { - ypoint = src + ((val_y >> 16) * sw); - YAP = (((0x100 - ((val_y >> 8) & 0xff)) * Cp_y) >> 8) | (Cp_y << 16); - INV_YAP = 256 - YAP; - val_y += inc_y; - val_x = 0; - - Cy = YAP >> 16; - yap = YAP & 0xffff; - - dptr = dest + (y * dow); - for (x = 0; x < end; x++) { - xpoint = (val_x >> 16); - XAP = (((0x100 - ((val_x >> 8) & 0xff)) * Cp_x) >> 8) | (Cp_x << 16); - INV_XAP = 256 - XAP; - val_x += inc_x; - - Cx = XAP >> 16; - xap = XAP & 0xffff; - - sptr = ypoint + xpoint; - - pix = sptr; - sptr += sow; - rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; - gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; - bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; - pix++; - for (i = (1 << 14) - xap; i > Cx; i -= Cx) { - rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; - pix++; - } - if (i > 0) { - rx += (RGB_UNPACK_RED(*pix) * i) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; - } - - r = (rx * yap) >> 14; - g = (gx * yap) >> 14; - b = (bx * yap) >> 14; - - for (j = (1 << 14) - yap; j > Cy; j -= Cy) { - pix = sptr; - sptr += sow; - rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; - gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; - bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; - pix++; - for (i = (1 << 14) - xap; i > Cx; i -= Cx) { - rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; - pix++; - } - if (i > 0) { - rx += (RGB_UNPACK_RED(*pix) * i) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; - } - - r += (rx * Cy) >> 14; - g += (gx * Cy) >> 14; - b += (bx * Cy) >> 14; - } - if (j > 0) { - pix = sptr; - sptr += sow; - rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; - gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; - bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; - pix++; - for (i = (1 << 14) - xap; i > Cx; i -= Cx) { - rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; - pix++; - } - if (i > 0) { - rx += (RGB_UNPACK_RED(*pix) * i) >> 9; - gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; - bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; - } - - r += (rx * j) >> 14; - g += (gx * j) >> 14; - b += (bx * j) >> 14; - } - - *dptr = LCD_RGBPACK(r >> 5, g >> 5, b >> 5); - dptr++; - } - } - } -} Index: apps/plugins/lib/bmp.h =================================================================== --- apps/plugins/lib/bmp.h (Revision 18151) +++ apps/plugins/lib/bmp.h (Arbeitskopie) @@ -31,16 +31,4 @@ int save_bmp_file( char* filename, struct bitmap *bm, const struct plugin_api* rb ); #endif -/** - Very simple image scale from src to dst (nearest neighbour). - Source and destination dimensions are read from the struct bitmap. -*/ -void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst); - -/** - Advanced image scale from src to dst (bilinear) based on imlib2. - Source and destination dimensions are read from the struct bitmap. - */ -void smooth_resize_bitmap(struct bitmap *src, struct bitmap *dst); - #endif Index: apps/plugins/SOURCES =================================================================== --- apps/plugins/SOURCES (Revision 18151) +++ apps/plugins/SOURCES (Arbeitskopie) @@ -51,7 +51,7 @@ rockblox1d.c brickmania.c maze.c -mazezam.c +mazezam.c text_editor.c wavview.c robotfindskitten.c Index: apps/plugin.c =================================================================== --- apps/plugin.c (Revision 18151) +++ apps/plugin.c (Arbeitskopie) @@ -49,6 +49,10 @@ #include "bidi.h" #endif +#ifdef HAVE_BMP_RESIZE +#include "resize.h" +#endif + #ifdef SIMULATOR static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; void *sim_plugin_load(char *plugin, void **pd); @@ -206,7 +210,7 @@ lcd_remote_bitmap, #endif viewport_set_defaults, - + /* list */ gui_synclist_init, gui_synclist_set_nb_items, @@ -238,7 +242,7 @@ #ifdef HAVE_TOUCHPAD touchpad_set_mode, #endif - + #ifdef HAVE_BUTTON_LIGHT buttonlight_set_timeout, buttonlight_off, @@ -600,6 +604,10 @@ search_albumart_files, #endif +#ifdef HAVE_BMP_RESIZE + resize_bitmap, +#endif + /* new stuff at the end, sort into place next time the API gets incompatible */ #ifdef HAVE_TAGCACHE @@ -703,8 +711,8 @@ #endif plugin_loaded = true; - + #if defined HAVE_LCD_BITMAP && LCD_DEPTH > 1 old_backdrop = lcd_get_backdrop(); #endif Index: apps/SOURCES =================================================================== --- apps/SOURCES (Revision 18151) +++ apps/SOURCES (Arbeitskopie) @@ -89,6 +89,9 @@ recorder/icons.c recorder/keyboard.c recorder/peakmeter.c +#ifdef HAVE_BMP_RESIZE +recorder/resize.c +#endif #ifdef HAVE_ALBUMART recorder/albumart.c #endif @@ -113,10 +116,10 @@ #ifdef HAVE_RECORDING enc_config.c #endif -eq.c +eq.c #if defined(CPU_COLDFIRE) dsp_cf.S -eq_cf.S +eq_cf.S #elif defined(CPU_ARM) dsp_arm.S eq_arm.S Index: apps/plugin.h =================================================================== --- apps/plugin.h (Revision 18151) +++ apps/plugin.h (Arbeitskopie) @@ -222,7 +222,7 @@ #ifdef HAVE_LCD_INVERT void (*lcd_set_invert_display)(bool yesno); #endif /* HAVE_LCD_INVERT */ - + #ifdef HAVE_LCD_ENABLE void (*lcd_set_enable_hook)(void (*enable_hook)(void)); struct event_queue *button_queue; @@ -335,7 +335,7 @@ intptr_t (*button_get_data)(void); #endif void (*button_clear_queue)(void); - int (*button_queue_count)(void); + int (*button_queue_count)(void); #ifdef HAS_BUTTON_HOLD bool (*button_hold)(void); #endif @@ -597,7 +597,7 @@ /* scroll bar */ struct gui_syncstatusbar *statusbars; void (*gui_syncstatusbar_draw)(struct gui_syncstatusbar * bars, bool force_redraw); - + /* options */ const struct settings_list* (*find_setting)(const void* variable, int *id); bool (*option_screen)(const struct settings_list *setting, @@ -611,8 +611,8 @@ const char* no_str, int no_voice, void (*function)(bool)); bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit, - const int* variable, void (*function)(int), int step, - int min, int max, + const int* variable, void (*function)(int), int step, + int min, int max, void (*formatter)(char*, size_t, int, const char*) ); bool (*set_bool)(const char* string, const bool* variable ); @@ -752,6 +752,9 @@ bool (*search_albumart_files)(const struct mp3entry *id3, const char *size_string, char *buf, int buflen); #endif +#ifdef HAVE_BMP_RESIZE + void (*resize_bitmap)(struct bitmap *src, struct bitmap *dst); +#endif /* new stuff at the end, sort into place next time the API gets incompatible */ Index: firmware/export/config_caps.h =================================================================== --- firmware/export/config_caps.h (Revision 18151) +++ firmware/export/config_caps.h (Arbeitskopie) @@ -116,3 +116,8 @@ #endif #endif /* HAVE_RECORDING */ + + +#if LCD_DEPTH > 1 +#define HAVE_BMP_RESIZE +#endif