intOsdInit(int DeviceID) { int Status; /* Initialize the OSD instance */ OsdCfgPtr = XOSD_LookupConfig(DeviceID); Status = XOSD_CfgInitialize(&Osd, OsdCfgPtr,OsdCfgPtr->BaseAddress); if (Status != XST_SUCCESS) return1; /* Reset the devices */ XOSD_Reset(&Osd); /* Enable the OSD device and tell it to pick up the register changes */ XOSD_Enable(&Osd); XOSD_RegUpdateEnable(&Osd); return0; }
voidGraphics_setting(u8 Gcindex,u8 LayerPriority,u32 ColorData[],u32 *TextData) { int width = 1920; int height = 1080; int LayerAlphaValue = 0xFF; int LayerGlobalAlphaEnable = 0; XOSD_SetLayerAlpha(&Osd, Gcindex, LayerGlobalAlphaEnable,LayerAlphaValue); XOSD_SetLayerPriority(&Osd, Gcindex, LayerPriority); XOSD_SetLayerDimension(&Osd, Gcindex, 0, 0, width, height); XOSD_EnableLayer(&Osd, Gcindex); /* Load color, font and text and set the active banks */ XOSD_LoadColorLUTBank(&Osd, Gcindex, 0, ColorData); //set BankIndex is 1(fit our keyboard) XOSD_LoadCharacterSetBank(&Osd, Gcindex, 1, (u32 *)Font); XOSD_LoadTextBank(&Osd, Gcindex, 0, (u32 *)TextData); XOSD_SetActiveBank(&Osd, Gcindex, 0, 0, 0, 0); }
图文叠加模块
voidOsdDrawText(int Gcindex,int x_pos, int y_pos, int color, int string_index, int text_size) { u32 Instruction[XOSD_INS_SIZE]; u16 ObjType = XOSD_INS_OPCODE_BOXTXT; /* A text string XOSD_INS_OPCODE_TXT*/ u8 ObjSize = (text_size<<4); /* Text Scale factor (1x, 2x, 4x, 8x) */ u16 XStart = x_pos; /* Horizontal start pixel of the text */ u16 YStart = y_pos; /* Vertical start line of the text */ u16 XEnd = x_pos; /* Horizontal end pixel of the text (not used) */ u16 YEnd = y_pos; /* Vertical end line of the text (must be same as YStart) */ u8 TextIndex = string_index; /* Index of Text String */ u8 ColorIndex = color; /* Color used to draw text */
intOsdInit(int DeviceID) { int Status; /* Initialize the OSD instance */ OsdCfgPtr = XOSD_LookupConfig(DeviceID); Status = XOSD_CfgInitialize(&Osd, OsdCfgPtr,OsdCfgPtr->BaseAddress); if (Status != XST_SUCCESS) return1; /* Reset the devices */ XOSD_Reset(&Osd); /* Enable the OSD device and tell it to pick up the register changes */ XOSD_Enable(&Osd); XOSD_RegUpdateEnable(&Osd); return0; }
voidGraphics_setting(u8 Gcindex,u8 LayerPriority,u32 ColorData[],u32 *TextData) { int width = 1920; int height = 1080; int LayerAlphaValue = 0xFF; int LayerGlobalAlphaEnable = 0; XOSD_SetLayerAlpha(&Osd, Gcindex, LayerGlobalAlphaEnable,LayerAlphaValue); XOSD_SetLayerPriority(&Osd, Gcindex, LayerPriority); XOSD_SetLayerDimension(&Osd, Gcindex, 0, 0, width, height); XOSD_EnableLayer(&Osd, Gcindex); /* Load color, font and text and set the active banks */ XOSD_LoadColorLUTBank(&Osd, Gcindex, 0, ColorData); //set BankIndex is 1(fit our keyboard) XOSD_LoadCharacterSetBank(&Osd, Gcindex, 1, (u32 *)Font); XOSD_LoadTextBank(&Osd, Gcindex, 0, (u32 *)TextData); XOSD_SetActiveBank(&Osd, Gcindex, 0, 0, 0, 0); }
图文叠加模块
voidOsdDrawText(int Gcindex,int x_pos, int y_pos, int color, int string_index, int text_size) { u32 Instruction[XOSD_INS_SIZE]; u16 ObjType = XOSD_INS_OPCODE_BOXTXT; /* A text string XOSD_INS_OPCODE_TXT*/ u8 ObjSize = (text_size<<4); /* Text Scale factor (1x, 2x, 4x, 8x) */ u16 XStart = x_pos; /* Horizontal start pixel of the text */ u16 YStart = y_pos; /* Vertical start line of the text */ u16 XEnd = x_pos; /* Horizontal end pixel of the text (not used) */ u16 YEnd = y_pos; /* Vertical end line of the text (must be same as YStart) */ u8 TextIndex = string_index; /* Index of Text String */ u8 ColorIndex = color; /* Color used to draw text */