It is currently Sun Jul 05, 2020 6:35 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Using #PB_any give compiler error
PostPosted: Mon Apr 16, 2018 7:42 pm 
Offline
User
User
User avatar

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 91
Location: Netherlands
I had this problem a couple of times. I load a image and then i grab a array image from that image but the compiler stops,and asking me if this is what i want. To have a high number for that image.

E.g
    Global Dim JewColors(6)

    Global Jewels = LoadImage(#PB_Any,"graphics\Jewels.bmp")

    For x = 0 To 6
    Jewcolors(x) =CreateImage(#PB_Any,32,32)
    GrabImage(JewColors(x),Jewels,(x*32)+1,y,(x*32)+32,y+31)
    Next


In this example code grabed from source. #PB_any give in the first line a number of 28732912 This is higher then the 100000 is given by the compiler. But the compiler is not complaining about it. Then in the for next loop. The first Array element Jewcolors(0) got a number 28706608. Still no warning from the compiler. Then the next line GrabImage is comming and the compiler start Asking if this is the right number cause its higher then 100 000 and halted the compiling. In the documentation state that i can use the #PB_Any. And when i check the variables all of them are higher then the limit of 100000. There is absolute no problem, only when using a Array this problem is occuring.
Is there a work around for or is this solved in the next release.

_________________
From my first self made computer till now I stil like computers.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Mon Apr 16, 2018 7:44 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14065
Location: France
I don't think there is a bug here, could you post a small snippet showing the bug ?


Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Mon Apr 16, 2018 9:24 pm 
Offline
User
User
User avatar

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 91
Location: Netherlands
Thats the problem the code is the snipe
Code:
Global Dim JewColors(6)

;The #PB_Any give out the number 28732912
Global Jewels = LoadImage(#PB_Any,"graphics\Jewels.bmp")

For x = 0 To 6
;The #PB_Any give out the number 28706608 For element 0 Element 1 is not comming up the debugger stop the program
Jewcolors(x) =CreateImage(#PB_Any,32,32)
;The message under the IDE window says error number to high over 100000
GrabImage(JewColors(x),Jewels,(x*32)+1,y,(x*32)+32,y+31)
Next


The following image showed what kind of error i got. It made no sence to me.
[img]http://bartfernhout.magix.net/public/images/PBError.jpg
[/img]

_________________
From my first self made computer till now I stil like computers.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Mon Apr 16, 2018 10:16 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14065
Location: France
You don't use GrabImage correctly. See the doc:

Code:
A number to identify the new image. #PB_Any can be specified to auto-generate this number.

Note: The number of an existing image created using #PB_Any can not be used as the target image. Instead, the existing image must be freed and a new number generated by passing #PB_Any here.


http://www.purebasic.com/documentation/ ... image.html


Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Tue Apr 17, 2018 12:35 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2314
Location: Singapore
bfernhout wrote:
In the documentation state that i can use the #PB_Any...
The PureBasic Manual wrote:
GrabImage()

Parameters
#Image2: A number to identify the new image. #PB_Any can be specified to auto-generate this number.
Note: The number of an existing image created using #PB_Any cannot be used as the target image...

The GrabImage() function will create the new image automatically:
Code:
Global Dim JewColors(6)

Global Jewels = LoadImage(#PB_Any,"graphics\Jewels.bmp")

For x = 0 To 6
  ;Jewcolors(x) = CreateImage(#PB_Any,32,32)  ;not required
  Jewcolors(x) = GrabImage(Jewels, #PB_Any ,(x*32)+1,y,(x*32)+32,y+31)
Next

Edit: Error in code.

_________________
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Last edited by TI-994A on Tue Apr 17, 2018 12:37 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Tue Apr 17, 2018 12:48 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3710
Location: Utah, USA
TI-994A wrote:
bfernhout wrote:
In the documentation state that i can use the #PB_Any...
The PureBasic Manual wrote:
GrabImage()

Parameters
#Image2: A number to identify the new image. #PB_Any can be specified to auto-generate this number.
Note: The number of an existing image created using #PB_Any cannot be used as the target image...

The GrabImage() function will create the new image automatically:
Code:
Global Dim JewColors(6)

Global Jewels = LoadImage(#PB_Any,"graphics\Jewels.bmp")

For x = 0 To 6
  ;Jewcolors(x) = CreateImage(#PB_Any,32,32)  ;not required
  Jewcolors(x) = GrabImage(Jewels, #PB_Any ,(x*32)+1,y,(x*32)+32,y+31)
Next


Nice, simple and to the point. :)


If the images that are created using #PB_Any need to be updated by replacing them with a newly created image, it is good to remember that the previous images need to be freed with FreeImage().


@Edit: Removed a bad and incorrect code sample. Thanks TI-994A.

_________________
Image


Last edited by Demivec on Tue Apr 17, 2018 4:26 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Tue Apr 17, 2018 1:00 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2314
Location: Singapore
:wink:

_________________
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Last edited by TI-994A on Tue Apr 17, 2018 1:45 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Tue Apr 17, 2018 1:32 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3710
Location: Utah, USA
@TI-994A: Please excuse my sloppiness, you're absolutely correct. Darn these eyes of mine. :wink:

_________________
Image


Last edited by Demivec on Tue Apr 17, 2018 2:06 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Tue Apr 17, 2018 1:42 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2314
Location: Singapore
Demivec wrote:
Darn these eyes of mine. :wink:
...of ours!

EDIT: Now, it lives on only in yours. :lol:

_________________
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Tue Apr 17, 2018 12:23 pm 
Offline
User
User
User avatar

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 91
Location: Netherlands
All thanks for the intell. The helpfile is here a bit in the dark. So i did it trough the helpfile making this. i already changed it.
Code:
Global Dim JewColors(6)

Global Jewels = LoadImage(#PB_Any,"graphics\Jewels.bmp")

For x = 0 To 6
  ;Jewcolors(x) = CreateImage(#PB_Any,32,32)  ;not required
  Jewcolors(x) = GrabImage(JewColors(x), #PB_Any ,(x*32)+1,y,(x*32)+32,y+31)
Next


The other problem is myself. I am used to work with Blitz3D and there is the declaration of the image a must. As soon as you free up the image Blitz3D lose its pointer to the memory location where the image is stored. Blitz3D need a live action memory allocation. Therefore the pointing to a image is 2 sided. Firts the Variable who got the image assigned to it. Get the pointer to the memory where the real pointer of the image is. And that part is changing every time.
This was also one of the reasons why a game made in Blitz3D, who is running longer than say one hour. Jammed the computer by never freeed up any Image heap space. The cleaning is only done when te game is terminated.

The basic of cleaning up the images that is not needed is just a good thing. And a good practice to do.

You know the way the help file discribe this is a bit puzzeling:
Code:
Result = GrabImage(#Image1, #Image2, x, y, Width, Height)


A beter way to discribe it is:
Code:
NewImage = GrabImage(#ImageSource,#PB_Any,x,y,Width,Height)

;Or if user make the number by himself
;Where noted the #NewImage is assign by user as assigned ImageNumber
Result = GrabImage(#ImageSource,#NewImage,x,y,Width,Height)

Then it make a lot more sence.

Thanks a lot guys.

_________________
From my first self made computer till now I stil like computers.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Tue Apr 17, 2018 12:50 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2314
Location: Singapore
@bfernhout: There was an error in my earlier post.

The GrabImage() function should read as follows:
Code:
Jewcolors(x) = GrabImage(Jewels,#PB_Any,(x*32)+1,y,(x*32)+32,y+31)

With the variable Jewels holding the source image.

_________________
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Tue Apr 17, 2018 10:11 pm 
Offline
User
User
User avatar

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 91
Location: Netherlands
Thanks very much.

I do understand it now. I have to learn a lot before i could understand PB a little. The same time i think needed to start writing error free code. (Witch is never. Even if i think its ok. Always some thing is popping up. And I was always the one who make the thinking error. Or just forgot something to put in.

Stil its a good piece of program to work in. And a lot of things working perfect. The only drawback is the IDE. You can do al lot in it but smal things are left out.

E.g.
When i am busy in a project i only see the procdures in the file i am busy in, and not all the procedures in the project.
Stil i like the PB. Its much better the Blitz3D and DarkBasic Pro. (Who are both died)

Thanks for all the help.

_________________
From my first self made computer till now I stil like computers.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Wed Apr 18, 2018 11:02 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2314
Location: Singapore
bfernhout wrote:
...i think needed to start writing error free code...

You'd be the first! :lol:

Moreover, programming might lose its magic if there were no errors to hunt down and debug. That's half the fun.

_________________
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Sat Apr 21, 2018 3:28 pm 
Offline
User
User
User avatar

Joined: Mon Feb 26, 2018 10:41 pm
Posts: 91
Location: Netherlands
I think you are right. :lol:

_________________
From my first self made computer till now I stil like computers.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using #PB_any give compiler error
PostPosted: Sun Jun 03, 2018 9:14 am 
Offline
Addict
Addict
User avatar

Joined: Thu Feb 09, 2006 11:27 pm
Posts: 2544
Just had a look into the help files (in german language), the text for the return value of CreateImage seems to be wrong, as it says "#PB_Any [...] wird die generierte Nummer zurückgegeben." where "Nummer" is identified as the image number.

Anyhow it would be fine to have access to the created image via it's number to be able to use all image functions easily.

Code:
procedure ImageProcessing(image)
   protected temp   

   temp=CreateImage(#PB_Any,2000,2000)    allocates memory

   process image using a temporary image...

   FreeImage("temp")               how to free the memory again?
endprocedure


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye