Image rotation Sample. This program uses GraphicsFramework library and L3GD20 sensor.

Dependencies:   GR-PEACH_video GraphicsFramework L3GD20 R_BSP 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 #include "Images/BinaryImage_RZ_A1H.h"
00024 
00025 Canvas2D_ContextClass canvas2d;
00026 
00027 void Set_RGAObject(frame_buffer_t* frmbuf_info) {
00028     errnum_t err;
00029     Canvas2D_ContextConfigClass config;
00030 
00031     config.frame_buffer = frmbuf_info;
00032     canvas2d = R_RGA_New_Canvas2D_ContextClass(config);
00033     err = R_OSPL_GetErrNum();
00034     if (err != 0) {
00035         printf("Line %d, error %d\n", __LINE__, err);
00036         while (1);
00037     }
00038 }
00039 
00040 void RGA_Func_Rotation(frame_buffer_t* frmbuf_info, graphics_matrix_float_t image_angle) {
00041     /* Rotate the image */
00042     /* Clear */
00043     canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height);
00044 
00045     /* Move to drawing position */
00046     canvas2d.translate((155 + (IMG_DRAW_WIDTH / 2)), (73 + (IMG_DRAW_HEIGHT / 2)));
00047 
00048     /* Rotate */
00049     canvas2d.rotate(image_angle * (3.14159 / 180));
00050 
00051     /* Move to center to rotate */
00052     canvas2d.translate((-IMG_DRAW_WIDTH / 2), (-IMG_DRAW_HEIGHT / 2));
00053     canvas2d.drawImage(Flower_jpg_File, 0, 0);
00054     canvas2d.setTransform(1, 0, 0, 1, 0, 0);
00055 
00056     /* Complete drawing */
00057     R_GRAPHICS_Finish(canvas2d.c_LanguageContext);
00058 }