📄 gfx_drawcontrol.c
字号:
RMstatus SetPalette(struct RUA *pRua, RMuint8 alpha, RMuint8 bmpindex, RMuint32 surfaceID){ RMstatus status = RM_OK; RMuint32 i; RMuint8 bpp = g_bitmaps[bmpindex].bmp.uiNbBitPerPixel; RMuint32 uiNbLUTColor = g_bitmaps[bmpindex].bmp.uiPaletteSize / sizeof(struct tagRMRGBQuad); struct GFXEngine_Palette_1BPP_type palette1bpp_param; struct GFXEngine_Palette_2BPP_type palette2bpp_param; struct GFXEngine_Palette_4BPP_type palette4bpp_param; struct GFXEngine_Palette_8BPP_type palette8bpp_param; switch (bpp) { case 1: for (i = 0; i < uiNbLUTColor; i++) { struct tagRMRGBQuad *pQuad; pQuad = (struct tagRMRGBQuad*) (g_bitmaps[bmpindex].bmp.palette + i); palette1bpp_param.Palette[i] = alpha << 24 | pQuad->rgbRed << 16 | pQuad->rgbGreen << 8 | pQuad->rgbBlue; if (g_bitmaps[bmpindex].usetransparentcolor) if ((palette1bpp_param.Palette[i] & 0x00ffffff) == (g_bitmaps[bmpindex].transparentcolor & 0x00ffffff)) palette1bpp_param.Palette[i] = palette1bpp_param.Palette[i] & 0x00ffffff; } palette1bpp_param.SurfaceID = surfaceID; status = GFX1BPPPaletteProperty(pRua, &palette1bpp_param); break; case 2: for (i = 0; i < uiNbLUTColor; i++) { struct tagRMRGBQuad *pQuad; pQuad = (struct tagRMRGBQuad*) (g_bitmaps[bmpindex].bmp.palette + i); palette2bpp_param.Palette[i] = alpha << 24 | pQuad->rgbRed << 16 | pQuad->rgbGreen << 8 | pQuad->rgbBlue; if (g_bitmaps[bmpindex].usetransparentcolor) if ((palette2bpp_param.Palette[i] & 0x00ffffff) == (g_bitmaps[bmpindex].transparentcolor & 0x00ffffff)) palette2bpp_param.Palette[i] = palette2bpp_param.Palette[i] & 0x00ffffff; } palette2bpp_param.SurfaceID = surfaceID; status = GFX2BPPPaletteProperty(pRua, &palette2bpp_param); break; case 4: for (i = 0; i < uiNbLUTColor; i++) { struct tagRMRGBQuad *pQuad; pQuad = (struct tagRMRGBQuad*) (g_bitmaps[bmpindex].bmp.palette + i); palette4bpp_param.Palette[i] = alpha << 24 | pQuad->rgbRed << 16 | pQuad->rgbGreen << 8 | pQuad->rgbBlue; if (g_bitmaps[bmpindex].usetransparentcolor) if ((palette4bpp_param.Palette[i] & 0x00ffffff) == (g_bitmaps[bmpindex].transparentcolor & 0x00ffffff)) palette4bpp_param.Palette[i] = palette4bpp_param.Palette[i] & 0x00ffffff; } palette4bpp_param.SurfaceID = surfaceID; status = GFX4BPPPaletteProperty(pRua, &palette4bpp_param); break; case 8: for (i = 0; i < uiNbLUTColor; i++) { struct tagRMRGBQuad *pQuad; pQuad = (struct tagRMRGBQuad*) (g_bitmaps[bmpindex].bmp.palette + i); palette8bpp_param.Palette[i] = alpha << 24 | pQuad->rgbRed << 16 | pQuad->rgbGreen << 8 | pQuad->rgbBlue; if (g_bitmaps[bmpindex].usetransparentcolor) if ((palette8bpp_param.Palette[i] & 0x00ffffff) == (g_bitmaps[bmpindex].transparentcolor & 0x00ffffff)) { palette8bpp_param.Palette[i] = palette8bpp_param.Palette[i] & 0x00ffffff; } } if (CompareBitmapPalette(&palette8bpp_param)) { // printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> skipping palette %d bpp\n", bpp); return RM_OK; } // printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> setting palette %d bpp\n", bpp); palette8bpp_param.SurfaceID = surfaceID; status = GFX8BPPPaletteProperty(pRua, &palette8bpp_param); RMMemcpy(&g_lastpal, &palette8bpp_param, sizeof(palette4bpp_param)); g_last_palbpp = 8; break; default: status = RM_ERROR; break; } if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error sending command set palette\n")); return status;}RMstatus DrawBitmapBlendBack(struct RUA *pRua, RMint32 x, RMint32 y, RMuint32 transparentcolor, RMbool usetransparentcolor, RMuint8 alpha, RMuint8 bmpindex, RMbool blend, RMuint8 parentindex){ RMstatus status = RM_OK; struct GFXEngine_BlendRectangles_type blend_param; RMuint32 width, height; RMuint32 mainmode, bkmode; RMuint32 startaddr; width = g_bitmaps[bmpindex].bmp.uiWidth; height = g_bitmaps[bmpindex].bmp.uiHeight; //verify bitmap fits within surface if ((RMuint32) (width + x) > gdata.osdWidth || (RMuint32) (height + y) > gdata.osdHeight) { RMDBGLOG((ENABLE, "GOES OUTSIDE SURFACE BOUNDARIES\n", g_bitmaps[bmpindex].path)); return RM_ERROR; } // setup input Y surface // set transparency g_bitmaps[bmpindex].transparentcolor = transparentcolor; g_bitmaps[bmpindex].usetransparentcolor = usetransparentcolor; // fill the palette if (g_bitmaps[bmpindex].bmp.uiNbBitPerPixel <= 8) SetPalette(pRua, alpha, bmpindex, GFX_SURFACE_ID_Y); // color format switch (g_bitmaps[bmpindex].bmp.uiNbBitPerPixel) { case 1: mainmode = EMhwlibColorMode_LUT_1BPP; break; case 2: mainmode = EMhwlibColorMode_LUT_2BPP; break; case 4: mainmode = EMhwlibColorMode_LUT_4BPP; break; case 8: mainmode = EMhwlibColorMode_LUT_8BPP; break; default: mainmode = EMhwlibColorMode_TrueColor; break; } startaddr = g_bitmaps[bmpindex].pBmpAddr; if (g_bitmaps[parentindex].pBmpAddr == 0) return RM_ERROR; // setup X surface -- background // color format bkmode = EMhwlibColorMode_TrueColor; status = SetInputSurface(pRua, bkmode, gdata.backBuffer.baseAddr, g_bitmaps[0].bmp.uiWidth, GFX_SURFACE_ID_X); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting surface parameters\n")); // setup Y surface // color format -- set above status = SetInputSurface(pRua, mainmode, startaddr, width, GFX_SURFACE_ID_Y); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting surface parameters\n")); blend_param.Src1X = 0; // YZ blend_param.Src1Y = 0; blend_param.Src2X = x; // X blend_param.Src2Y = y; blend_param.DstX = x; blend_param.DstY = y; blend_param.Width = width; blend_param.Height = height; blend_param.SaturateAlpha = FALSE; status = GFXBlendRectanglesProperty(pRua, &blend_param); return RM_OK;}RMstatus HideLoadCursor(struct RUA *pRua, RMPageObject* page, RMAnimationObject* anime, RMbool bCenter){ RMstatus status = RM_OK; RMuint8 bmpindex; status = SetOutputSurfaceBuffer(pRua, gdata.backBuffer.baseAddr, gdata.osdWidth); if (RMFAILED(status)) return status; status = GetBitmapIndex(pRua, anime->icon, &bmpindex, TRUE); if (RMFAILED(status)) return status; if(page) { GFXLib_rect rect; rect.x = anime->x; if(bCenter) rect.y = gdata.osdHeight / 2; else rect.y = anime->y; rect.width = anime->icon_width; rect.height = g_bitmaps[bmpindex].bmp.uiHeight; DrawPageRect(pRua, page, &rect); } else { Fill(pRua, anime->x, gdata.osdHeight / 2, anime->icon_width, g_bitmaps[bmpindex].bmp.uiHeight, 0x00FFFFFF); } return BitBlt(pRua);}RMstatus DrawLoadCursor(struct RUA *pRua, RMPageObject* page, RMAnimationObject* anime, RMbool bCenter){ RMstatus status = RM_OK; struct GFXEngine_BlendRectangles_type blend_param;// struct GFXEngine_MoveReplaceRectangle_type move_param; RMuint32 width = 0, height = 0; RMuint32 mainmode, bkmode; RMuint32 startaddr = 0; RMuint8 maxframe, bmpindex; status = SetOutputSurfaceBuffer(pRua, gdata.backBuffer.baseAddr, gdata.osdWidth); if (RMFAILED(status)) return status; status = GetBitmapIndex(pRua, anime->icon, &bmpindex, TRUE); if (RMFAILED(status)) return status;// printf("animate\n"); maxframe = g_bitmaps[bmpindex].bmp.uiWidth / anime->icon_width; width = anime->icon_width; height = g_bitmaps[bmpindex].bmp.uiHeight; //verify bitmap fits within surface if ((RMuint32) (width + anime->x) > gdata.osdWidth || (RMuint32) (height + anime->y) > gdata.osdHeight) { RMDBGLOG((ENABLE, "GOES OUTSIDE SURFACE BOUNDARIES\n", g_bitmaps[bmpindex].path)); return RM_ERROR; } // setup input Y surface // set transparency g_bitmaps[bmpindex].transparentcolor = 0; g_bitmaps[bmpindex].usetransparentcolor = 0; // fill the palette if (g_bitmaps[bmpindex].bmp.uiNbBitPerPixel <= 8) SetPalette(pRua, 0xFF, bmpindex, GFX_SURFACE_ID_Y); // color format switch (g_bitmaps[bmpindex].bmp.uiNbBitPerPixel) { case 1: mainmode = EMhwlibColorMode_LUT_1BPP; break; case 2: mainmode = EMhwlibColorMode_LUT_2BPP; break; case 4: mainmode = EMhwlibColorMode_LUT_4BPP; break; case 8: mainmode = EMhwlibColorMode_LUT_8BPP; break; default: mainmode = EMhwlibColorMode_TrueColor; break; } anime->cur_frame ++; if(anime->cur_frame >= maxframe) anime->cur_frame = 0; startaddr = g_bitmaps[bmpindex].pBmpAddr; if (g_bitmaps[0].pBmpAddr == 0) return RM_ERROR; // setup X surface -- background // color format switch (g_bitmaps[0].bmp.uiNbBitPerPixel) { case 1: bkmode = EMhwlibColorMode_LUT_1BPP; break; case 2: bkmode = EMhwlibColorMode_LUT_2BPP; break; case 4: bkmode = EMhwlibColorMode_LUT_4BPP; break; case 8: bkmode = EMhwlibColorMode_LUT_8BPP; break; default: bkmode = EMhwlibColorMode_TrueColor; break; } RMEnterCriticalSection(g_cs_media); if(page == NULL) { Fill(pRua, anime->x, gdata.osdHeight / 2, width, height, 0x00FFFFFF); status = SetInputSurface(pRua, bkmode, gdata.backBuffer.baseAddr, g_bitmaps[0].bmp.uiWidth, GFX_SURFACE_ID_X); } else { status = SetInputSurface(pRua, bkmode, g_bitmaps[0].pBmpAddr, g_bitmaps[0].bmp.uiWidth, GFX_SURFACE_ID_X); } if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting surface parameters\n")); // setup Y surface // color format -- set above status = SetInputSurface(pRua, mainmode, startaddr, g_bitmaps[bmpindex].bmp.uiWidth, GFX_SURFACE_ID_Y); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting surface parameters\n")); blend_param.Src1X = anime->cur_frame * anime->icon_width; // YZ blend_param.Src1Y = 0; blend_param.Src2X = anime->x; // X if(page) { if(bCenter) { blend_param.Src2Y = gdata.osdHeight / 2; } else { blend_param.Src2Y = anime->y; } }else blend_param.Src2Y = gdata.osdHeight / 2; blend_param.DstX = anime->x; if(page) { if(bCenter) { blend_param.DstY = gdata.osdHeight / 2; } else { blend_param.DstY = anime->y; } }else blend_param.DstY = gdata.osdHeight / 2; blend_param.Width = width; blend_param.Height = height; blend_param.SaturateAlpha = FALSE; status = GFXBlendRectanglesProperty(pRua, &blend_param); RMLeaveCriticalSection(g_cs_media);// if(page) BitBlt(pRua); return RM_OK;}RMstatus DrawBitmap(struct RUA *pRua, RMint32 x, RMint32 y, RMuint32 transparentcolor, RMbool usetransparentcolor, RMuint8 alpha, RMuint8 bmpindex, RMbool blend, RMuint8 parentindex){ RMstatus status = RM_OK; struct GFXEngine_BlendRectangles_type blend_param; struct GFXEngine_MoveReplaceRectangle_type move_param; RMuint32 width, height; RMuint32 mainmode, bkmode; RMuint32 startaddr; width = g_bitmaps[bmpindex].bmp.uiWidth; height = g_bitmaps[bmpindex].bmp.uiHeight; //verify bitmap fits within surface if ((RMuint32) (width + x) > gdata.osdWidth || (RMuint32) (height + y) > gdata.osdHeight) { RMDBGLOG((ENABLE, "GOES OUTSIDE SURFACE BOUNDARIES\n", g_bitmaps[bmpindex].path)); return RM_ERROR; } // setup input Y surface // set transparency g_bitmaps[bmpindex].transparentcolor = transparentcolor; g_bitmaps[bmpindex].usetransparentcolor = usetransparentcolor; // fill the palette if (g_bitmaps[bmpindex].bmp.uiNbBitPerPixel <= 8) SetPalette(pRua, alpha, bmpindex, GFX_SURFACE_ID_Y); // color format switch (g_bitmaps[bmpindex].bmp.uiNbBitPerPixel) { case 1: mainmode = EMhwlibColorMode_LUT_1BPP; break; case 2: mainmode = EMhwlibColorMode_LUT_2BPP; break; case 4: mainmode = EMhwlibColorMode_LUT_4BPP; break; case 8: mainmode = EMhwlibColorMode_LUT_8BPP; break; default: mainmode = EMhwlibColorMode_TrueColor; break; } startaddr = g_bitmaps[bmpindex].pBmpAddr; if (bmpindex == 0 || blend == FALSE) { // RMuint16 i; RMASSERT(startaddr != 0); // setup Y surface status = SetInputSurface(pRua, mainmode, startaddr, width, GFX_SURFACE_ID_Y); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting surface parameters\n")); // for(i = 0; i < x; i++){ move_param.SrcX = 0; move_param.SrcY = 0; move_param.AlphaX = 0; move_param.AlphaY = 0; move_param.DstX = x; // move_param.DstX = i; move_param.DstY = y; move_param.Width = width; move_param.Height = height; move_param.Merge = FALSE; status = GFXReplaceRectangleProperty(pRua, &move_param); // } return RM_OK; } if (g_bitmaps[parentindex].pBmpAddr == 0) return RM_ERROR; // setup X surface -- background // color format switch (g_bitmaps[parentindex].bmp.uiNbBitPerPixel) { case 1: bkmode = EMhwlibColorMode_LUT_1BPP; break; case 2: bkmode = EMhwlibColorMode_LUT_2BPP; break; case 4: bkmode = EMhwlibColorMode_LUT_4BPP; break; case 8: bkmode = EMhwlibColorMode_LUT_8BPP; break; default: bkmode = EMhwlibColorMode_TrueColor; break; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -