언어 설정

Menu
Sites
Language
convert png to bitmap

 

Hi :)

I'm writing code for wallpaper in form like this

 


result
MorningAlarmForm::OnDraw()
{
    result r;
	Canvas* canvas=this->GetCanvasN();

	//background
	Image img;
	Bitmap* pBitmap = null;
	Canvas* pCanvas = null;
	String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"img/Homescreen_sunny_day_bg.png";

	img.Construct();

	// Decodes the image
	pBitmap = img.DecodeN(filePath, BITMAP_PIXEL_FORMAT_R8G8B8A8 );
	//pBitmap = pAppResource->GetBitmapN(filePath, BITMAP_PIXEL_FORMAT_ARGB8888);



	r= canvas->DrawBitmap(Rectangle(0, 66,480,800-138), * pBitmap);
	if (IsFailed(r))
	{
	AppLog("Draw Bitmap Failed");
	return r;
	}
	return r;
}

 

But, When I run this code, I get this log

11-28 10:06:27.150 : INFO / MorningAlarm ( 7263 : 7263 ) : int OspMain(int, char **)(20) > Application started.
11-28 10:06:27.170 : ERROR / Tizen::Base::Collection ( 2421 : 2421 ) : virtual const Tizen::Base::Object* Tizen::Base::Collection::ArrayList::GetAt(int) const(238) > [E_OUT_OF_RANGE] The index(2) MUST be greater than or equal to 0 and less than the number of elements(2).
11-28 10:06:27.190 : ERROR / Tizen::Ui ( 7263 : 7263 ) : bool Tizen::Ui::_Control::IsVisible() const(2943) > [E_SYSTEM] This control should be attached to the main tree.
11-28 10:06:27.210 : ERROR / Tizen::Io ( 7263 : 7263 ) : result Tizen::Io::_DirEnumeratorImpl::MoveNext()(143) > [E_END_OF_FILE] End of directory entries
11-28 10:06:27.210 : ERROR / Tizen::App ( 7263 : 7263 ) : virtual Tizen::Graphics::Bitmap* Tizen::App::_AppResourceBitmap::GetBitmapN(const Tizen::Base::String&, Tizen::Graphics::BitmapPixelFormat, bool) const(84) > [E_FILE_NOT_FOUND] The specified file does not exist.
11-28 10:06:27.210 : ERROR / Tizen::Graphics ( 7263 : 7263 ) : result Tizen::Graphics::Canvas::DrawBitmap(const Tizen::Graphics::Rectangle&, const Tizen::Graphics::Bitmap&)(257) > [E_INVALID_ARG] The source bitmap is invalid.
11-28 10:06:27.210 : INFO / MorningAlarm ( 7263 : 7263 ) : virtual result MorningAlarmForm::OnDraw()(127) > Draw Bitmap Failed

 

 

I think the reason is to convert png to bitmap.

What should I do ?

Please let me know

 

Best Regards,

Jenny

 

 

 

Responses

4 댓글

It says "

The specified file does not exist.

"

Well, If it does then you cannot access this folder. Anyway.. the better solution is to place the "img" folder inside the "data" folder and access it like this

	String filePath = Tizen::App::App::GetInstance()->GetAppDataPath() + L"img/Homescreen_sunny_day_bg.png";
Pushpa G

Also make sure you have made the form's background color transparent by writing the following code in fileframe.cpp, oninitializing()

after

pTestWallPaperForm->Initialize();

pTestWallPaperForm->SetBackgroundColor(0X000000);

And then yes i tested putting the image in data folder and used the following code:

String filePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/image1.png";

It worked and showed the background bitmap on the form.

Try it

Kamil N

You can put bitmap in the resources and read it (for example in OnInitializing method)

AppResource *pAppResource = Application::GetInstance()->GetAppResource();
pBackground = pAppResource->GetBitmapN("wallpaper.png");

 

Slawek Kowalski

Better to do loading stuff outside OnDraw()