Tomo Yamanaka / Mbed 2 deprecated ImageScroll_Sample

Dependencies:   GR-PEACH_video GraphicsFramework R_BSP SI1143 mbed-rtos mbed

Fork of RGA_HelloWorld by Renesas

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rga_func.cpp Source File

rga_func.cpp

00001 /*
00002 Permission is hereby granted, free of charge, to any person obtaining a copy
00003 of this software and associated documentation files (the "Software"), to deal
00004 in the Software without restriction, including without limitation the rights
00005 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00006 copies of the Software, and to permit persons to whom the Software is
00007 furnished to do so, subject to the following conditions:
00008 
00009 The above copyright notice and this permission notice shall be included in
00010 all copies or substantial portions of the Software.
00011 
00012 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00013 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00014 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00015 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00016 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00018 THE SOFTWARE.
00019 */
00020 
00021 #include "mbed.h"
00022 #include "rga_func.h"
00023 
00024 Canvas2D_ContextClass canvas2d;
00025 
00026 void Set_RGAObject(frame_buffer_t* frmbuf_info) {
00027     errnum_t err;
00028     Canvas2D_ContextConfigClass config;
00029 
00030     config.frame_buffer = frmbuf_info;
00031     canvas2d = R_RGA_New_Canvas2D_ContextClass(config);
00032     err = R_OSPL_GetErrNum();
00033     if (err != 0) {
00034         printf("Line %d, error %d\n", __LINE__, err);
00035         while (1);
00036     }
00037 }
00038 
00039 void RGA_Func_DrawTopScreen(frame_buffer_t* frmbuf_info, const graphics_image_t* image) {
00040     canvas2d.drawImage((const graphics_image_t*)image, 0, 0);
00041 
00042     /* Complete drawing */
00043     R_GRAPHICS_Finish(canvas2d.c_LanguageContext);
00044 }
00045 
00046 void RGA_Func_Scroll(frame_buffer_t* frmbuf_info, const graphics_image_t* image_old, const graphics_image_t* image_new,
00047                      int direction, float32_t scroll) {
00048     canvas2d.drawImage((const graphics_image_t*)image_old, 0, 0);
00049 
00050     /* Scroll */
00051     switch (direction) {
00052         case DIREC_RIGHT:
00053             canvas2d.drawImage((const graphics_image_t*)image_new,
00054                                ((int)(frmbuf_info->width * scroll) - frmbuf_info->width) * 1, 0,
00055                                frmbuf_info->width, frmbuf_info->height);
00056             break;
00057         case DIREC_LEFT:
00058             canvas2d.drawImage((const graphics_image_t*)image_new,
00059                                ((int)(frmbuf_info->width * scroll) - frmbuf_info->width) * -1, 0,
00060                                frmbuf_info->width, frmbuf_info->height);
00061             break;
00062         case DIREC_UP:
00063             canvas2d.drawImage((const graphics_image_t*)image_new,
00064                                0, ((int)(frmbuf_info->height * scroll) - frmbuf_info->height) * -1, 
00065                                frmbuf_info->width, frmbuf_info->height);
00066             break;
00067         case DIREC_DOWN:
00068             canvas2d.drawImage((const graphics_image_t*)image_new,
00069                                0, ((int)(frmbuf_info->height * scroll) - frmbuf_info->height) * 1, 
00070                                frmbuf_info->width, frmbuf_info->height);
00071             break;
00072         default :
00073             break;
00074     }
00075 
00076     /* Complete drawing */
00077     R_GRAPHICS_Finish(canvas2d.c_LanguageContext);
00078 }
00079