diff -ru rockbox_orig/apps/gui/gwps-common.c rockbox/apps/gui/gwps-common.c --- rockbox_orig/apps/gui/gwps-common.c 2006-07-19 01:17:54.000000000 +0900 +++ rockbox/apps/gui/gwps-common.c 2006-07-19 11:06:28.590552000 +0900 @@ -291,7 +291,7 @@ data->progressbar.bm.data=data->img_buf_ptr; ret = read_bmp_file(imgname, &data->progressbar.bm, data->img_buf_free, - FORMAT_ANY|FORMAT_TRANSPARENT); + FORMAT_ANY|FORMAT_TRANSPARENT,0,0); if (ret > 0) { @@ -405,7 +405,7 @@ data->img[n].bm.data = data->img_buf_ptr; ret = read_bmp_file(imgname, &data->img[n].bm, data->img_buf_free, - FORMAT_ANY|FORMAT_TRANSPARENT); + FORMAT_ANY|FORMAT_TRANSPARENT,0,0); if (ret > 0) { @@ -2866,8 +2866,10 @@ if (gui_wps->data->wps_has_albumart && gwps->state->id3->albumart_found) { - if (strcasecmp(cur_displayed_albumart_path, - gwps->state->id3->albumart_path) != 0) + if ((strcasecmp(cur_displayed_albumart_path, + gwps->state->id3->albumart_path) != 0) || + (cur_displayed_albumart_width != gui_wps->data->albumart_max_width) || + (cur_displayed_albumart_height != gui_wps->data->albumart_max_height)) { /* load the cover art bitmap */ int rc; @@ -2875,7 +2877,8 @@ temp_bm.data = gui_wps->data->img_buf_ptr; rc = read_bmp_file(gwps->state->id3->albumart_path, &temp_bm, gui_wps->data->img_buf_free, - FORMAT_ANY|FORMAT_TRANSPARENT); + FORMAT_ANY|FORMAT_TRANSPARENT, + gui_wps->data->albumart_max_width, gui_wps->data->albumart_max_height); if (rc > 0) { //gwps->state->id3->albumart_size = cur_displayed_albumart_size = rc; diff -ru rockbox_orig/apps/recorder/backdrop.c rockbox/apps/recorder/backdrop.c --- rockbox_orig/apps/recorder/backdrop.c 2006-05-21 13:00:02.000000000 +0900 +++ rockbox/apps/recorder/backdrop.c 2006-07-19 11:06:28.610580800 +0900 @@ -36,7 +36,7 @@ /* load the image */ bm.data=(char*)backdrop_buffer; - ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), FORMAT_NATIVE); + ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), FORMAT_NATIVE, 0, 0); if ((ret > 0) && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT)) { diff -ru rockbox_orig/apps/recorder/bmp.c rockbox/apps/recorder/bmp.c --- rockbox_orig/apps/recorder/bmp.c 2006-04-24 17:52:04.000000000 +0900 +++ rockbox/apps/recorder/bmp.c 2006-07-21 03:34:04.733800000 +0900 @@ -104,7 +104,9 @@ int read_bmp_file(char* filename, struct bitmap *bm, int maxsize, - int format) + int format, + int dst_x, + int dst_y) { struct Fileheader fh; int width, height, PaddedWidth, PaddedHeight, dst_width; @@ -115,8 +117,25 @@ int depth; int totalsize; char *bitmap = bm->data; - - unsigned char bmpbuf[LCD_WIDTH*sizeof(struct rgb_quad)]; /* Buffer for one line */ + int e_x; + int e_y; + int src_x; + int src_y; + int r_x; + int r_y; + int r_t; + int tr_x; + int tr_x1; + int tr_x2; + int tr_y; + int tr_y1; + int tr_y2; + int w_flag; + int c_y; + int l_y; + int p_buf[3][LCD_WIDTH]; + + unsigned char bmpbuf[512*sizeof(struct rgb_quad)]; /* Buffer for one line */ #if LCD_DEPTH == 1 format = FORMAT_MONO; @@ -152,7 +171,7 @@ } /* Exit if too wide */ - if (readlong(&fh.Width) > LCD_WIDTH) { + if (dst_x > LCD_WIDTH) { DEBUGF("error - Bitmap is too wide (%d pixels, max is %d)\n", readlong(&fh.Width), LCD_WIDTH); close(fd); @@ -160,7 +179,7 @@ } /* Exit if too high */ - if (readlong(&fh.Height) > LCD_HEIGHT) { + if (dst_y > LCD_HEIGHT) { DEBUGF("error - Bitmap is too high (%d pixels, max is %d)\n", readlong(&fh.Height), LCD_HEIGHT); close(fd); @@ -172,7 +191,42 @@ width = readlong(&fh.Width); depth = readshort(&fh.BitCount); - /* 4-byte boundary aligned */ + if ((dst_x == 0) || (dst_y == 0)) { + dst_x = width; + dst_y = height; + } + + e_x = 0; + e_y = 0; + src_x = width; + src_y = height; + c_y = 0; + + r_x = 1024 * dst_x / src_x; + r_y = 1024 * dst_y / src_y; + r_t = (r_x 1 @@ -186,21 +240,21 @@ /* PaddedHeight is for rockbox format. */ if(format == FORMAT_MONO) { - PaddedHeight = (height + 7) / 8; - dst_width = width; + PaddedHeight = (dst_y + 7) / 8; + dst_width = dst_x; totalsize = PaddedHeight * dst_width; } else { #if LCD_DEPTH == 2 #if LCD_PIXELFORMAT == VERTICAL_PACKING - PaddedHeight = (height + 3) / 4; - dst_width = width; + PaddedHeight = (dst_y + 3) / 4; + dst_width = dst_x; #else - PaddedHeight = height; - dst_width = (width + 3) / 4; + PaddedHeight = dst_y; + dst_width = (dst_x + 3) / 4; #endif #else - PaddedHeight = height; - dst_width = width; + PaddedHeight = dst_y; + dst_width = dst_x; #endif totalsize = PaddedHeight * dst_width * sizeof(fb_data); } @@ -248,18 +302,21 @@ #endif /* loop to read rows and put them to buffer */ - for (row = 0; row < height; row++) { - unsigned char *p; - - /* read one row */ - ret = read(fd, bmpbuf, PaddedWidth); + e_y = 0; + c_y = 1; + w_flag = 1; + l_y = 1; + /* read one row */ + ret = read(fd, bmpbuf, PaddedWidth); /* src_y++ */ if (ret != PaddedWidth) { DEBUGF("error reading image, read returned: %d expected was: " "%d\n", ret, PaddedWidth); close(fd); return -9; } - + for (row = 0; row < dst_y; row++ ) { + unsigned char *p; + switch(depth) { case 1: #if LCD_DEPTH > 1 @@ -379,72 +436,223 @@ if(format == FORMAT_MONO) { #endif /* RGB24 -> mono */ - for (col = 0; col < width; col++) { + e_x = 0; + int p0, p1, p2, i; + p0 = 0; + p1 = 0; + p2 = 0; + i = 1; + for (col = 0; col < dst_x; col++) { + if ((tr_x1 <= col) && (col <= tr_x2) && (tr_y1 <= row) && (row <= tr_y2) ) { struct rgb_quad rgb; - rgb.red = p[2]; - rgb.green = p[1]; - rgb.blue = p[0]; - ret = brightness(rgb); - if (ret > 96) { - bitmap[width * ((height - row - 1) / 8) + col] - &= ~ 1 << ((height - row - 1) % 8); - } else { - bitmap[width * ((height - row - 1) / 8) + col] - |= 1 << ((height - row - 1) % 8); + p_buf[0][col] += (p[0]+p0)/i; + p_buf[1][col] += (p[1]+p1)/i; + p_buf[2][col] += (p[2]+p2)/i; + if (w_flag == 1) { + rgb.red = p_buf[2][col]/l_y; + rgb.green = p_buf[1][col]/l_y; + rgb.blue = p_buf[0][col]/l_y; + ret = brightness(rgb); + if (ret > 96) { + bitmap[dst_x * ((dst_y - row - 1) / 8) + col] + &= ~ 1 << ((dst_y - row - 1) % 8); + } else { + bitmap[dst_x * ((dst_y - row - 1) / 8) + col] + |= 1 << ((dst_y - row - 1) % 8); + } + e_x = e_x + width; + i = 1; + p0 = 0; + p1 = 0; + p2 = 0; + while ( e_x >= tr_x ) { + p += 3; /* src_x++ */ + i++; + p0 += p[0]; + p1 += p[1]; + p2 += p[2]; + e_x = e_x - tr_x; } - p += 3; + } else { + bitmap[dst_x * ((dst_y - row - 1) / 8) + col] + |= 1 << ((dst_y - row - 1) % 8); + } + } + if (w_flag == 1) { + l_y = 1; } + } #if LCD_DEPTH == 2 #if LCD_PIXELFORMAT == VERTICAL_PACKING } else { /* RGB24 -> 2gray (iriver H1xx) */ - for (col = 0; col < width; col++) { + e_x = 0; + int p0, p1, p2, i; + p0 = 0; + p1 = 0; + p2 = 0; + i = 1; + for (col = 0; col < dst_x; col++) { + if ((tr_x1 <= col) && (col <= tr_x2) && (tr_y1 <= row) && (row <= tr_y2) ) { struct rgb_quad rgb; - rgb.red = p[2]; - rgb.green = p[1]; - rgb.blue = p[0]; - ret = brightness(rgb); - - dest[((height - row - 1)/4) * width + col] |= - (~ret & 0xC0) >> (2 * (~(height - row - 1) & 3)); - p += 3; + p_buf[0][col] += (p[0]+p0)/i; + p_buf[1][col] += (p[1]+p1)/i; + p_buf[2][col] += (p[2]+p2)/i; + if (w_flag == 1) { + rgb.red = p_buf[2][col]/l_y; + rgb.green = p_buf[1][col]/l_y; + rgb.blue = p_buf[0][col]/l_y; + ret = brightness(rgb); + dest[((dst_y - row - 1)/4) * dst_x + col] |= + (~ret & 0xC0) >> (2 * (~(dst_y - row - 1) & 3)); + p_buf[0][col] = 0; + p_buf[1][col] = 0; + p_buf[2][col] = 0; + } + e_x = e_x + width; + i = 1; + p0 = 0; + p1 = 0; + p2 = 0; + while ( e_x >= tr_x ) { + p += 3; /* src_x++ */ + i++; + p0 += p[0]; + p1 += p[1]; + p2 += p[2]; + e_x -= tr_x; + } + } else { + dest[((dst_y - row - 1)/4) * dst_x + col] |= + (0 & 0xC0) >> (2 * (~(dst_y - row - 1) & 3)); + } + } + if (w_flag == 1) { + l_y = 1; } } #else } else { /* RGB24 -> 2gray (ipod) */ - for (col = 0; col < width; col++) { + e_x = 0; + int p0, p1, p2, i; + p0 = 0; + p1 = 0; + p2 = 0; + i = 1; + for (col = 0; col < dst_x; col++) { + if ((tr_x1 <= col) && (col <= tr_x2) && (tr_y1 <= row) && (row <= tr_y2) ) { struct rgb_quad rgb; - rgb.red = p[2]; - rgb.green = p[1]; - rgb.blue = p[0]; - ret = brightness(rgb); - - dest[(height - row - 1) * dst_width + col/4] |= - (~ret & 0xC0) >> (2 * (col & 3)); - p += 3; + p_buf[0][col] += (p[0]+p0)/i; + p_buf[1][col] += (p[1]+p1)/i; + p_buf[2][col] += (p[2]+p2)/i; + if (w_flag == 1) { + rgb.red = p_buf[2][col]/l_y; + rgb.green = p_buf[1][col]/l_y; + rgb.blue = p_buf[0][col]/l_y; + ret = brightness(rgb); + dest[(dst_y - row - 1) * dst_x + col/4] |= + (~ret & 0xC0) >> (2 * (col & 3)); + p_buf[0][col] = 0; + p_buf[1][col] = 0; + p_buf[2][col] = 0; + } + e_x = e_x + width; + while ( e_x >= tr_x ) { + p += 3; /* src_x++ */ + i++; + p0 += p[0]; + p1 += p[1]; + p2 += p[2]; + e_x -=tr_x; + } + } else { + dest[(dst_y - row - 1) * dst_x + col/4] = + (0 & 0xC0) >> (2 * (col & 3)); + } + } + if (w_flag == 1) { + l_y = 1; } } #endif #elif LCD_DEPTH == 16 } else { /* RGB24 -> RGB16 */ - for (col = 0; col < width; col++) { - unsigned short rgb = LCD_RGBPACK(p[2],p[1],p[0]); - dest[width * (height - row - 1) + col] = rgb; - p += 3; + e_x = 0; + int p0, p1, p2, i; + p0 = 0; + p1 = 0; + p2 = 0; + i = 1; + for (col = 0; col < dst_x; col++) { + if ((tr_x1 <= col) && (col <= tr_x2) && (tr_y1 <= row) && (row <= tr_y2)) { + p_buf[0][col] += (p[0]+p0)/i; + p_buf[1][col] += (p[1]+p1)/i; + p_buf[2][col] += (p[2]+p2)/i; + if (w_flag == 1) { + unsigned short rgb = LCD_RGBPACK((p_buf[2][col]/l_y),(p_buf[1][col]/l_y),(p_buf[0][col]/l_y)); + dest[dst_x * (dst_y - row - 1) + col] = rgb; + p_buf[0][col] = 0; + p_buf[1][col] = 0; + p_buf[2][col] = 0; + } + e_x += width; + i = 1; + p0 = 0; + p1 = 0; + p2 = 0; + while ( e_x >= tr_x ) { + p += 3; /* src_x++ */ + i++; + p0 += p[0]; + p1 += p[1]; + p2 += p[2]; + e_x -= tr_x; + } + } else { + dest[dst_x * (dst_y - row - 1) + col] = TRANSPARENT_COLOR; + } + } + if (w_flag == 1) { + l_y = 1; } } #endif break; } + if ((tr_y1 <= row) && (row <= tr_y2)) { + if (w_flag == 1) e_y += height; + if (e_y >= tr_y) { + c_y++; + if (c_y <= height) { + ret = read(fd, bmpbuf, PaddedWidth); /* src_y++ */ + if (ret != PaddedWidth) { + DEBUGF("error reading image, read returned: %d expected was: " + "%d\n", ret, PaddedWidth); + close(fd); + return -9; + } + } + e_y -= tr_y; + if (e_y >= tr_y) { + row--; + l_y++; + w_flag = 0; + } else { + w_flag = 1; + } + } else { + w_flag = 1; + } + } } close(fd); /* returning image size: */ - bm->width = width; - bm->height = height; + bm->width = dst_x; + bm->height = dst_y; #if LCD_DEPTH > 1 bm->format = format; #endif diff -ru rockbox_orig/apps/recorder/bmp.h rockbox/apps/recorder/bmp.h --- rockbox_orig/apps/recorder/bmp.h 2006-01-28 13:12:42.000000000 +0900 +++ rockbox/apps/recorder/bmp.h 2006-07-19 11:06:28.680681600 +0900 @@ -32,5 +32,7 @@ int read_bmp_file(char* filename, struct bitmap *bm, int maxsize, - int format); + int format, + int dst_x, // if x_size=0 or y_size=0, load original size + int dst_y); // #endif