简体   繁体   English

如何在Tizen本机应用程序中设置背景图像

[英]How to set background image in Tizen native app

I have been trying to set background image in Tizen Native app but have not been successful so far. 我一直在尝试在Tizen本机应用程序中设置背景图像,但到目前为止尚未成功。 I have tried doing the same through Canvas and Bitmap but its not working,though i am not getting any error. 我已经尝试通过Canvas和Bitmap进行相同的操作,但是它没有用,尽管我没有收到任何错误。

I am using the below code in the OnInitializing function of my form. 我在表单的OnInitializing函数中使用以下代码。

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, 谢谢,

从表单中使用GetCanvasN()方法。

use OnDraw to draw the background 使用OnDraw绘制背景

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

if (__pFormBitmap)
{
    pCanvas = this->GetCanvasN();
    pCanvas->DrawBitmap(Point(0, 0), *__pFormBitmap);
}
delete pCanvas;
return r;
}

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. 将名为“ screen-density-xhigh”的文件夹添加到资源文件夹,并将图像存储到要设置为应用程序背景的此文件夹。 Now declare result type onDraw() function into the application header.Now implement the code bellow to the .cpp file of this form. 现在在应用程序头文件中声明结果类型onDraw()函数,现在将以下代码实现到此形式的.cpp文件中。

 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;

 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM