|
本帖最后由 bl-2019 于 2019-10-22 19:28 编辑
static void _cbDialog(WM_MESSAGE * pMsg) {
const void * pData;
WM_HWIN hItem;
U32 FileSize;
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'Image'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
pData = _GetImageById(ID_IMAGE_0_IMAGE_0, &FileSize);
IMAGE_SetBMP(hItem, pData, FileSize);
// USER START (Optionally insert additional code for further widget initialization)
// USER END
break;
// USER START (Optionally insert additional message handling)
// USER END
case WM_PAINT:
GUI_DrawBitmapMag(&bmstart1, 100, 10, 3, 3);
GUI_DrawBitmap(&bmstart1, 200, 50);
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
发现一个奇怪的现象,红色的代码部分,也就是GUI_DrawBitmap不能显示图片,但是用GUI_DrawBitmapMag就可以显示图片这是为什么
并且我试验过不是放大后的图片遮住了,而且GUI_DrawBitmapMag(&bmstart1, 100, 10, 1, 1);只放大一倍也不能显示,最小要放大2倍,感觉好奇怪啊
下面时两个函数相关的代码
/*********************************************************************
*
* 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();
}
/*********************************************************************
*
* GL_DrawBitmap
*
* Purpose:
* Translates the external bitmap format into an internal
* format. This turned out to be necessary as the internal
* format is easier to create and more flexible for routines
* that draw text-bitmaps.
*/
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);
}
*/
/*********************************************************************
*
* GUI_DrawBitmapMag
*/
void GUI_DrawBitmapMag(const GUI_BITMAP GUI_UNI_PTR *pBitmap, int x0, int y0, int xMul, int yMul) {
GUI_DRAWMODE PrevDraw;
int xSize, ySize;
const GUI_LOGPALETTE GUI_UNI_PTR * pPal;
const LCD_PIXELINDEX* pTrans;
GUI_LOCK();
pPal = pBitmap->pPal;
xSize = pBitmap->XSize;
ySize = pBitmap->YSize;
pTrans = LCD_GetpPalConvTable(pPal);
if (!pTrans) {
pTrans = (pBitmap->BitsPerPixel != 1) ? NULL : &LCD_BKCOLORINDEX;
}
PrevDraw = GUI_SetDrawMode((pPal && pPal->HasTrans) ? GUI_DRAWMODE_TRANS : 0);
#if (GUI_WINSUPPORT)
WM_ADDORG(x0,y0);
{
GUI_RECT r;
r.x0 = x0;
r.x1 = x0 + xSize * xMul -1;
r.y0 = y0;
r.y1 = y0 + ySize * yMul -1;
WM_ITERATE_START(&r);
#endif
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, xMul, yMul);
#endif
} else {
LCD_DrawBitmap(x0, y0, xSize, ySize, xMul, yMul
,pBitmap->BitsPerPixel, pBitmap->BytesPerLine
,pBitmap->pData, pTrans);
}
#if (GUI_WINSUPPORT)
WM_ITERATE_END();
}
#endif
GUI_SetDrawMode(PrevDraw);
GUI_UNLOCK();
}
|
|