color:rgb(255,0,0)">SPGUI(Simple Powerfull Graphics User Interface)是使用简单、功能强大的嵌入式图形开发系统。主要为开发嵌入式LINUX图形窗口应用提供工具集。她具有美观友好的图形控件c;面向对像的编程接口c;多平台可移植性等特点SPGUI为设计运行于嵌入式设备c;个人电脑及工作站平台的图形窗口应用程序c;提供一个完整的开发平台。她的核心是为应用程序提供资源库及编译链接环境c;开发者使用SPGUI提供的资源及环境c;来开发自己的应用程序。SPGUI为应用程序设计者提供的资源包括:嵌入式图形引擎c;图形控件c;数据库引擎c;底层驱动封装c;常用数据结构封装及中文支持等
SPGUI是源码级高度可移植的,
目前经过本人的努力已经移植到window xp 使用vc 2005开发(可称作:模拟器),开发出来的程序只需要在嵌入式平台编译就可运行.
同时也扩展了如下功能.
图片支持 png ,gif, bmp,jpg
字库管理 freetype 矢量字库 ,fnt字库
压缩 zip
脚本 xml expat
窗口框架 : ems ui( 下个文章更新 )
ce:pre"> ce:pre">提供帮助:124736442@qq.com
言归正传.
先看效果图
之前
c="http://hi.csdn.net/attachment/201112/19/853768_1324287614sS3x.jpg" alt="" />
之后
c="http://hi.csdn.net/attachment/201112/19/853768_132428761322O2.jpg" alt="" />
高斯模糊class="tags" href="/tags/SuanFa.html" title=算法>算法 c源码.
颜色信息是565 可修改到 rgb888 argb 以及灰度的处理.
//---------------------------------------------------------------------------------
//ce:pre"> 124736442@qq.com
//
//
//图象的平滑(去噪声)、锐化
//
//
//---------------------------------------------------------------------------------
#include <mach/effect.h>
#include <mach/datatype.h>
enum EFFECT_TYPE{
ce:pre">SMOOTH_BOX = 0,
ce:pre">SMOOTH_GAUSS,
ce:pre">SHARPEN_LL
};
//template array
SINT32 Smooth_Box[10]={1,1,1,1,1,1,1,1,1,3};
SINT32 Smooth_Gauss[10]={1,2,1,2,4,2,1,2,1,4};
SINT32 Sharpen_Laplacian[10]={-1,-1,-1,-1,9,-1,-1,-1,-1,1};
SINT32 Bitmap_SmoothDeal(spBitmap_t *p,spRect_t *rect,int type)
{
ce:pre">SINT32 *tEffect = NULL;
ce:pre">UINT8 *stpos;
ce:pre">UINT16 *pbg;
ce:pre">int r,g,b,Index,row,col;
ce:pre">int x;int y;
ce:pre">UINT8 r1,g1,b1;
ce:pre">UINT32 colorref;
ce:pre">UINT32 sumcol;
ce:pre">switch(type)
ce:pre">{
ce:pre">case SMOOTH_BOX:
ce:pre">tEffect = Smooth_Box;
ce:pre">break;
ce:pre">case SMOOTH_GAUSS:
ce:pre">tEffect = Smooth_Gauss;
ce:pre">break;
ce:pre">case SHARPEN_LL:
ce:pre">tEffect = Sharpen_Laplacian;
ce:pre">break;
ce:pre">default:
ce:pre">return SP_FAIL;
ce:pre">}
ce:pre">stpos = (UINT8 *)( p->pData + (rect->x*p->bpl/p->width + rect->y*p->bpl) );
ce:pre">for(y = 1 ; y<rect->height-1;y++)
ce:pre">for( x = 1;x <rect->width-1;x++)
ce:pre">{
ce:pre">
ce:pre">r=0,g=0,b=0;
ce:pre">Index=0;
ce:pre">sumcol = 0 ;
ce:pre">for(col=-1;col<=1;col++)
ce:pre">{
ce:pre">pbg = (UINT16*)(stpos+(y+col)*p->bpl);
ce:pre">for(row=-1;row<=1;row++)
ce:pre">{ce:pre">
ce:pre">colorref=pbg[x+row];
ce:pre">RGB_FROM_RGB565(colorref,r1,g1,b1);
ce:pre">r+=r1*tEffect[Index];
ce:pre">g+=g1*tEffect[Index];
ce:pre">b+=b1*tEffect[Index];
ce:pre">Index++;
ce:pre">}
ce:pre">}
ce:pre">r>>=tEffect[Index];//调节亮度.
ce:pre">g>>=tEffect[Index];
ce:pre">b>>=tEffect[Index];
ce:pre">RGB565_FROM_RGB(colorref,r,g,b);
ce:pre">pbg[x] = (UINT16)colorref;
ce:pre">}
ce:pre">return SP_OK;
}
SINT32 effect_do(spBitmap_t *image,spRect_t *rect,SINT32 type)
{
ce:pre">spRect_t tRect;
ce:pre">if(image == NULL)
ce:pre">return SP_FAIL;
ce:pre">if(rect==NULL){
ce:pre">tRect.x = tRect.y = 0 ;
ce:pre">tRect.width = image->width;
ce:pre">tRect.height = image->height;
ce:pre">}
ce:pre">else
ce:pre">tRect = *rect;
ce:pre">//check rect
ce:pre">tRect.x = tRect.x <0 ?0:tRect.x;
ce:pre">tRect.y = tRect.y <0 ?0:tRect.y;
ce:pre">tRect.width = tRect.width >image->width ?image->width:tRect.width;
ce:pre">tRect.height = tRect.height >image->height?image->height:tRect.height;
ce:pre">//do effect
ce:pre">switch(type)
ce:pre">{
ce:pre">case SMOOTH_BOX:
ce:pre">case SMOOTH_GAUSS:
ce:pre">case SHARPEN_LL:
ce:pre">//return SP_OK;
ce:pre">Bitmap_SmoothDeal(image,&tRect,type);
ce:pre">break;
ce:pre">}
ce:pre">return SP_OK;
}