?? gfx_drawcontrol.c.svn-base
字號:
} else if (isJpeg(g_bitmaps[bmpindex].path)) { status = load_jpeg(pRua, &g_bitmaps[bmpindex], bmpsize); } else { status = load_gif(pRua, &g_bitmaps[bmpindex], bmpsize); } if (RMFAILED(status) || g_bitmaps[bmpindex].bmp.uiDataSize == 0) { RMDBGLOG((GFXDBG, "Error %s while loading %s \n", RMstatusToString(status), g_bitmaps[bmpindex].path)); RMMemset(&g_bitmaps[bmpindex], '\0', sizeof(g_bitmaps[bmpindex])); return status; } return status;}void ResetNonBackgroundBuffers(){ RMuint8 i; RMuint32 usedbuffer = 0; RMEnterCriticalSection(g_cs); for (i = 1; i < MAX_BITMAPS; i++) { if (g_bitmaps[i].path[0] != '\0') { usedbuffer += g_bitmaps[i].bmp.uiDataSize; // clear bmp buffer RMMemset(&g_bitmaps[i], 0, sizeof(RMbitmapdata)); } else break; } ResetUsedBuffer(usedbuffer); RMLeaveCriticalSection(g_cs);}RMstatus GetBitmapIndex(struct RUA *pRua, RMascii* path, RMuint8 *bmpindex, RMbool attemptReload){ RMuint8 i; RMstatus status; RMuint32 bmpsize = 0; RMuint8 index; RMEnterCriticalSection(g_cs); // check if we already have the bitmap data from index 1 since 0 is reserved to background image for (i = 1; i < MAX_BITMAPS; i++) { if (g_bitmaps[i].path[0] != '\0') { if (RMCompareAscii(g_bitmaps[i].path, path) && g_bitmaps[i].charwidth == 0) { *bmpindex = i; UpdateCache(i); RMLeaveCriticalSection(g_cs); return RM_OK; } // not loaded continue; } else { RMCopyAscii(g_bitmaps[i].path, path); g_bitmaps[i].charwidth = 0; *bmpindex = i; status = LoadImage(pRua, i, &bmpsize); // check if not background file and try loading again by // resetting used bitmap buffers one at the time if (status == RM_FATALOUTOFMEMORY) { status = FindFreeSpace(bmpsize, &index); { RMCopyAscii(g_bitmaps[index].path, path); g_bitmaps[index].charwidth = 0; *bmpindex = index; status = LoadImage(pRua, index, &bmpsize); } } RMLeaveCriticalSection(g_cs); return status; } } RMLeaveCriticalSection(g_cs); // more than MAX_BITMAPS!!!! return RM_ERROR;}// background is stored at index 0RMstatus LoadPageBackground(struct RUA *pRua, RMascii* path){ // check if we already have the bitmap data // printf("%s\n%s\n", path, g_bitmaps[0].path); if (RMCompareAscii(g_bitmaps[0].path, path)) { return RM_OK; } else { RMstatus status; RMuint32 bmpsize = 0; RMEnterCriticalSection(g_cs); RMCopyAscii(g_bitmaps[0].path, path); g_bitmaps[0].isBackground = TRUE; printf("load background\n"); status = LoadImage(pRua, 0, &bmpsize); UpdateCache(0); RMLeaveCriticalSection(g_cs); return status; } return RM_ERROR;}RMstatus SetTextPalette(struct RUA *pRua, RMuint32 foregroundcolor, RMuint32 backgroundcolor, RMbool transparentbkgnd){ struct GFXEngine_Palette_1BPP_type palette_param; RMstatus status; palette_param.Palette[0] = foregroundcolor; palette_param.Palette[1] = (transparentbkgnd ? backgroundcolor & 0xffffffff : 0); palette_param.SurfaceID = GFX_SURFACE_ID_Y; if (CompareTextPalette(&palette_param)) { // printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> skipping TEXT palette\n"); return RM_OK; } // printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> setting TEXT palette\n"); status = GFX1BPPPaletteProperty(pRua, &palette_param); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error sending command set palette\n")); RMMemcpy(&g_lastpal, &palette_param, sizeof(palette_param)); g_last_palbpp = 1; return status;}RMstatus SetTextColorFormat(struct RUA *pRua){ struct GFXEngine_ColorFormat_type format_param; RMstatus status; // color format format_param.SurfaceID = GFX_SURFACE_ID_Y; format_param.MainMode = EMhwlibColorMode_LUT_1BPP; format_param.SubMode = EMhwlibColorFormat_32BPP; status = GFXColorFormatProperty(pRua, &format_param); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting color format parameters\n")); return status;}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 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; } status = SetInputSurface(pRua, bkmode, g_bitmaps[parentindex].pBmpAddr, g_bitmaps[parentindex].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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -