Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Bitmap Value Lost?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-16-2008, 02:47 PM
Junior Member
 
Join Date: May 2008
Posts: 19
Question Bitmap Value Lost?

Hi all.

I finally buy this wonderfull app.
Now i have more doubts than ever!

I have problems using imagelib library.
The problem is the following, when i create a bitmap with backdrop image, I create a drawer and paint a bit image over previous, using drawer.drawimage1
When I first time, try to draw in a gamewindow.drawbackgroundimage2, all seems to be correct, but the second time, value doesn't work.
I have to use an intermediate image for storing value of backdropbitmap and reassign every time.

The code is follow.

Code:
Sub UpdateForm(x, y)
	CellBitmap.New1(AppPath & "\images\cell.png")
	'BackdropBitmap.New3(TmpBackdropBitmap.Value)
	CellRectangle.New1(0, 0, CellBitmap.Width, CellBitmap.Height)
	BackdropRectangle.New1(x, y, CellBitmap.Width, CellBitmap.Height)
	GameFormDrawer.New2(BackdropBitmap.Value, B4PObject(5))
	GameFormDrawer.DrawImage1(CellBitmap.Value, CellRectangle.Value, BackdropRectangle.Value, false)
	GameFormDrawer.Refresh2(BackdropRectangle.Value)
	'TmpBackdropBitmap.New3(BackdropBitmap.Value)
	GameGameWindow.DrawBackgroundImage2(BackdropBitmap.Value)
End Sub
This methods seems to work, but i wonder why i have to create new BackdropBitmap referencing to previous (TmpBackdropBitmap).

I commented 2 lines needed to work, and i wonder why I need this 2 lines.

Any Clues?

Thanks in advance.

fjsantos.
Reply With Quote
  #2 (permalink)  
Old 06-16-2008, 03:37 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 702
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Could you post your whole code, it would be easyer to look what happens, the kind of objects and their context.

What function is this:
GameGameWindow.DrawBackgroundImage2(BackdropBitmap .Value)
I don't know this one.

Best regards
__________________
Klaus
Switzerland
Reply With Quote
  #3 (permalink)  
Old 06-16-2008, 04:37 PM
Junior Member
 
Join Date: May 2008
Posts: 19
Default

Hi Klaus

Thanks for helping.

Code is a bit large so I extract important part.

Code:
Sub App_Start
	GameFormLib.New1("GameForm", B4PObject(1))
	GameGameWindow.New1("GameForm", 0, 0, WIDTH, HEIGHT)
	GameGameWindow.DrawBackgroundImage(AppPath & "\images\backdrop.png")
	ObjectDoor.New1(False)
	ObjectDoor.FromControl("GameForm")
	ObjectDoor.SetProperty("KeyPreview", True)
	TmpBackdropBitmap.New1(AppPath & "\images\backdrop.png")
	GameForm.Image = TmpBackdropBitmap.Value
	GameForm.Show
	GameForm.ForeLayer = True
	CreateCloseButton
	CreateNewCell
	UpdateForm1
	MoveCellTimer.Enabled = True
End Sub

Sub UpdateForm1
	CellBitmap.New1(AppPath & "\images\cell.png")
	CellRectangle.New1(0, 0, CellBitmap.Width, CellBitmap.Height)
	BackdropRectangle.New1(0, 0, CellBitmap.Width, CellBitmap.Height)
	GameFormDrawer.New1("GameForm", True)
End Sub

Sub UpdateForm(x, y)
	BackdropRectangle.X = x
	BackdropRectangle.Y = y
	GameFormDrawer.DrawImage1(CellBitmap.Value, CellRectangle.Value, BackdropRectangle.Value, False)
	GameFormDrawer.Refresh2(BackdropRectangle.Value)
	GameGameWindow.DrawBackgroundImage2(GameForm.Image)
End Sub
The first time GameGameWindow draws GameForm.Image all seems to be ok, but the second one, its fails 'Parameter is not valid'.

Thanks, fjsantos.
Reply With Quote
  #4 (permalink)  
Old 06-16-2008, 05:08 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,186
Default

Can you zip and upload your complete project?
There may be an issue here with how images are stored internally.
Reply With Quote
  #5 (permalink)  
Old 06-16-2008, 05:17 PM
Junior Member
 
Join Date: May 2008
Posts: 19
Default

Of course I can.

Here it go.

Best Regards, fjsantos.
Attached Files
File Type: zip Energy.zip (39.2 KB, 8 views)
Reply With Quote
  #6 (permalink)  
Old 06-16-2008, 06:07 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 702
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Erel is of course more competent to solve your problem than myself. I have never used the Sprite library.

Best regards
__________________
Klaus
Switzerland
Reply With Quote
  #7 (permalink)  
Old 06-16-2008, 06:52 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,186
Default

This is the same problem as this one: fullscreen problem
DrawBackgroundImage2 disposes the image after drawing it on the GameWindow.

The solution is to create a new copy of the image (with a Bitmap object) and then pass it.
It will be fixed in the next update of the Sprite library.

BTW, why are you setting ForeLayer to true? It is hidden by the GameWindow.
There is a problem with the designer code in your source file.
You can use the attached file instead.
Attached Files
File Type: sbp Energy.sbp (4.9 KB, 3 views)
Reply With Quote
  #8 (permalink)  
Old 06-16-2008, 07:04 PM
Junior Member
 
Join Date: May 2008
Posts: 19
Default

Hi all.

Yep i suppose that image was disposing after drawimage. The code was only a draft playing around with forms and gamewindows (I have to learn a lot yet!).

Thanks a lot for improve the code!!

Klaus thanks to you too for your interest and help!!

Best Regards, fjsantos.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
i lost treeview.dll after loading V6 dan kabestan Questions & Help Needed 1 01-03-2008 12:57 PM
Performance on Bitmap? Roadrunner Questions & Help Needed 9 12-09-2007 03:19 PM
Background-Color on Bitmap.new2 Roadrunner Bug Reports 1 12-08-2007 04:08 PM
Out of Memory error while loading bitmap HARRY Questions & Help Needed 3 05-15-2007 01:12 PM
Image gets lost with orientation change HARRY Questions & Help Needed 7 05-14-2007 10:19 AM


All times are GMT. The time now is 01:40 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0