Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
pictLIB.cpp
00001 #include "mbed.h" 00002 #include "pictLIB.h" 00003 00004 PICTLIB::PICTLIB(int _dsp_x,int _dsp_y) 00005 { 00006 dsp_x = _dsp_x; 00007 dsp_y = _dsp_y; 00008 dsp_center_x = ((float)dsp_x - 1) / 2.0; 00009 dsp_center_y = ((float)dsp_y - 1) / 2.0; 00010 pi = 3.14159265358979323846; 00011 } 00012 00013 void PICTLIB::scroll(char* in_pic, char* out_pic) 00014 { 00015 for(int y1 = 0 ; y1 < dsp_y ; y1++) 00016 { 00017 for(int x1 = 0 ; x1 < dsp_x ; x1++) 00018 { 00019 int y2 = y1+1; 00020 if( y2 >= dsp_y ) y2 -= dsp_y; 00021 out_pic[(y2 * dsp_y) + x1] = in_pic[(y1 *dsp_y) + x1]; 00022 } 00023 } 00024 for(int x1 = 0 ; x1 < dsp_x ; x1++) 00025 { 00026 out_pic[(0 * dsp_y) + x1] = in_pic[((dsp_y-1) *dsp_y) + x1]; 00027 } 00028 } 00029 00030 void PICTLIB::rotation(float rad, char* in_pic, char* out_pic) 00031 { 00032 rad = rad*(pi/180.0); 00033 00034 memset( out_pic , 0 , 16*16 ); 00035 00036 float cos_f = cos(-rad); 00037 float sin_f = sin(-rad); 00038 00039 for(int y1 = 0 ; y1 < dsp_y ; y1++) 00040 { 00041 for(int x1 = 0 ; x1 < dsp_x ; x1++) 00042 { 00043 float x2f = ((float)x1-dsp_center_x) * cos_f - ((float)y1-dsp_center_y) * sin_f + dsp_center_x; 00044 float y2f = ((float)x1-dsp_center_x) * sin_f + ((float)y1-dsp_center_y) * cos_f + dsp_center_y; 00045 int x2 = (int)(x2f + 0.5); 00046 int y2 = (int)(y2f + 0.5); 00047 00048 if( x2 >= 0 && x2 < dsp_x && y2 >= 0 && y2 < dsp_y ) { 00049 out_pic[(y2 * dsp_y) + x2] = in_pic[(y1 *dsp_y) + x1]; 00050 } 00051 00052 } 00053 } 00054 00055 }
Generated on Tue Jul 12 2022 20:04:43 by
