It is currently Thu May 25, 2017 5:38 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Invalid Bitmap Pointer error when running compiled app
Unread postPosted: Sun Jan 29, 2017 10:55 am 
Offline

Joined: Tue Apr 19, 2016 4:43 pm
Posts: 6
First let me say I am very happy that the android compiled RFO Basic is available.
I have compiled several of my basic programs and they work fine.

But I have one basic program that has a line with:
gr.bitmap.draw img1, imgtest,hb1,vb1

It compiles with no errors.
When I attempt to run it I get a "Invalid Bitmap Pointer".
The uncompiled version of this program runs fine on my device.

I searched on this forum and only found one unanswered post.

I compiled on my third gen Moto G. Android version 5.1.1. This is a Republic wireless phone if it matters.

Thanks in advance for any help.

-Don B


Last edited by donb on Sun Jan 29, 2017 2:21 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Invalid Bitmap Pointer error when running compiled app
Unread postPosted: Sun Jan 29, 2017 11:25 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1336
Hi donb

When you load the bitmap Check the path and spelling is correct. Capitals and lower case matter in file names, when compiling.

Regards Roy


Top
 Profile  
 
 Post subject: Re: Invalid Bitmap Pointer error when running compiled app
Unread postPosted: Sun Jan 29, 2017 7:00 pm 
Offline

Joined: Sat May 14, 2011 7:43 am
Posts: 357
Location: South Africa, UK & US (Florida)
I guess you have tried this, but be sure that you check the bitmap pointer returned when you load, crop or scale your bitmap before you 'gr.bitmap.draw' it. These functions will quietly (no error report) return -1 if they were not successful, usually due to insufficient memory.
Peter


Top
 Profile  
 
 Post subject: Re: Invalid Bitmap Pointer error when running compiled app
Unread postPosted: Mon Jan 30, 2017 12:29 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1336
Hi Don

If you haven't sorted the problem, then perhaps you could post your code and then one of us may be albe to tell you whats wrong.

Roy


Top
 Profile  
 
 Post subject: Re: Invalid Bitmap Pointer error when running compiled app
Unread postPosted: Mon Jan 30, 2017 8:41 am 
Offline

Joined: Tue Apr 19, 2016 4:43 pm
Posts: 6
Roy thanks it was
a upper case lower case mismatch.
I should have remembered my UNIX disciplines

! Peter could you elaborate on Return -1 so I can incorporate this in my code?


Top
 Profile  
 
 Post subject: Re: Invalid Bitmap Pointer error when running compiled app
Unread postPosted: Mon Jan 30, 2017 8:45 am 
Offline

Joined: Tue Apr 19, 2016 4:43 pm
Posts: 6
! Here is my code I did not include the .Pngs

REM Start of BASIC! Program

hb1=40
bb1=30
indexb = 1


SPD=500
!
ar1=1
!
gr.open 255,255,255,255
gr.color 255,0,0,255,0
gr.orientation 1




label 5:


gr.rect rct1, 500,400,670,570
gr.rect bck,500,630,670,800
gr.rect rgt,500,900,670,1100
gr.rect lft, 300,900,470,1100
gr.oval fire,300,630,470,800
array.load sprite$[],"B1TW.png","B2TW.png", "B3TW.png", "B4TW.png" ,"B5TW.png","B6TW.png" ,"B7TW.png" , "B8TW.png" , "B9TW.png" , "B10TW.png" , "B11TW.png" , "B12TW.png" , "B13TW.png"
if indexb = 1 then ar1 = 1
if indexb = 2 then ar1 = 2
if indexb = 3 then ar1 = 3
if indexb = 4 then ar1 = 4
if indexb = 5 then ar1 = 5
if indexb = 6 then ar1 = 6
if indexb = 7 then ar1 = 7
if indexb = 8 then ar1 = 8
if indexb = 9 then ar1 = 9
if indexb = 10 then ar1 = 10
if indexb = 11 then ar1 = 11
if indexb = 12 then ar1 = 12
if indexb = 13 then ar1 = 13
if indexb = 13 then indexb=1





do
do
GR.TOUCH FLAG,X,Y
gr.bounded.touch touchfwd,500,400,670,570

gr.bounded.touch touchrev,500,630,670,800

gr.bounded.touch touchr,500,900,670,1100

gr.bounded.touch touchl, 300,900,470,1100
until flag



do
gr.touch flag, x,y
! until flag


if touchfwd then
indexb=indexb+1
! gr.render
endif

if touchrev then
indexb=indexb-1
! gr.render
endif


if touchr then
hb1=hb1 -20
! gr.render
endif

if touchl then
hb1=hb1+20
! gr.render
endif

until flag
gr.rect tmp ,50,30,6,15


gr.text.size 60
gr.text.bold Boolean
! gr.text.align 2

gr.text.draw t1,511,511,"FWD"
gr.text.draw t2,511,720,"BCK"
gr.text.draw t3,511,975,"RGHT"
gr.text.draw t4,350,975,"LFT"
gr.text.draw t5,350,720,"Fire"





label98:
gr.bitmap.load imgtest, sprite$[ar1]
gr.bitmap.draw img1, imgtest,hb1, vb1
! gr.render
if ar1>=9 then ar1=1
gr.bitmap.load imgtest2, sprite$[ar1+1]
gr.bitmap.draw img2, imgtest2,hb1-200,vb1-200
pause 100


gr.render
GR.BITMAP.DELETE imgtest
GR.BITMAP.DELETE imgtest2

label99:


gr.cls

go to label 5

!
label11:

pause 10

end


Top
 Profile  
 
 Post subject: Re: Invalid Bitmap Pointer error when running compiled app
Unread postPosted: Mon Jan 30, 2017 9:46 am 
Offline

Joined: Sat May 14, 2011 7:43 am
Posts: 357
Location: South Africa, UK & US (Florida)
Glad you got that sorted out. It is such an easy trap to fall into.
Regarding the "-1", this is the response in the bitmap pointer if the function has failed. It does NOT stop the program nor go to the OnError: label but DOES provide an error description in GETERROR$()
It is almost always due to there being insufficient memory for the new bitmap. It can occur in a 'compiled' apk even though the Editor version runs ok, due to the slightly different environment.
It is a reminder of how important it is to delete all bitmaps as soon as they are no longer required.

I normally check this with a little User Function during development and testing

Fn.def chk(a, a$)
If a<0
Print int$(a) +" "+a$+" fail "+ geterror$()
End
Endif
Fn.end

So in the code might appear

Gr.bitmap.create bm0,"mybitmap.jpg"
Chk(bm0, "create bm0")
Gr.bitmap.load bm1,bm0
Chk(bm1, "load bm1")
Gr.bitmap.scale,bm2,bm1,240,120
Chk(bm2, "scale bm1-bm2")

......

It is simple when finally committing the program to "live" to either "comment out" the chk() calls or replace the function with a null.

Hope this is useful. It is all covered in the Manual under the heading "Bitmap Commands". You will see that it says I was wrong in reporting that the error is not trapped by Basic (although that has not been my experience; sometimes it just rather stops Basic dead), but in view of the caveat that it will only approximately indicate the error line I prefer my way!

Peter


Top
 Profile  
 
 Post subject: Re: Invalid Bitmap Pointer error when running compiled app
Unread postPosted: Mon Jan 30, 2017 10:15 am 
Offline
User avatar

Joined: Sat Oct 04, 2014 5:45 am
Posts: 639
For what it is worth :
In addition to Peter's (-1) return value testing I suggest the following way to load sprites upfront for animation purposes if you plan to animate something.
Then it becomes only a matter of "GR.MODIFY" the bitmap pointer to display the animation at fastest speed and avoiding the eventual out of memory problem when reloading bitmaps.

Code:
INITCODE:
   GR.BITMAP.LOAD TmpPtr, "Starling.png"
   GR.BITMAP.SCALE BmpPtr1, TmpPtr, 750, 390, 1
   GR.BITMAP.DELETE TmpPtr

   !MasterBitmap ==> 750 x 390 ==> 5x3 tiles
   BmpWidth = 150
   BmpHeight = 130

   Dim Bird[14]
   For ii = 0 to 4
      GR.BITMAP.CROP Bird[ii+1], BmpPtr1, BmpWidth*ii, 0, BmpWidth, BmpHeight
   Next
   For ii = 0 to 4
      GR.BITMAP.CROP Bird[ii+1+5], BmpPtr1, BmpWidth*ii, 130, BmpWidth, BmpHeight
   Next
   For ii = 0 to 3
      GR.BITMAP.CROP Bird[ii+1+10], BmpPtr1, BmpWidth*ii, 260, BmpWidth, BmpHeight
   Next
RETURN

_________________
Download and tutorial for RFODESIGNER
https://sites.google.com/site/rfodesigner/


Top
 Profile  
 
 Post subject: Re: Invalid Bitmap Pointer error when running compiled app
Unread postPosted: Mon Jan 30, 2017 11:35 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1336
Pleased you are sorted Don

Attachment:
e1.jpg
e1.jpg [ 10.14 KiB | Viewed 214 times ]


Top
 Profile  
 
 Post subject: Re: Invalid Bitmap Pointer error when running compiled app
Unread postPosted: Mon Jan 30, 2017 5:58 pm 
Offline

Joined: Tue Apr 19, 2016 4:43 pm
Posts: 6
Thanks for the help and suggestions. I will look into incorporating these examples.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred