@@ -20,13 +20,16 @@ void flip_NNOptimized_AllowOutOfScreen(SDL_Surface *src_surface, SDL_Surface *ds
2020 int i , j ;
2121
2222 /* Compute padding for centering when out of bounds */
23- int y_padding = (SCREEN_VERTICAL_SIZE - new_h )/2 ;
24- int x_padding = 0 ;
23+ int x_padding = 0 , y_padding = 0 ;
24+ if (h2 > SCREEN_HORIZONTAL_SIZE ){
25+ y_padding = (SCREEN_VERTICAL_SIZE - new_h )/2 ;
26+ }
2527 if (w2 > SCREEN_HORIZONTAL_SIZE ){
2628 x_padding = (w2 - SCREEN_HORIZONTAL_SIZE )/2 + 1 ;
2729 }
2830 int x_padding_ratio = x_padding * w1 /w2 ;
2931
32+ /* Copy pixels NN */
3033 for (i = 0 ;i < h2 ;i ++ )
3134 {
3235 if (i >=SCREEN_VERTICAL_SIZE ){
@@ -52,6 +55,8 @@ void flip_NNOptimized_AllowOutOfScreen(SDL_Surface *src_surface, SDL_Surface *ds
5255
5356int launch_prod_screen_showImage (int argc , char * argv []){
5457 SDL_Event event ;
58+ SDL_Surface * text_surface = NULL ;
59+ SDL_Rect text_pos ;
5560 int res = 0 ;
5661 int stop_menu_loop = 0 ;
5762
@@ -64,14 +69,54 @@ int launch_prod_screen_showImage(int argc, char *argv[]){
6469 exit (1 );
6570 }
6671
72+ /* Fill screen white */
73+ SDL_FillRect (hw_surface , NULL , SDL_MapRGB (hw_surface -> format , bg_color .r , bg_color .g , bg_color .b ));
74+
75+ /* Write Title */
76+ text_surface = TTF_RenderText_Shaded (font_info , "SCAN & PRINT" , text_color , bg_color );
77+ int height_title = text_surface -> h ;
78+ text_pos .x = hw_surface -> w /2 - text_surface -> w /2 ;
79+ text_pos .y = 0 ;
80+ SDL_BlitSurface (text_surface , NULL , hw_surface , & text_pos );
81+ SDL_FreeSurface (text_surface );
82+
83+ /* Write:
84+ "L=FAIL"
85+ */
86+ SDL_Color red_color = {220 ,20 ,20 };
87+ text_surface = TTF_RenderText_Shaded (font_info , "L=FAIL" , red_color , bg_color );
88+ int height_buttons = text_surface -> h ;
89+ text_pos .x = X_PADDING ;
90+ text_pos .y = hw_surface -> h - text_surface -> h ;
91+ SDL_BlitSurface (text_surface , NULL , hw_surface , & text_pos );
92+ SDL_FreeSurface (text_surface );
93+
94+ /* Write:
95+ "R=OK"
96+ */
97+ SDL_Color green_color = {20 ,220 ,20 };
98+ text_surface = TTF_RenderText_Shaded (font_info , "R=DONE" , green_color , bg_color );
99+ text_pos .x = hw_surface -> w - text_surface -> w - X_PADDING ;
100+ text_pos .y = hw_surface -> h - text_surface -> h ;
101+ SDL_BlitSurface (text_surface , NULL , hw_surface , & text_pos );
102+ SDL_FreeSurface (text_surface );
67103
68104 /* Convert img to RGB565 */
69105 SDL_Surface * image_rgb565 = SDL_CreateRGBSurface (SDL_SWSURFACE , image -> w , image -> h , 16 , 0 , 0 , 0 , 0 );
70106 SDL_BlitSurface (image , NULL , image_rgb565 , NULL );
71107 SDL_FreeSurface (image );
108+
109+ /* Resize img */
110+ int new_img_height = hw_surface -> h - height_buttons - height_title ;
111+ int new_img_width = image -> w * new_img_height / image -> h ;
112+ SDL_Surface * image_rgb565_resized = SDL_CreateRGBSurface (SDL_SWSURFACE , new_img_width , new_img_height , 16 , 0 , 0 , 0 , 0 );
113+ flip_NNOptimized_AllowOutOfScreen (image_rgb565 , image_rgb565_resized , image_rgb565_resized -> w , image_rgb565_resized -> h );
114+ SDL_FreeSurface (image_rgb565 );
72115
73- /* Scale to fullscreen */
74- flip_NNOptimized_AllowOutOfScreen (image_rgb565 , hw_surface , hw_surface -> w , hw_surface -> h );
116+ /* Blit image */
117+ SDL_Rect pos_img = {(hw_surface -> w - image_rgb565_resized -> w )/2 , height_title , image_rgb565_resized -> w , image_rgb565_resized -> h };
118+ SDL_BlitSurface (image_rgb565_resized , NULL , hw_surface , & pos_img );
119+ SDL_FreeSurface (image_rgb565_resized );
75120
76121 /// -------- Main loop ---------
77122 while (!stop_menu_loop )
@@ -86,10 +131,17 @@ int launch_prod_screen_showImage(int argc, char *argv[]){
86131 case SDL_KEYDOWN :
87132 switch (event .key .keysym .sym )
88133 {
134+ case SDLK_m :
135+ stop_menu_loop = 1 ;
136+ res = ERROR_MANUAL_FAIL ;
137+ break ;
138+
139+ case SDLK_n :
89140 case SDLK_ESCAPE :
90141 stop_menu_loop = 1 ;
91142 res = 0 ;
92143 break ;
144+
93145 default :
94146 break ;
95147 }
0 commit comments