How to set background image in Tizen native app

2019-07-31 17:01发布

I have been trying to set background image in Tizen Native app but have not been successful so far. I have tried doing the same through Canvas and Bitmap but its not working,though i am not getting any error.

I am using the below code in the OnInitializing function of my form.

AppResource *pAppResource = Application::GetInstance()->GetAppResource(); 
Bitmap* pBitmap1 = pAppResource->GetBitmapN(L"image.png");   
Canvas *pCanvas = new Canvas();    
pCanvas->Construct();    
pCanvas->DrawBitmap(Point(0,0), *pBitmap1);   
pCanvas->Show();      

Any idea what could be the issue or any other simpler way of doing the same?

Thanks,

3条回答
Deceive 欺骗
2楼-- · 2019-07-31 17:25

Use GetCanvasN() method from your form.

查看更多
你好瞎i
3楼-- · 2019-07-31 17:35

Add a folder named "screen-density-xhigh" to the resource folder and store image to this folder that you want to set as application background. Now declare result type onDraw() function into the application header.Now implement the code bellow to the .cpp file of this form.

 result TizenForm::OnDraw()
  {

    result r = E_UNKNOWN;
    AppResource *pAppResource = Application::GetInstance()->GetAppResource();
    Bitmap* pBitmap1 = pAppResource->GetBitmapN(L"backgroundImage.jpg");
    Canvas* pCanvas = GetCanvasN();
    if (pCanvas != null)
    {
      pCanvas->DrawBitmap(Rectangle(0, 0,720,1280), *pBitmap1);
    }

    return r;

 }
查看更多
在下西门庆
4楼-- · 2019-07-31 17:47

use OnDraw to draw the background

result TizenForm::OnDraw()
{
result r=E_SUCCESS;
Canvas* pCanvas;

if (__pFormBitmap)
{
    pCanvas = this->GetCanvasN();
    pCanvas->DrawBitmap(Point(0, 0), *__pFormBitmap);
}
delete pCanvas;
return r;
}
查看更多
登录 后发表回答