Image Zoom In/out Sample. This program uses GraphicsFramework library and GP2Y0A21YK sensor. Please use distance sensor in the range of 10-30cm.
Dependencies: GR-PEACH_video GraphicsFramework R_BSP mbed-rtos mbed
Fork of RGA_HelloWorld by
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 #define ZOOM_SRC_CENTER_X IMAGE_WIDTH_ZOOM_FUNC / 2 00026 #define ZOOM_SRC_CENTER_Y IMAGE_HEIGHT_ZOOM_FUNC / 2 00027 00028 Canvas2D_ContextClass canvas2d; 00029 00030 void Set_RGAObject(frame_buffer_t* frmbuf_info) { 00031 errnum_t err; 00032 Canvas2D_ContextConfigClass config; 00033 00034 config.frame_buffer = frmbuf_info; 00035 canvas2d = R_RGA_New_Canvas2D_ContextClass(config); 00036 err = R_OSPL_GetErrNum(); 00037 if (err != 0) { 00038 printf("Line %d, error %d\n", __LINE__, err); 00039 while (1); 00040 } 00041 } 00042 00043 void RGA_Func_Zoom(frame_buffer_t* frmbuf_info, int src_height_pos) { 00044 /* Clear */ 00045 canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height); 00046 /* Zoom out */ 00047 canvas2d.drawImage(Landscape_wide_jpg_File, 00048 /* src X */ ZOOM_SRC_CENTER_X - (src_height_pos * IMG_DRAW_WIDTH / IMG_DRAW_HEIGHT), 00049 /* src Y */ ZOOM_SRC_CENTER_Y - src_height_pos, 00050 /* src W */ src_height_pos * 2 * IMG_DRAW_WIDTH / IMG_DRAW_HEIGHT, 00051 /* src H */ src_height_pos * 2, 00052 /* dst */ 10, 10, IMG_DRAW_WIDTH, IMG_DRAW_HEIGHT); 00053 00054 /* Complete drawing */ 00055 R_GRAPHICS_Finish(canvas2d.c_LanguageContext); 00056 }
Generated on Fri Jul 22 2022 17:36:14 by 1.7.2