summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2009-10-15 13:11:31 +0000
committerTeruaki Kawashima <teru@rockbox.org>2009-10-15 13:11:31 +0000
commit889436816ec5c0b9e1900a0495ec0366b584a3b1 (patch)
tree2ee038efba11d0a7b60121f3950920097596e8df /apps/plugins
parent91933a3fef096d267b2aae1e32b7bff9fe4b3e02 (diff)
downloadrockbox-889436816ec5c0b9e1900a0495ec0366b584a3b1.tar.gz
rockbox-889436816ec5c0b9e1900a0495ec0366b584a3b1.zip
FS#10554: Rockpaint: enable to set canvas size.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23188 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/rockpaint.c49
1 files changed, 38 insertions, 11 deletions
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index 78fe7b46fe..0f57b2b11c 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -322,6 +322,8 @@ static void draw_rect_full( int x1, int y1, int x2, int y2 );
322 322
323static int drawcolor=0; /* Current color (in palette) */ 323static int drawcolor=0; /* Current color (in palette) */
324static int bgdrawcolor=9; /* Current background color (in palette) */ 324static int bgdrawcolor=9; /* Current background color (in palette) */
325static int img_height = ROWS;
326static int img_width = COLS;
325bool isbg = false; /* gruik ugly hack alert */ 327bool isbg = false; /* gruik ugly hack alert */
326 328
327static int preview=false; /* Is preview mode on ? */ 329static int preview=false; /* Is preview mode on ? */
@@ -531,6 +533,7 @@ enum {
531 /* Main menu */ 533 /* Main menu */
532 MAIN_MENU_RESUME, 534 MAIN_MENU_RESUME,
533 MAIN_MENU_NEW, MAIN_MENU_LOAD, MAIN_MENU_SAVE, 535 MAIN_MENU_NEW, MAIN_MENU_LOAD, MAIN_MENU_SAVE,
536 MAIN_MENU_SET_WIDTH, MAIN_MENU_SET_HEIGHT,
534 MAIN_MENU_BRUSH_SIZE, MAIN_MENU_BRUSH_SPEED, MAIN_MENU_COLOR, 537 MAIN_MENU_BRUSH_SIZE, MAIN_MENU_BRUSH_SPEED, MAIN_MENU_COLOR,
535 MAIN_MENU_GRID_SIZE, 538 MAIN_MENU_GRID_SIZE,
536 MAIN_MENU_PLAYBACK_CONTROL, 539 MAIN_MENU_PLAYBACK_CONTROL,
@@ -551,6 +554,7 @@ enum {
551 554
552MENUITEM_STRINGLIST(main_menu, "RockPaint", NULL, 555MENUITEM_STRINGLIST(main_menu, "RockPaint", NULL,
553 "Resume", "New", "Load", "Save", 556 "Resume", "New", "Load", "Save",
557 "Set Width", "Set Height",
554 "Brush Size", "Brush Speed", 558 "Brush Size", "Brush Speed",
555 "Choose Color", "Grid Size", 559 "Choose Color", "Grid Size",
556 "Playback Control", "Exit"); 560 "Playback Control", "Exit");
@@ -1468,13 +1472,13 @@ static void show_grid( bool update )
1468 if( gridsize > 0 ) 1472 if( gridsize > 0 )
1469 { 1473 {
1470 rb->lcd_set_drawmode(DRMODE_COMPLEMENT); 1474 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
1471 for( i = gridsize; i < COLS; i+= gridsize ) 1475 for( i = gridsize; i < img_width; i+= gridsize )
1472 { 1476 {
1473 rb->lcd_vline( i, 0, ROWS-1 ); 1477 rb->lcd_vline( i, 0, img_height-1 );
1474 } 1478 }
1475 for( i = gridsize; i < ROWS; i+= gridsize ) 1479 for( i = gridsize; i < img_height; i+= gridsize )
1476 { 1480 {
1477 rb->lcd_hline( 0, COLS-1, i ); 1481 rb->lcd_hline( 0, img_width-1, i );
1478 } 1482 }
1479 rb->lcd_set_drawmode(DRMODE_SOLID); 1483 rb->lcd_set_drawmode(DRMODE_SOLID);
1480 if( update ) rb->lcd_update(); 1484 if( update ) rb->lcd_update();
@@ -2443,10 +2447,8 @@ static void inv_cursor(bool update)
2443 rb->lcd_set_foreground(COLOR_BLACK); 2447 rb->lcd_set_foreground(COLOR_BLACK);
2444 rb->lcd_set_drawmode(DRMODE_COMPLEMENT); 2448 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
2445 /* cross painting */ 2449 /* cross painting */
2446 rb->lcd_hline(x-4,x-1,y); 2450 rb->lcd_hline(x-4,x+4,y);
2447 rb->lcd_hline(x+1,x+4,y); 2451 rb->lcd_vline(x,y-4,y+4);
2448 rb->lcd_vline(x,y-4,y-1);
2449 rb->lcd_vline(x,y+1,y+4);
2450 rb->lcd_set_foreground(rp_colors[drawcolor]); 2452 rb->lcd_set_foreground(rp_colors[drawcolor]);
2451 rb->lcd_set_drawmode(DRMODE_SOLID); 2453 rb->lcd_set_drawmode(DRMODE_SOLID);
2452 2454
@@ -2456,11 +2458,18 @@ static void inv_cursor(bool update)
2456static void restore_screen(void) 2458static void restore_screen(void)
2457{ 2459{
2458 rb->lcd_bitmap( save_buffer, 0, 0, COLS, ROWS ); 2460 rb->lcd_bitmap( save_buffer, 0, 0, COLS, ROWS );
2461 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
2462 rb->lcd_vline( img_width, 0, ROWS );
2463 rb->lcd_hline( 0, COLS, img_height );
2464 rb->lcd_drawpixel( img_width, img_height );
2465 rb->lcd_set_drawmode(DRMODE_SOLID);
2459} 2466}
2460 2467
2461static void clear_drawing(void) 2468static void clear_drawing(void)
2462{ 2469{
2463 init_buffer(); 2470 init_buffer();
2471 img_height = ROWS;
2472 img_width = COLS;
2464 rb->lcd_set_foreground( rp_colors[ bgdrawcolor ] ); 2473 rb->lcd_set_foreground( rp_colors[ bgdrawcolor ] );
2465 rb->lcd_fillrect( 0, 0, COLS, ROWS ); 2474 rb->lcd_fillrect( 0, 0, COLS, ROWS );
2466 rb->lcd_update(); 2475 rb->lcd_update();
@@ -2511,6 +2520,14 @@ static void goto_menu(void)
2511 } 2520 }
2512 break; 2521 break;
2513 2522
2523 case MAIN_MENU_SET_WIDTH:
2524 rb->set_int( "Set Width", "px", UNIT_INT, &img_width,
2525 NULL, 1, 1, COLS, NULL );
2526 break;
2527 case MAIN_MENU_SET_HEIGHT:
2528 rb->set_int( "Set Height", "px", UNIT_INT, &img_height,
2529 NULL, 1, 1, ROWS, NULL );
2530 break;
2514 case MAIN_MENU_BRUSH_SIZE: 2531 case MAIN_MENU_BRUSH_SIZE:
2515 for(multi = 0; multi<4; multi++) 2532 for(multi = 0; multi<4; multi++)
2516 if(bsize == times_list[multi]) break; 2533 if(bsize == times_list[multi]) break;
@@ -2742,11 +2759,13 @@ static bool rockpaint_loop( void )
2742 break; 2759 break;
2743 } 2760 }
2744 reset_tool(); 2761 reset_tool();
2762 restore_screen();
2745 } 2763 }
2746 break; 2764 break;
2747 2765
2748 case Fill: 2766 case Fill:
2749 draw_fill( x, y ); 2767 draw_fill( x, y );
2768 restore_screen();
2750 break; 2769 break;
2751 2770
2752 case ColorPicker: 2771 case ColorPicker:
@@ -2954,6 +2973,8 @@ static int load_bitmap( const char *file )
2954 if((bm.width > COLS ) || ( bm.height > ROWS )) 2973 if((bm.width > COLS ) || ( bm.height > ROWS ))
2955 return -1; 2974 return -1;
2956 2975
2976 img_width = bm.width;
2977 img_height = bm.height;
2957 for( i = bm.height-1; i >= 0; i-- ) 2978 for( i = bm.height-1; i >= 0; i-- )
2958 { 2979 {
2959 rb->memmove( save_buffer+i*COLS, save_buffer+i*bm.width, 2980 rb->memmove( save_buffer+i*COLS, save_buffer+i*bm.width,
@@ -2970,9 +2991,15 @@ static int load_bitmap( const char *file )
2970static int save_bitmap( char *file ) 2991static int save_bitmap( char *file )
2971{ 2992{
2972 struct bitmap bm; 2993 struct bitmap bm;
2973 bm.data = (char*)save_buffer; 2994 int i;
2974 bm.height = ROWS; 2995 for(i = 0; i < img_height; i++)
2975 bm.width = COLS; 2996 {
2997 rb->memcpy( buffer.clipboard+i*img_width, save_buffer+i*COLS,
2998 sizeof( fb_data )*img_width );
2999 }
3000 bm.data = (char*)buffer.clipboard;
3001 bm.height = img_height;
3002 bm.width = img_width;
2976 bm.format = FORMAT_NATIVE; 3003 bm.format = FORMAT_NATIVE;
2977 return save_bmp_file( file, &bm ); 3004 return save_bmp_file( file, &bm );
2978} 3005}