This is an old revision of the document!
API Application Example
API Header File
#ifndef __UI_H__ #define __UI_H__ #include <stdint.h> /* uint??_t */ //#include <stdbool.h> /* Bool */ #include "directfb/directfb.h" /* 항상 UI.h 와 함께 UI.h 보다 먼저 */ typedef struct { uint8_t R; uint8_t G; uint8_t B; uint8_t Alpha; } UIcolor_t; typedef enum { UI_TEXT_LAYOUT_NONE = 0, UI_TEXT_LAYOUT_TOP_LEFT, UI_TEXT_LAYOUT_TOP_CENTER, UI_TEXT_LAYOUT_TOP_RIGHT, UI_TEXT_LAYOUT_BOTTOM_LEFT, UI_TEXT_LAYOUT_BOTTOM_CENTER, UI_TEXT_LAYOUT_BOTTOM_RIGHT, UI_TEXT_LAYOUT_MIDDLE_LEFT, UI_TEXT_LAYOUT_MIDDLE_CENTER, UI_TEXT_LAYOUT_MIDDLE_RIGHT, UI_TEXT_LAYOUT_OUTLINE_TOP_LEFT, UI_TEXT_LAYOUT_OUTLINE_TOP_CENTER, UI_TEXT_LAYOUT_OUTLINE_TOP_RIGHT, UI_TEXT_LAYOUT_OUTLINE_BOTTOM_LEFT, UI_TEXT_LAYOUT_OUTLINE_BOTTOM_CENTER, UI_TEXT_LAYOUT_OUTLINE_BOTTOM_RIGHT, UI_TEXT_LAYOUT_OUTLINE_MIDDLE_LEFT, UI_TEXT_LAYOUT_OUTLINE_MIDDLE_CENTER, UI_TEXT_LAYOUT_OUTLINE_MIDDLE_RIGHT, } UItextLayout_t; #define UI_DRIVER_MESSAGE_ERROR // Must be Defined //#define UI_DRIVER_MESSAGE_DEBUG //#define UI_DRIVER_MESSAGE_INFO //#define UI_DRIVER_MESSAGE_KEY_EVENT_INFO extern int ui_initialize(void **pUI, uint32_t Rotate); extern int ui_release(void *pUI); extern int ui_change_font(void *pUI, char *pFontFile, int FontSize); /* // 아래와 같은 형태로 Layout이 나타난다. // ----------------------------------------- // |UI_TEXT_LAYOUT_TOP_LEFT | // | | // | UI_TEXT_LAYOUT_MIDDLE_CENTER | // | | // | UI_TEXT_LAYOUT_BOTTOM_RIGHT| // ----------------------------------------- */ extern int ui_draw_string(void *pUI, UIcolor_t Color, uint32_t X, uint32_t Y, uint32_t W, uint32_t H, char *pString, UItextLayout_t UItextLayout); extern int ui_draw_line(void *pUI, UIcolor_t Color, uint32_t X1, uint32_t Y1, uint32_t X2, uint32_t Y2); extern int ui_draw_rectangle(void *pUI, UIcolor_t Color, uint32_t X, uint32_t Y, uint32_t W, uint32_t H); extern int ui_fill_rectangle(void *pUI, UIcolor_t Color, uint32_t X, uint32_t Y, uint32_t W, uint32_t H); extern int ui_clear_screen(void *pUI); /* jpg png gif */ extern int ui_draw_image(void *pUI, char *pImageFile, uint32_t X, uint32_t Y); /* 0: No key input or Parameter Error 1: Key is inputed */ extern int ui_key_is_inputed(void *pUI, uint32_t MiliSecondWaitTimeout); /* 0: OK -1: Error */ extern int ui_key_get_code(void *pUI, uint32_t *pKeyCode, bool *pIsReleased); extern int ui_printer_create_surface(void *pUI, uint32_t SurfaceWidth, uint32_t SurfaceHeight); extern int ui_printer_font_set(void *pUI, char *pFontFile, int FontSize); extern int ui_printer_font_get_line_height(void *pUI, uint32_t *pLineHeight); extern int ui_printer_string(void *pUI, char *pString, UItextLayout_t UItextLayout, uint8_t *pImageBuffer, uint32_t ByteSizeOfImageBufferWidth, uint32_t ByteSizeOfImageBufferHeight); #endif /* __UI_H__ */
API Source File
#include <stdio.h> #include <stdint.h> /* uint??_t */ #include <string.h> /* for memset */ //#include <unistd.h> /* for open/close .. */ //#include <fcntl.h> /* for O_RDWR */ //#include <sys/ioctl.h> /* for ioctl */ //#include <sys/mman.h> /* for mmap */ //#include <linux/fb.h> /* for fb_var_screeninfo, FBIOGET_VSCREENINFO */ #include <linux/input.h> #include <poll.h> //#include <sys/fcntl.h> /* for O_RDWR */ #include <unistd.h> /* sleep */ #include "directfb/directfb.h" #include "UI.h" /* Surface는 이미지의 픽셀데이터가 특정 픽셀 형식으로 저장되는 메모리의 예약 영역임. */ #ifdef UI_DRIVER_MESSAGE_DEBUG #define UI_DEBUG(fmt, args ...) printf("DEBUG:%s(%d): " fmt, __FUNCTION__,__LINE__, ## args) #else #define UI_DEBUG(fmt, args ...) {} #endif /* UI_DRIVER_MESSAGE_DEBUG */ #ifdef UI_DRIVER_MESSAGE_ERROR #define UI_ERROR(fmt, args ...) printf("ERROR:%s(%d): " fmt, __FUNCTION__,__LINE__, ## args) #else #define UI_ERROR(fmt, args ...) {} #endif /* UI_DRIVER_DEBUG_MESSAGE */ #ifdef UI_DRIVER_MESSAGE_INFO #define UI_INFO(fmt, args ...) printf("INFOs:%s(%d): " fmt, __FUNCTION__,__LINE__, ## args) #else #define UI_INFO(fmt, args ...) {} #endif /* UI_DRIVER_DEBUG_MESSAGE */ #define DEFAULT_FONT_FILE "D2Coding.ttf" #define DEFAULT_FONT_SIZE 22 typedef struct { uint32_t X; uint32_t Y; } UIposition_t; typedef struct { uint32_t MagicNumber; IDirectFB * pDirectFb; IDirectFBInputDevice * pInputDevice; IDirectFBEventBuffer * pEventBuffer; IDirectFBSurface * pPrimarySurface; /* primary surface - Base Screen */ int ScreenWidth; int ScreenHeight; IDirectFBFont * pFont; char * pFontFile; int FontSize; uint32_t Rotate; uint32_t UserScreenWidth; uint32_t UserScreenHeight; IDirectFBSurface * pPrinterSurface; /* Printer surface */ uint32_t PrinterSurfaceWidth; uint32_t PrinterSurfaceHeight; IDirectFBFont * pPrinterFont; char * pPrinterFontFile; int PrinterFontSize; // uint32_t PrintedImageWidth; uint32_t PrintedLineHeight; } UIcontext_t; static UIcontext_t UIcontext = {0}; static UIcontext_t * pUIcontext = (UIcontext_t *)0; int ui_initialize(void **pUI, uint32_t Rotate) { DFBSurfaceDescription SurfaceDescription; DFBFontDescription FontDescription; if ( ( pUI == (void **)0 ) || ( ( Rotate % 90 ) != 0 ) ) { UI_ERROR( "Error in Input Paramter\n" ); return -1; } Rotate %= 360; if ( pUIcontext != (UIcontext_t *)0 ) { UI_DEBUG( "Already initialized\n" ); *pUI = (void *)pUIcontext; return 0; } UI_INFO( "Initialize Direct FB\n" ); if ( DirectFBInit( 0, 0 ) != DFB_OK ) { UI_ERROR( "Error in DirectFBInit()\n" ); goto UI_INITIALIZE_ERROR_IN_INIT_DIRECT_FB; } UI_INFO( "Create Super Interface\n" ); if ( DirectFBCreate( &UIcontext.pDirectFb ) != DFB_OK ) { UI_ERROR( "Error in DirectFBCreate()\n" ); goto UI_INITIALIZE_ERROR_IN_CREATE_FB; } UI_INFO( "Create Input Device\n" ); if ( UIcontext.pDirectFb->GetInputDevice( UIcontext.pDirectFb, DIDID_KEYBOARD, &UIcontext.pInputDevice ) != DFB_OK ) { UI_ERROR( "Error in GetInputDevice()\n" ); goto UI_INITIALIZE_ERROR_IN_CREATE_INPUT_DEVICE; } UI_INFO( "Create Event Buffer\n" ); if ( UIcontext.pInputDevice->CreateEventBuffer( UIcontext.pInputDevice, &UIcontext.pEventBuffer ) != DFB_OK ) { UI_ERROR( "Error in CreateEventBuffer()\n" ); goto UI_INITIALIZE_ERROR_IN_CREATE_EVENT_BUFFER; } UI_INFO( "Set Cooperative Level - to full screen\n" ); if ( UIcontext.pDirectFb->SetCooperativeLevel( UIcontext.pDirectFb, DFSCL_FULLSCREEN ) != DFB_OK ) { UI_ERROR( "Error in SetCooperativeLevel()\n "); goto UI_INITIALIZE_ERROR_IN_SET_COOPERATIVE_LEVEL; } /* set flags */ SurfaceDescription.flags = DSDESC_CAPS; SurfaceDescription.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING; UI_INFO( "Create Surface - Prime\n" ); if ( UIcontext.pDirectFb->CreateSurface( UIcontext.pDirectFb, &SurfaceDescription, &UIcontext.pPrimarySurface ) != DFB_OK ) { UI_ERROR( "Error in CreateSurface()\n" ); goto UI_INITIALIZE_ERROR_IN_CREATE_PRIME_SURFACE; } UI_INFO( "Get Surface Size\n" ); if ( UIcontext.pPrimarySurface->GetSize( UIcontext.pPrimarySurface, &UIcontext.ScreenWidth, &UIcontext.ScreenHeight ) != DFB_OK ) { UI_ERROR( "Error in GetSize()\n"); goto UI_INITIALIZE_ERROR_IN_GET_PRIME_SURFACE_SIZE; } UI_INFO( " Prime Surface : Physical Width = %d, Physical Height= %d\n", UIcontext.ScreenWidth, UIcontext.ScreenHeight ); UI_INFO( "Clear Surface\n" ); if ( UIcontext.pPrimarySurface->FillRectangle( UIcontext.pPrimarySurface, 0, 0, UIcontext.ScreenWidth, UIcontext.ScreenHeight ) != DFB_OK ) { UI_ERROR( "Error in FillRectangle() to clear prime surface\n"); goto UI_INITIALIZE_ERROR_IN_CLEAR_SURFACE; } if ( UIcontext.pPrimarySurface->Flip( UIcontext.pPrimarySurface, NULL, 0 ) != DFB_OK ) { UI_ERROR( "Error in Flip() to clear prime surface\n"); goto UI_INITIALIZE_ERROR_IN_FLIP_TO_CLEAR_SURFACE; } UIcontext.FontSize = DEFAULT_FONT_SIZE; UIcontext.pFontFile = DEFAULT_FONT_FILE; UI_INFO( "Create Font\n" ); FontDescription.flags = DFDESC_HEIGHT | DFDESC_ATTRIBUTES; FontDescription.height = UIcontext.FontSize; FontDescription.attributes = DFFA_MONOCHROME; // DFFA_NONE if ( UIcontext.pDirectFb->CreateFont( UIcontext.pDirectFb, UIcontext.pFontFile, &FontDescription, &UIcontext.pFont ) != DFB_OK ) { UI_ERROR( "Error in CreateFont()\n"); goto UI_INITIALIZE_ERROR_IN_CREATE_FONT; } UIcontext.MagicNumber = 0x1828128; UIcontext.Rotate = Rotate; if ( ( UIcontext.Rotate == 90) || ( UIcontext.Rotate == 270) ) { UIcontext.UserScreenWidth = UIcontext.ScreenHeight; UIcontext.UserScreenHeight = UIcontext.ScreenWidth; } else { UIcontext.UserScreenWidth = UIcontext.ScreenWidth; UIcontext.UserScreenHeight = UIcontext.ScreenHeight; } pUIcontext = &UIcontext; *pUI = (void *)pUIcontext; UIcontext.pPrinterSurface = (IDirectFBSurface *)0; UIcontext.pPrinterFont = (IDirectFBFont *)0; UI_INFO( "Initialized\n" ); return 0; UI_INITIALIZE_ERROR_IN_CREATE_FONT: UI_INITIALIZE_ERROR_IN_FLIP_TO_CLEAR_SURFACE: UI_INITIALIZE_ERROR_IN_CLEAR_SURFACE: UI_INITIALIZE_ERROR_IN_GET_PRIME_SURFACE_SIZE: UIcontext.pPrimarySurface->Release( UIcontext.pPrimarySurface ); UI_INITIALIZE_ERROR_IN_CREATE_PRIME_SURFACE: UI_INITIALIZE_ERROR_IN_SET_COOPERATIVE_LEVEL: UIcontext.pEventBuffer->Release( UIcontext.pEventBuffer ); UI_INITIALIZE_ERROR_IN_CREATE_EVENT_BUFFER: UIcontext.pInputDevice->Release( UIcontext.pInputDevice ); UI_INITIALIZE_ERROR_IN_CREATE_INPUT_DEVICE: UIcontext.pDirectFb->Release( UIcontext.pDirectFb ); UI_INITIALIZE_ERROR_IN_CREATE_FB: UI_INITIALIZE_ERROR_IN_INIT_DIRECT_FB: return -2; } int ui_release(void *pUI) { if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } UIcontext.MagicNumber = 0; if ( UIcontext.pPrinterSurface != (IDirectFBSurface *)0 ) { printf ( "Printer Surface Release\n" ); UIcontext.pPrinterSurface->Release( UIcontext.pPrinterSurface ); } if ( UIcontext.pPrinterFont != (IDirectFBFont *)0 ) { printf ( "Printer Font Release\n" ); UIcontext.pPrinterFont->Release( UIcontext.pPrinterFont ); } UIcontext.pFont->Release( UIcontext.pFont ); UIcontext.pPrimarySurface->Release( UIcontext.pPrimarySurface ); UIcontext.pEventBuffer->Release( UIcontext.pEventBuffer ); UIcontext.pInputDevice->Release( UIcontext.pInputDevice ); UIcontext.pDirectFb->Release( UIcontext.pDirectFb ); pUIcontext = (UIcontext_t *)0; memset( &UIcontext, 0, sizeof(UIcontext_t) ); return 0; } int ui_change_font(void *pUI, char *pFontFile, int FontSize) { DFBFontDescription FontDescription; IDirectFBFont * pNewFont; if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } FontDescription.flags = DFDESC_HEIGHT | DFDESC_ATTRIBUTES; FontDescription.height = FontSize; FontDescription.attributes = DFFA_MONOCHROME; // DFFA_NONE if ( UIcontext.pDirectFb->CreateFont( UIcontext.pDirectFb, pFontFile, &FontDescription, &pNewFont ) != DFB_OK ) { UI_ERROR( "Error in CreateFont()\n"); return -1; } if ( UIcontext.pFont->Release( UIcontext.pFont ) != DFB_OK ) { UI_DEBUG( "Error in Release() for release old font.. using old font\n"); pNewFont->Release( pNewFont ); return -2; } UIcontext.pFont = pNewFont; UIcontext.FontSize = FontSize; UIcontext.pFontFile = pFontFile; return 0; } uint32_t ui_make_text_flag(UItextLayout_t UItextLayout) { uint32_t Flag; Flag = DSTF_NONE; switch ( UItextLayout ) { case UI_TEXT_LAYOUT_TOP_LEFT: Flag += DSTF_TOP; Flag += DSTF_LEFT; break; case UI_TEXT_LAYOUT_TOP_CENTER: Flag += DSTF_TOP; Flag += DSTF_CENTER; break; case UI_TEXT_LAYOUT_TOP_RIGHT: Flag += DSTF_TOP; Flag += DSTF_RIGHT; break; case UI_TEXT_LAYOUT_BOTTOM_LEFT: Flag += DSTF_BOTTOM; Flag += DSTF_LEFT; break; case UI_TEXT_LAYOUT_BOTTOM_CENTER: Flag += DSTF_BOTTOM; Flag += DSTF_CENTER; break; case UI_TEXT_LAYOUT_BOTTOM_RIGHT: Flag += DSTF_BOTTOM; Flag += DSTF_RIGHT; break; case UI_TEXT_LAYOUT_MIDDLE_LEFT: Flag += DSTF_LEFT; break; case UI_TEXT_LAYOUT_MIDDLE_CENTER: Flag += DSTF_CENTER; break; case UI_TEXT_LAYOUT_MIDDLE_RIGHT: Flag += DSTF_RIGHT; break; case UI_TEXT_LAYOUT_OUTLINE_TOP_LEFT: Flag += DSTF_OUTLINE; Flag += DSTF_TOP; Flag += DSTF_LEFT; break; case UI_TEXT_LAYOUT_OUTLINE_TOP_CENTER: Flag += DSTF_OUTLINE; Flag += DSTF_TOP; Flag += DSTF_CENTER; break; case UI_TEXT_LAYOUT_OUTLINE_TOP_RIGHT: Flag += DSTF_TOP; Flag += DSTF_RIGHT; Flag += DSTF_OUTLINE; break; case UI_TEXT_LAYOUT_OUTLINE_BOTTOM_LEFT: Flag += DSTF_OUTLINE; Flag += DSTF_BOTTOM; Flag += DSTF_LEFT; break; case UI_TEXT_LAYOUT_OUTLINE_BOTTOM_CENTER: Flag += DSTF_OUTLINE; Flag += DSTF_BOTTOM; Flag += DSTF_CENTER; break; case UI_TEXT_LAYOUT_OUTLINE_BOTTOM_RIGHT: Flag += DSTF_OUTLINE; Flag += DSTF_BOTTOM; Flag += DSTF_RIGHT; break; case UI_TEXT_LAYOUT_OUTLINE_MIDDLE_LEFT: Flag += DSTF_OUTLINE; Flag += DSTF_LEFT; break; case UI_TEXT_LAYOUT_OUTLINE_MIDDLE_CENTER: Flag += DSTF_OUTLINE; Flag += DSTF_CENTER; break; case UI_TEXT_LAYOUT_OUTLINE_MIDDLE_RIGHT: Flag += DSTF_OUTLINE; Flag += DSTF_RIGHT; break; case UI_TEXT_LAYOUT_NONE: default: break; } return Flag; } UIposition_t ui_make_text_draw_position(UItextLayout_t UItextLayout, uint32_t X, uint32_t Y, uint32_t W, uint32_t H, uint32_t Rotate) { UIposition_t Position; uint32_t Temp; switch ( UItextLayout ) { case UI_TEXT_LAYOUT_TOP_LEFT: case UI_TEXT_LAYOUT_OUTLINE_TOP_LEFT: Position.X = X; Position.Y = Y; break; case UI_TEXT_LAYOUT_OUTLINE_TOP_CENTER: case UI_TEXT_LAYOUT_TOP_CENTER: Position.X = X + ( W >> 1 ); Position.Y = Y; break; case UI_TEXT_LAYOUT_OUTLINE_TOP_RIGHT: case UI_TEXT_LAYOUT_TOP_RIGHT: Position.X = X + W; Position.Y = Y; break; case UI_TEXT_LAYOUT_OUTLINE_BOTTOM_LEFT: case UI_TEXT_LAYOUT_BOTTOM_LEFT: Position.X = X; Position.Y = Y + H; break; case UI_TEXT_LAYOUT_OUTLINE_BOTTOM_CENTER: case UI_TEXT_LAYOUT_BOTTOM_CENTER: Position.X = X + ( W >> 1 ); Position.Y = Y + H; break; case UI_TEXT_LAYOUT_OUTLINE_BOTTOM_RIGHT: case UI_TEXT_LAYOUT_BOTTOM_RIGHT: Position.X = X + W; Position.Y = Y + H; break; case UI_TEXT_LAYOUT_OUTLINE_MIDDLE_CENTER: case UI_TEXT_LAYOUT_MIDDLE_CENTER: Position.X = X + ( W >> 1 ); Position.Y = Y + ( H >> 1 ); break; case UI_TEXT_LAYOUT_OUTLINE_MIDDLE_RIGHT: case UI_TEXT_LAYOUT_MIDDLE_RIGHT: Position.X = X + W; Position.Y = Y + ( H >> 1 ); break; case UI_TEXT_LAYOUT_OUTLINE_MIDDLE_LEFT: case UI_TEXT_LAYOUT_MIDDLE_LEFT: case UI_TEXT_LAYOUT_NONE: default: Position.X = X; Position.Y = Y + ( H >> 1 ); break; } if ( ( Rotate == 90 ) || ( Rotate == 270 ) ) { Temp = Position.X; Position.X = Position.Y; Position.Y = Temp; } return Position; } static int ui_draw_update(IDirectFBSurface *pPrimarySurface, uint32_t Rotate) { /* update surface */ if ( Rotate == 90 ) { if ( pPrimarySurface->SetBlittingFlags( pPrimarySurface, DSBLIT_ROTATE90 ) != DFB_OK ) { return -3; } } else if ( Rotate == 180 ) { if ( pPrimarySurface->SetBlittingFlags( pPrimarySurface, DSBLIT_ROTATE180 ) != DFB_OK ) { return -3; } } else if ( Rotate == 270 ) { if ( pPrimarySurface->SetBlittingFlags( pPrimarySurface, DSBLIT_ROTATE270 ) != DFB_OK ) { return -3; } } if ( pPrimarySurface->Flip( pPrimarySurface, NULL, 0) != DFB_OK ) { return -3; } if ( Rotate != 0 ) { if ( pPrimarySurface->SetBlittingFlags( pPrimarySurface, DSBLIT_NOFX ) != DFB_OK ) { return -3; } } return 0; } int ui_draw_string(void *pUI, UIcolor_t Color, uint32_t X, uint32_t Y, uint32_t W, uint32_t H, char *pString, UItextLayout_t UItextLayout) { int DisplayWidth; int DisplayHeight; UIposition_t Position; if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) || ( pString == (char *)0 ) ) { UI_ERROR( "Input Parameter\n" ); return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { UI_ERROR( "Magic Number\n" ); return -1; } if ( UIcontext.pFont->GetStringWidth( UIcontext.pFont, pString, -1/*bytes*/, &DisplayWidth) != DFB_OK ) { UI_ERROR( "Get String Width\n" ); return -3; } UI_INFO( "String Width = %d\n", DisplayWidth ); if ( UIcontext.pFont->GetHeight( UIcontext.pFont, &DisplayHeight ) != DFB_OK ) { UI_ERROR( "Get String Height\n" ); return -3; } UI_INFO( "String Height = %d\n", DisplayHeight ); if ( ( DisplayWidth > W ) || ( DisplayHeight > H ) ) { UI_ERROR( "DisplayWidth(%d) > W(%d) or DisplayHeight(%d) > H(%d)\n", DisplayWidth, W, DisplayHeight, H ); return -1; } if ( ( UIcontext.UserScreenWidth < ( W + X ) ) || ( UIcontext.UserScreenHeight < ( H + Y ) ) ) { UI_ERROR( "UserScreenWidth(%d) < (W + X)(%d) or UIcontext.UserScreenHeight(%d) < ( H + Y )(%d)\n", UIcontext.UserScreenWidth, ( W + X ), UIcontext.UserScreenHeight, ( H + Y ) ); return -1; } if ( UIcontext.pPrimarySurface->SetFont( UIcontext.pPrimarySurface, UIcontext.pFont ) != DFB_OK ) { UI_ERROR( "Set Font\n" ); return -3; } UI_INFO( "Set Font OK\n" ); if ( UIcontext.pPrimarySurface->SetColor( UIcontext.pPrimarySurface, Color.B, Color.G, Color.R, Color.Alpha ) != DFB_OK ) { UI_ERROR( "Set Color\n" ); return -3; } UI_INFO( "Set Color OK\n" ); Position = ui_make_text_draw_position( UItextLayout, X, Y, W, H, UIcontext.Rotate ); UI_INFO( "Position : X = %d, Y= %d\n", Position.X, Position.Y ); if ( UIcontext.pPrimarySurface->DrawString( UIcontext.pPrimarySurface, pString, -1/*Bytes*/, Position.X, Position.Y, ui_make_text_flag( UItextLayout )/*Flasg*/ ) != DFB_OK ) { UI_ERROR( "Draw\n" ); return -3; } UI_INFO( "Draw OK\n" ); /* update surface */ return ui_draw_update( UIcontext.pPrimarySurface, UIcontext.Rotate); } int ui_draw_line(void *pUI, UIcolor_t Color, uint32_t X1, uint32_t Y1, uint32_t X2, uint32_t Y2) { if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } if ( ( UIcontext.UserScreenWidth <= X1 ) || ( UIcontext.UserScreenHeight <= Y1 ) || ( UIcontext.UserScreenWidth <= X2 ) || ( UIcontext.UserScreenHeight <= Y2 ) ) { return -2; } if ( UIcontext.pPrimarySurface->SetColor( UIcontext.pPrimarySurface, Color.B, Color.G, Color.R, Color.Alpha ) != DFB_OK ) { return -3; } if ( UIcontext.pPrimarySurface->DrawLine( UIcontext.pPrimarySurface, X1, Y1, X2, Y2 ) != DFB_OK ) { return -3; } /* update surface */ return ui_draw_update( UIcontext.pPrimarySurface, UIcontext.Rotate); } int ui_draw_rectangle(void *pUI, UIcolor_t Color, uint32_t X, uint32_t Y, uint32_t W, uint32_t H) { if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } if ( ( UIcontext.UserScreenWidth <= ( W + X ) ) || ( UIcontext.UserScreenHeight <= ( H + Y ) ) ) { return -2; } if ( UIcontext.pPrimarySurface->SetColor( UIcontext.pPrimarySurface, Color.B, Color.G, Color.R, Color.Alpha ) != DFB_OK ) { return -3; } if ( UIcontext.pPrimarySurface->DrawRectangle( UIcontext.pPrimarySurface, X, Y, W, H ) != DFB_OK ) { return -3; } /* update surface */ return ui_draw_update( UIcontext.pPrimarySurface, UIcontext.Rotate); } int ui_fill_rectangle(void *pUI, UIcolor_t Color, uint32_t X, uint32_t Y, uint32_t W, uint32_t H) { if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } if ( ( UIcontext.UserScreenWidth <= ( W + X ) ) || ( UIcontext.UserScreenHeight <= ( H + Y ) ) ) { return -2; } if ( UIcontext.pPrimarySurface->SetColor( UIcontext.pPrimarySurface, Color.B, Color.G, Color.R, Color.Alpha ) != DFB_OK ) { return -3; } if ( UIcontext.pPrimarySurface->FillRectangle( UIcontext.pPrimarySurface, X, Y, W, H ) != DFB_OK ) { return -3; } /* update surface */ return ui_draw_update( UIcontext.pPrimarySurface, UIcontext.Rotate); } int ui_clear_screen(void *pUI) { if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } if ( UIcontext.pPrimarySurface->SetColor( UIcontext.pPrimarySurface, 0, 0, 0, 0xFF ) != DFB_OK ) { return -3; } if ( UIcontext.pPrimarySurface->FillRectangle( UIcontext.pPrimarySurface, 0, 0, UIcontext.ScreenWidth, UIcontext.ScreenHeight ) != DFB_OK ) { return -3; } /* update surface */ return ui_draw_update( UIcontext.pPrimarySurface, UIcontext.Rotate); } /* jpg png gif */ int ui_draw_image(void *pUI, char *pImageFile, uint32_t X, uint32_t Y) { IDirectFBSurface * pImageSurface; /* Image surface */ IDirectFBImageProvider *pImageProvider; /* */ DFBSurfaceDescription SurfaceDescription; if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } /* Create image provider */ if ( UIcontext.pDirectFb->CreateImageProvider( UIcontext.pDirectFb, pImageFile, &pImageProvider ) != DFB_OK ) { goto UI_DRAW_IMAGE_ERROR_IN_CREATE_IMAGE_PROVIDER; } if ( pImageProvider->GetSurfaceDescription( pImageProvider, &SurfaceDescription ) != DFB_OK ) { goto UI_DRAW_IMAGE_ERROR_IN_GET_SURFACE_DESCRIPTION; } if ( UIcontext.pDirectFb->CreateSurface( UIcontext.pDirectFb, &SurfaceDescription, &pImageSurface) != DFB_OK ) { goto UI_DRAW_IMAGE_ERROR_IN_CREATE_SURFACE; } if ( pImageProvider->RenderTo( pImageProvider, pImageSurface, NULL) != DFB_OK ) { goto UI_DRAW_IMAGE_ERROR_IN_RANDER; } if ( UIcontext.pPrimarySurface->Blit( UIcontext.pPrimarySurface, pImageSurface, NULL, X, Y) != DFB_OK ) { goto UI_DRAW_IMAGE_ERROR_IN_BLIT; } /* update surface */ if ( ui_draw_update( UIcontext.pPrimarySurface, UIcontext.Rotate ) != 0 ) { goto UI_DRAW_IMAGE_ERROR_IN_UPDATE; } UI_DRAW_IMAGE_ERROR_IN_UPDATE: UI_DRAW_IMAGE_ERROR_IN_BLIT: UI_DRAW_IMAGE_ERROR_IN_RANDER: pImageSurface->Release( pImageSurface ); UI_DRAW_IMAGE_ERROR_IN_CREATE_SURFACE: UI_DRAW_IMAGE_ERROR_IN_GET_SURFACE_DESCRIPTION: pImageProvider->Release( pImageProvider ); UI_DRAW_IMAGE_ERROR_IN_CREATE_IMAGE_PROVIDER: return -2; } /* 0: No key input or Parameter Error 1: Key is inputed */ int ui_key_is_inputed(void *pUI, uint32_t MiliSecondWaitTimeout) { if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } if ( /*( UIcontext.pEventBuffer == (IDirectFBEventBuffer *)0 ) ||*/ ( MiliSecondWaitTimeout == 0 ) ) { return -1; } if ( UIcontext.pEventBuffer->WaitForEventWithTimeout( UIcontext.pEventBuffer, 0, MiliSecondWaitTimeout ) == DFB_TIMEOUT ) { return 0; } return 1; } /* 0: OK -1: Error */ int ui_key_get_code(void *pUI, uint32_t *pKeyCode, bool *pIsReleased) { if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } DFBInputEvent InputEvent; if ( /*( UIcontext.pEventBuffer == (IDirectFBEventBuffer *)0 ) || */( pKeyCode == (uint32_t *)0 ) || ( pIsReleased == (bool *)0 ) ) { return -1; } if ( UIcontext.pEventBuffer->GetEvent ( UIcontext.pEventBuffer, DFB_EVENT( &InputEvent ) ) != DFB_OK ) { return -2; } #ifdef UI_DRIVER_MESSAGE_KEY_EVENT_INFO UI_INFO("Input Event : Type = %d, Key ID = %d\n", InputEvent.type, InputEvent.key_id); UI_INFO(" clazz = %d clazz of event\n", InputEvent.clazz); switch (InputEvent.clazz) { case DFEC_NONE: UI_INFO(" none of these\n"); break; case DFEC_INPUT: UI_INFO(" raw input event\n"); break; case DFEC_WINDOW: UI_INFO(" windowing event\n"); break; case DFEC_USER: UI_INFO(" custom event for the user of this library\n"); break; case DFEC_UNIVERSAL: UI_INFO(" universal event for custom usage with variable size\n"); break; case DFEC_VIDEOPROVIDER: UI_INFO(" video provider event\n"); break; case DFEC_SURFACE: UI_INFO(" surface event\n"); break; default: UI_INFO(" unknown\n"); break; } UI_INFO(" type = %d type of event\n", InputEvent.type); switch (InputEvent.type) { case DIET_UNKNOWN: UI_INFO(" unknown event\n"); break; case DIET_KEYPRESS: UI_INFO(" a key is been pressed\n"); break; case DIET_KEYRELEASE: UI_INFO(" a key is been released\n"); break; case DIET_BUTTONPRESS: UI_INFO(" a (mouse) button is been pressed\n"); break; case DIET_BUTTONRELEASE: UI_INFO(" a (mouse) button is been released\n"); break; case DIET_AXISMOTION: UI_INFO(" mouse/joystick movement\n"); break; default: UI_INFO(" unknown\n"); break; } UI_INFO(" device_id = %d source of event\n", InputEvent.device_id); UI_INFO(" flags = %d which optional fields are valid\n", InputEvent.flags); if ( InputEvent.flags == DIEF_NONE) { UI_INFO(" no additional fields\n"); } if ( (InputEvent.flags & DIEF_TIMESTAMP) == DIEF_TIMESTAMP) { UI_INFO(" timestamp is valid\n"); } if ( (InputEvent.flags & DIEF_AXISABS) == DIEF_AXISABS) { UI_INFO(" axis and axisabs are valid\n"); } if ( (InputEvent.flags & DIEF_AXISREL) == DIEF_AXISREL) { UI_INFO(" axis and axisrel are valid\n"); } if ( (InputEvent.flags & DIEF_KEYCODE) == DIEF_KEYCODE) { UI_INFO(" DIEF_KEYCODE used internally by the input core, always set at application level\n"); } if ( (InputEvent.flags & DIEF_KEYID) == DIEF_KEYID) { UI_INFO(" DIEF_KEYID used internally by the input core, always set at application level\n"); } if ( (InputEvent.flags & DIEF_KEYSYMBOL) == DIEF_KEYSYMBOL) { UI_INFO(" DIEF_KEYSYMBOL used internally by the input core, always set at application level\n"); } if ( (InputEvent.flags & DIEF_MODIFIERS) == DIEF_MODIFIERS) { UI_INFO(" DIEF_MODIFIERS used internally by the input core, always set at application level\n"); } if ( (InputEvent.flags & DIEF_LOCKS) == DIEF_LOCKS) { UI_INFO(" DIEF_LOCKS used internally by the input core, always set at application level\n"); } if ( (InputEvent.flags & DIEF_BUTTONS) == DIEF_BUTTONS) { UI_INFO(" DIEF_BUTTONS used internally by the input core, always set at application level\n"); } if ( (InputEvent.flags & DIEF_GLOBAL) == DIEF_GLOBAL) { UI_INFO(" Only for event buffers creates by IDirectFB::CreateInputEventBuffer() with global events enabled\n"); /* Indicates that the event would have been filtered if the buffer hadn't been global. */ } if ( (InputEvent.flags & DIEF_REPEAT) == DIEF_REPEAT) { UI_INFO(" repeated event, e.g. key or button press\n"); } if ( (InputEvent.flags & DIEF_FOLLOW) == DIEF_FOLLOW) { UI_INFO(" another event will follow immediately, e.g. x/y axis\n"); } if ( (InputEvent.flags & DIEF_MIN) == DIEF_MIN) { UI_INFO(" minimum value is set, e.g. for absolute axis motion\n"); } if ( (InputEvent.flags & DIEF_MAX) == DIEF_MAX) { UI_INFO(" maximum value is set, e.g. for absolute axis motion\n"); } UI_INFO(" additionally (check flags)\n"); // struct timeval timestamp; /* time of event creation */ UI_INFO(" DIET_KEYPRESS, DIET_KEYRELEASE\n"); UI_INFO(" key_code = %d hardware keycode, no mapping, -1 if device doesn't differentiate between several keys\n", InputEvent.key_code); // DFBInputDeviceKeyIdentifier key_id; /* basic mapping, modifier independent */ // DFBInputDeviceKeySymbol key_symbol; /* advanced mapping, unicode compatible, modifier dependent */ UI_INFO(" additionally (check flags)\n"); UI_INFO(" modifiers = 0x%X pressed modifiers (optional)\n", InputEvent.modifiers); #if 0 DIMM_SHIFT = (1 << DIMKI_SHIFT), /* Shift key is pressed */ DIMM_CONTROL = (1 << DIMKI_CONTROL), /* Control key is pressed */ DIMM_ALT = (1 << DIMKI_ALT), /* Alt key is pressed */ DIMM_ALTGR = (1 << DIMKI_ALTGR), /* AltGr key is pressed */ DIMM_META = (1 << DIMKI_META), /* Meta key is pressed */ DIMM_SUPER = (1 << DIMKI_SUPER), /* Super key is pressed */ DIMM_HYPER = (1 << DIMKI_HYPER) /* Hyper key is pressed */ #endif // DFBInputDeviceLockState locks; /* active locks (optional) */ UI_INFO(" DIET_BUTTONPRESS, DIET_BUTTONRELEASE\n"); UI_INFO(" button = %d in case of a button event Left=0, Right=1, Middle=2\n", InputEvent.button); UI_INFO(" buttons = %d mask of currently pressed buttons Left=1, Right=2, Middle=4\n", InputEvent.buttons); UI_INFO(" DIET_AXISMOTION\n"); UI_INFO(" axis = %d in case of an axis event X=0, Y=1, Z=2\n", InputEvent.axis); UI_INFO(" one of these two (check flags) : mouse/joystick\n"); UI_INFO(" axisabs = %d absolute mouse/joystick coordinate\n", InputEvent.axisabs); UI_INFO(" axisrel = %d relative mouse/joystick movement\n", InputEvent.axisrel); UI_INFO(" general information\n"); UI_INFO(" min = %d\n", InputEvent.min); UI_INFO(" max = %d\n", InputEvent.max); #endif /* UI_DRIVER_MESSAGE_KEY_EVENT_INFO */ if ( (InputEvent.flags & DIEF_KEYCODE) == DIEF_KEYCODE ) { if ( ( InputEvent.type == DIET_KEYPRESS ) || ( InputEvent.type == DIET_KEYRELEASE ) ) { *pKeyCode = InputEvent.key_code; if ( InputEvent.type == DIET_KEYPRESS ) { *pIsReleased = 0; } else /*if ( InputEvent.type == DIET_KEYRELEASE )*/ { *pIsReleased = 1; } return 0; } } return -3; } int ui_printer_create_surface(void *pUI, uint32_t SurfaceWidth, uint32_t SurfaceHeight) { DFBSurfaceDescription SurfaceDescription; if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) || ( SurfaceWidth == 0 ) || ( SurfaceHeight == 0 ) ) { UI_ERROR( "Input parameter\n" ); return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { UI_ERROR( "Not Initiailized UI\n" ); return -1; } if ( UIcontext.pPrinterSurface != (IDirectFBSurface *)0 ) { UI_ERROR( "Arleady created printer surface\n" ); return -2; } UI_INFO( "Create Surface - Printer\n" ); SurfaceDescription.flags = DSDESC_CAPS|DSDESC_PIXELFORMAT|DSDESC_WIDTH|DSDESC_HEIGHT; SurfaceDescription.caps = DSCAPS_FLIPPING; SurfaceDescription.pixelformat = DSPF_A8; SurfaceDescription.width = SurfaceWidth; SurfaceDescription.height = SurfaceHeight; if ( UIcontext.pDirectFb->CreateSurface( UIcontext.pDirectFb, &SurfaceDescription, &UIcontext.pPrinterSurface ) != DFB_OK ) { UI_ERROR( "Error in CreateSurface()\n" ); return -2; } UIcontext.PrinterSurfaceWidth = SurfaceWidth; UIcontext.PrinterSurfaceHeight = SurfaceHeight; return 0; } int ui_printer_font_set(void *pUI, char *pFontFile, int FontSize) { IDirectFBFont * pNewFont; DFBFontDescription FontDescription; int PrintedLineHeight; if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) || ( pFontFile == (char *)0 ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } UI_INFO( "Create Font - Printer\n" ); FontDescription.flags = DFDESC_HEIGHT | DFDESC_ATTRIBUTES; FontDescription.height = FontSize; FontDescription.attributes = DFFA_MONOCHROME; // DFFA_NONE if ( UIcontext.pDirectFb->CreateFont( UIcontext.pDirectFb, pFontFile, &FontDescription, &pNewFont ) != DFB_OK ) { UI_ERROR( "Error in CreateFont()\n"); return -2; } if ( pNewFont->GetHeight( pNewFont, &PrintedLineHeight ) != DFB_OK ) { UI_ERROR( "Get Font Height\n" ); pNewFont->Release( pNewFont ); return -2; } PrintedLineHeight += 2; /*Line Space*/ UI_INFO( " Printer Line Height = %d\n", PrintedLineHeight ); if ( UIcontext.pPrinterFont != (IDirectFBFont *)0 ) { UI_INFO( " Need old printer font relase\n" ); if ( UIcontext.pPrinterFont->Release( UIcontext.pPrinterFont ) != DFB_OK ) { UI_ERROR( "Error in old printer font release\n" ); } else { UI_INFO( " OK in old printer font relase\n" ); } } UIcontext.pPrinterFont = pNewFont; UIcontext.pPrinterFontFile = pFontFile; UIcontext.PrinterFontSize = FontSize; UIcontext.PrintedLineHeight = PrintedLineHeight; return 0; } int ui_printer_font_get_line_height(void *pUI, uint32_t *pLineHeight) { IDirectFBFont * pNewFont; IDirectFBSurface * pNewSurface; DFBFontDescription FontDescription; DFBSurfaceDescription SurfaceDescription; int PrintedImageHeight; if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) || ( pLineHeight == (uint32_t *)0 ) ) { return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { return -1; } *pLineHeight = UIcontext.PrintedLineHeight; return 0; } void ui_printer_mapping_surface_to_image_buffer(uint8_t *pSurface, uint8_t *pImageBuffer, uint32_t ByteSizeOfImageBufferWidth, uint32_t ByteSizeOfImageBufferHeight, uint32_t SurfaceWidth, bool LSBFirst, bool LRswitching) { uint32_t IndexForY; uint32_t IndexForX; uint32_t SurfaceLineIndex; uint32_t SurfaceOffset; uint32_t ImageLineIndex; uint32_t ImageOffset; for ( IndexForY = 0; IndexForY < ByteSizeOfImageBufferHeight; IndexForY++ ) { for ( IndexForX = 0; IndexForX < ( ByteSizeOfImageBufferWidth * 8 ); IndexForX++ ) { SurfaceLineIndex = IndexForY * SurfaceWidth; /* 여기에서 좌우바뀜 수정 */ if( LRswitching == true ) { SurfaceOffset = ( ByteSizeOfImageBufferWidth * 8 ) - IndexForX - 1; } else { SurfaceOffset = IndexForX; } ImageLineIndex = IndexForY * ByteSizeOfImageBufferWidth; ImageOffset = IndexForX / 8; if ( pSurface[SurfaceLineIndex + SurfaceOffset] != 0 ) { if ( LSBFirst == true ) { pImageBuffer[ImageLineIndex + ImageOffset] |= (0x01 << (IndexForX & 0x00000007/* =IndexForX%8 */)); } else { pImageBuffer[ImageLineIndex + ImageOffset] |= (0x80 >> (IndexForX & 0x00000007/* =IndexForX%8 */)); } } } } } int ui_printer_string(void *pUI, char *pString, UItextLayout_t UItextLayout, uint8_t *pImageBuffer, uint32_t ByteSizeOfImageBufferWidth, uint32_t ByteSizeOfImageBufferHeight) { DFBResult Result; int PrintedWidth; int PrintedHeight; UIposition_t Position; uint32_t PhysicalAddress; int Pitch; void * pVoid; if ( ( pUI == (void *)0 ) || ( pUI != (void *)pUIcontext ) || ( pString == (char *)0 ) || ( pImageBuffer == (uint8_t *)0 ) || ( ByteSizeOfImageBufferWidth == 0 ) || ( ByteSizeOfImageBufferHeight == 0 ) ) { UI_ERROR( "Input Parameter\n" ); return -1; } if ( UIcontext.MagicNumber != 0x1828128 ) { UI_ERROR( "Magic Number\n" ); return -1; } if ( ( ( ByteSizeOfImageBufferWidth * 8 ) > UIcontext.PrinterSurfaceWidth ) || ( ByteSizeOfImageBufferHeight > UIcontext.PrinterSurfaceHeight ) ) { UI_ERROR( "Image Buffer Width(%d) > Surface W(%d) or Image Buffer Height(%d) > Surface H(%d)\n", ByteSizeOfImageBufferWidth, ( UIcontext.PrinterSurfaceWidth / 8 ), ByteSizeOfImageBufferHeight, UIcontext.PrinterSurfaceHeight ); return -1; } if ( UIcontext.pPrinterSurface->SetFont( UIcontext.pPrinterSurface, UIcontext.pPrinterFont ) != DFB_OK ) { UI_ERROR( "Error in SetFont()\n" ); return -2; } UI_INFO( "OK in SetFont()\n" ); UIcontext.pPrinterSurface->SetColor( UIcontext.pPrinterSurface, 0xFF, 0xFF, 0xFF, 0xFF ); UIcontext.pPrinterSurface->Clear( UIcontext.pPrinterSurface, 0, 0, 0, 0 ); if ( UIcontext.pPrinterFont->GetStringWidth( UIcontext.pPrinterFont, pString, -1/*bytes*/, &PrintedWidth ) != DFB_OK ) { UI_ERROR( "Get String Width\n" ); return -3; } UI_INFO( "String Width = %d\n", PrintedWidth ); if ( UIcontext.pPrinterFont->GetHeight( UIcontext.pPrinterFont, &PrintedHeight ) != DFB_OK ) { UI_ERROR( "Get String Height\n" ); return -3; } UI_INFO( "String Height = %d\n", PrintedHeight ); if ( ( PrintedWidth > UIcontext.PrinterSurfaceWidth ) || ( PrintedHeight > UIcontext.PrinterSurfaceHeight ) ) { UI_ERROR( "PrintedWidth(%d) > Surface W(%d) or PrintedHeight(%d) > Surface H(%d)\n", PrintedWidth, UIcontext.PrinterSurfaceWidth, PrintedHeight, UIcontext.PrinterSurfaceHeight ); return -1; } if ( ( (PrintedWidth / 8) > ByteSizeOfImageBufferWidth ) || ( PrintedHeight > ByteSizeOfImageBufferHeight ) ) { UI_ERROR( "PrintedWidth Byte(%d) > Image Buffer W(%d) or PrintedHeight Byte(%d) > Image Buffer H(%d)\n", (PrintedWidth / 8), UIcontext.PrinterSurfaceWidth, PrintedHeight, ByteSizeOfImageBufferHeight ); return -1; } Position = ui_make_text_draw_position( UItextLayout, 0, 0, ( ByteSizeOfImageBufferWidth * 8 ), ByteSizeOfImageBufferHeight, 0 ); UI_INFO( "Position : X = %d, Y= %d\n", Position.X, Position.Y ); if ( UIcontext.pPrinterSurface->DrawString( UIcontext.pPrinterSurface, pString, -1/*Bytes*/, Position.X, Position.Y, ui_make_text_flag( UItextLayout )/*Flasg*/ ) != DFB_OK ) { UI_ERROR( "Draw\n" ); return -3; } UI_INFO( "Draw OK\n" ); if ( UIcontext.pPrinterSurface->Flip( UIcontext.pPrinterSurface, NULL, 0 ) != DFB_OK ) { UI_ERROR( "Flip\n" ); return -3; } UI_INFO( "Flip OK\n" ); Result = UIcontext.pPrinterSurface->Lock( UIcontext.pPrinterSurface, DSLF_READ, &pVoid, &Pitch ); if ( Result != DFB_OK ) { UI_INFO( "Lock Fail\n" ); DirectFBError ( "Lock Fail", Result ); } else { UI_INFO( "Lock On : Address = 0x%08X, Pitch = %d\n", pVoid, Pitch ); ui_printer_mapping_surface_to_image_buffer( (uint8_t *)pVoid, pImageBuffer, ByteSizeOfImageBufferWidth, ByteSizeOfImageBufferHeight, UIcontext.PrinterSurfaceWidth, false/*LSBFirst*/ false/*LR switching*/); } if ( UIcontext.pPrinterSurface->Unlock( UIcontext.pPrinterSurface ) != DFB_OK ) { UI_INFO( "Unlock Fail\n" ); } usleep( 1000 ); /* Must be need for completed move data */ return ( ByteSizeOfImageBufferWidth * ByteSizeOfImageBufferHeight ); }