GUI_BITMAP位图转换的问题。求大神解答

fanqieci 2013-01-10 11:11:49
现在在学习gui。有关于位图转换的一块。我用uC-GUI-BitmapConvert.exe进行位图转换,转换后得到一个数组加一个结构体。结构体如下:
GUI_CONST_STORAGE GUI_BITMAP bmbutterfly = {
48, /* XSize */
48, /* YSize */
96, /* BytesPerLine */
16, /* BitsPerPixel */
(unsigned char *)acbutterfly, /* Pointer to picture data */
NULL /* Pointer to palette */
,GUI_DRAW_BMP565
};
接着我就把这个数组和结构体放到我的keil工程中。烧写进去之后发现是白色的。跟踪发现我的GUI_DRAWBITMAP函数有问题。
void GUI_DrawBitmap(const GUI_BITMAP GUI_UNI_PTR * pBitmap, int x0, int y0) {
#if (GUI_WINSUPPORT)
GUI_RECT r;
#endif
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x0,y0);
r.x1 = (r.x0 = x0) + pBitmap->XSize-1;
r.y1 = (r.y0 = y0) + pBitmap->YSize-1;
WM_ITERATE_START(&r) {
#endif
GL_DrawBitmap(pBitmap, x0, y0);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}

void GL_DrawBitmap(const GUI_BITMAP GUI_UNI_PTR * pBitmap, int x0, int y0) {
GUI_DRAWMODE PrevDraw;
const GUI_LOGPALETTE GUI_UNI_PTR * pPal;
pPal = pBitmap->pPal;
PrevDraw = GUI_SetDrawMode(0); /* No Get... at this point */
GUI_SetDrawMode((pPal && pPal->HasTrans) ? (PrevDraw|GUI_DRAWMODE_TRANS) : PrevDraw &(~GUI_DRAWMODE_TRANS));
if (pBitmap->pMethods) {
#if GUI_COMPILER_SUPPORTS_FP /* Do not support this on VERY simple chips and compilers */
pBitmap->pMethods->pfDraw(x0, y0, pBitmap->XSize ,pBitmap->YSize, (U8 const *)pBitmap->pData, pBitmap->pPal, 1, 1);
#endif
} else {
const LCD_PIXELINDEX* pTrans;
pTrans = LCD_GetpPalConvTable(pBitmap->pPal);
if (!pTrans) {
pTrans = (pBitmap->BitsPerPixel != 1) ? NULL : &LCD_BKCOLORINDEX;
}
LCD_DrawBitmap( x0,y0
,pBitmap->XSize ,pBitmap->YSize
,1,1
,pBitmap->BitsPerPixel
,pBitmap->BytesPerLine
,pBitmap->pData
,pTrans);
}
GUI_SetDrawMode(PrevDraw);
}


void LCD_DrawBitmap(int x0, int y0, int xsize, int ysize, int xMul, int yMul,
int BitsPerPixel, int BytesPerLine,
const U8 GUI_UNI_PTR * pPixel, const LCD_PIXELINDEX* pTrans)
{
U8 Data = 0;
int x1, y1;
/* Handle rotation if necessary */
#if GUI_SUPPORT_ROTATION
if (GUI_pLCD_APIList) {
GUI_pLCD_APIList->pfDrawBitmap(x0, y0, xsize, ysize, xMul, yMul, BitsPerPixel, BytesPerLine, pPixel, pTrans);
return;
}
#endif
/* Handle the optional Y-magnification */
y1 = y0 + ysize - 1;
x1 = x0 + xsize - 1;
/* Handle BITMAP without magnification */
if ((xMul | yMul) == 1) {
int Diff;
/* Clip y0 (top) */
Diff = GUI_Context.ClipRect.y0 - y0;

//看不懂这里的GUI_context是什么,在这Diff就变成了100,然后ysize就变成了-50,就返回了。不懂啊不懂啊。我也是个新手,很多初始化都不会写。就直接拿了别人的工程。可是我实现GUI内部图形操作都没问题,像画圆线,点,什么颜色都有,gui_font,gui_color,gui_core等等都已经包括在工程了。是不是有简单点的实现这种位图移植的函数啊。你们都是怎么移植的呢?求大神解答,最好给个工程。或者贴个成功的例子。




if (Diff > 0) {
ysize -= Diff;
if (ysize <= 0) {
return;
}
y0 = GUI_Context.ClipRect.y0;
#if GUI_SUPPORT_LARGE_BITMAPS /* Required only for 16 bit CPUs if some bitmaps are >64kByte */
pPixel += (U32) Diff * (U32) BytesPerLine;
#else
pPixel += (unsigned)Diff * (unsigned)BytesPerLine;
#endif
}
/* Clip y1 (bottom) */
Diff = y1 - GUI_Context.ClipRect.y1;
if (Diff > 0) {
ysize -= Diff;
if (ysize <= 0) {
return;
}
}
/* Clip right side */
Diff = x1 - GUI_Context.ClipRect.x1;
if (Diff > 0) {
xsize -= Diff;
}
/* Clip left side ... (The difficult side ...) */
Diff = 0;
if (x0 < GUI_Context.ClipRect.x0) {
Diff = GUI_Context.ClipRect.x0 - x0;
xsize -= Diff;
switch (BitsPerPixel) {
case 1:
pPixel+= (Diff>>3); x0 += (Diff>>3)<<3; Diff &=7;
break;
case 2:
pPixel+= (Diff>>2); x0 += (Diff>>2)<<2; Diff &=3;
break;
case 4:
pPixel+= (Diff>>1); x0 += (Diff>>1)<<1; Diff &=1;
break;
case 8:
pPixel+= Diff; x0 += Diff; Diff=0;
break;
case 16:
pPixel+= (Diff<<1); x0 += Diff; Diff=0;
break;
}
}
if (xsize <=0) {
return;
}
LCDDEV_L0_DrawBitmap (x0,y0, xsize, ysize, BitsPerPixel, BytesPerLine, pPixel, Diff, pTrans);
} else {
/**** Handle BITMAP with magnification ***/
int x,y;
int yi;
int Shift = 8-BitsPerPixel;
for (y=y0, yi=0; yi<ysize; yi++, y+= yMul, pPixel+=BytesPerLine) {
int yMax = y+yMul-1;
/* Draw if within clip area (Optimization ... "if" is not required !) */
if ((yMax >= GUI_Context.ClipRect.y0) && (y <= GUI_Context.ClipRect.y1)) {
int BitsLeft =0;
int xi;
const U8 GUI_UNI_PTR * pDataLine = pPixel;
for (x=x0, xi=0; xi<xsize; xi++, x+=xMul) {
U8 Index;
if (!BitsLeft) {
Data = *pDataLine++;
BitsLeft =8;
}
Index = Data>>Shift;
Data <<= BitsPerPixel;
BitsLeft -= BitsPerPixel;
if (Index || ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) ==0)) {
LCD_PIXELINDEX OldColor = LCD_COLORINDEX;
if (pTrans) {
LCD_COLORINDEX = *(pTrans+Index);
} else {
LCD_COLORINDEX = Index;
}
LCD_FillRect(x,y, x+xMul-1, yMax);
LCD_COLORINDEX = OldColor;
}
}
}
}
}
}
...全文
620 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bao605424093 2013-06-26
  • 打赏
  • 举报
回复
引用 3 楼 u010214558 的回复:
楼主 uC-GUI-BitmapConvert.exe 能不能给发一份啊 940314812@qq.com谢谢楼主啊 楼主现在应该学完了吧 我找的比较好的介绍ucgui http://wiki.emsym.com/wiki/Graphical_User_Interface
楼主 过了河。还鸟你啊
dd940314812 2013-06-06
  • 打赏
  • 举报
回复
楼主 uC-GUI-BitmapConvert.exe 能不能给发一份啊 940314812@qq.com谢谢楼主啊 楼主现在应该学完了吧 我找的比较好的介绍ucgui http://wiki.emsym.com/wiki/Graphical_User_Interface
fanqieci 2013-01-10
  • 打赏
  • 举报
回复
还有学习gui的时候发现视窗这块有点难懂啊。有没有这方面的电子书可以介绍下。我看的GUI中文手册讲的东西太少了。关于这方面的电子书都好少啊。
fanqieci 2013-01-10
  • 打赏
  • 举报
回复
我用的板子是周立功的lpc1788.板子没有跑系统。

6,125

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 硬件设计
社区管理员
  • 硬件设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧