diff -uNr rockbox-20070817/apps/plugins/jpeg.c rockbox-patched/apps/plugins/jpeg.c --- rockbox-20070817/apps/plugins/jpeg.c 2007-08-17 08:00:02.000000000 +0400 +++ rockbox-patched/apps/plugins/jpeg.c 2007-08-17 15:44:11.000000000 +0400 @@ -1899,7 +1899,9 @@ char **file_pt; /* are we using the plugin buffer or the audio buffer? */ bool plug_buf = false; - +/* Zoom while playing variables. If plugin memory runs out for zoom. */ +int temp_ds; +bool zoom_more = false, autozoom = false; /************************* Implementation ***************************/ @@ -2847,6 +2849,10 @@ while (downscale > 1 && jpegmem(p_jpg, downscale/2) <= bufsize) downscale /= 2; + if(plug_buf == true && downscale > 1) + zoom_more = true; + else + zoom_more = false; return downscale; } @@ -3160,7 +3166,14 @@ ds = ds_max; /* initials setting */ cx = jpg.x_size/ds/2; /* center the view */ cy = jpg.y_size/ds/2; - + + if(autozoom) /*Autozoom image. If the user stopped playback to zoom more.*/ + { + ds = temp_ds; /* reduce downscaling to zoom in */ + cx *= 2; /* prepare the position in the new image */ + cy *= 2; + } + do /* loop the image prepare and decoding when zoomed */ { p_disp = get_image(&jpg, ds); /* decode or fetch from cache */ @@ -3176,7 +3189,14 @@ rb->lcd_puts(0, 3, print); rb->lcd_update(); } - MYLCD(clear_display)(); + + if(autozoom) + { + get_view(p_disp, &cx, &cy); + autozoom = false; + } + + MYLCD(clear_display)(); #ifdef HAVE_LCD_COLOR yuv_bitmap_part( p_disp->bitmap, p_disp->csub_x, p_disp->csub_y, @@ -3193,6 +3213,7 @@ MIN(LCD_WIDTH, p_disp->width), MIN(LCD_HEIGHT, p_disp->height)); #endif + MYLCD_UPDATE(); #ifdef USEGSLIB @@ -3214,6 +3235,55 @@ cx *= 2; /* prepare the position in the new image */ cy *= 2; } + else if (zoom_more == true) + { + bool exit = false; +#ifdef USEGSLIB + gray_show(false); +#endif + rb->lcd_setfont(FONT_SYSFIXED); + rb->lcd_clear_display(); + rb->snprintf(print,sizeof(print),"%s:", + rb->strrchr(filename,'/')+1); + rb->lcd_puts(0,0,print); + rb->lcd_puts(0,1,"Not enough memory to zoom!"); + rb->lcd_puts(0,2,"Zoom In: Stop playback"); + rb->lcd_puts(0,3,"to zoom."); + rb->lcd_puts(0,4,"Off: Cancel."); + rb->lcd_update(); + rb->lcd_setfont(FONT_UI); + + rb->button_clear_queue(); + + while (!exit) + { + int button = rb->button_get(true); + switch(button) + { + case JPEG_ZOOM_IN: + plug_buf = false; + zoom_more = false; + autozoom = true; + temp_ds = ds / 2; + buf_images = + rb->plugin_get_audio_buffer(&buf_images_size); + return PLUGIN_OTHER; + + case JPEG_MENU: +#ifdef USEGSLIB + gray_show(true); +#endif + exit = true; + break; + + default: + if(rb->default_event_handler_ex(button, + cleanup, NULL) + == SYS_USB_CONNECTED) + return PLUGIN_USB_CONNECTED; + } + } + } else continue; }