BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
Hi All,
I'm trying to make this bit of code work:
DIM SHARED mtn(1 TO 1564)
BLoad "mtn.vga", VarPtr(mtn(1))
But it crashes the app every time and fbdebugger tells me it is an "EXCEPTION_ACCESS_VIOLATION"
I believe all I'm trying to do here is load mtn.vga into the array mtn at position 1?
Any ideas why this is causing me issues?
Thanks!
Dave
I'm trying to make this bit of code work:
DIM SHARED mtn(1 TO 1564)
BLoad "mtn.vga", VarPtr(mtn(1))
But it crashes the app every time and fbdebugger tells me it is an "EXCEPTION_ACCESS_VIOLATION"
I believe all I'm trying to do here is load mtn.vga into the array mtn at position 1?
Any ideas why this is causing me issues?
Thanks!
Dave
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
Dim Shared (As "what?") a Type is needed here ...
Code: Select all
Dim Shared As Any Ptr mtn(1 To ...)
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
-lang qb ?
-lang fblite ?
(in qb, DIM by default => single = 4 Bytes)
(in fblite, DIM by default => integer = 4 Bytes)
If yes, how do you compute the size of mtn() ?
-lang fblite ?
(in qb, DIM by default => single = 4 Bytes)
(in fblite, DIM by default => integer = 4 Bytes)
If yes, how do you compute the size of mtn() ?
Last edited by fxm on Dec 03, 2016 21:10, edited 1 time in total.
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
fxm,
you should know me better than that, by now ... never -lang "QB"
only -lang "FB".
you should know me better than that, by now ... never -lang "QB"
only -lang "FB".
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
I tried added As Integer, doesn't seem to make a different.
Yes, -lang qb. Hmmm...not sure how to do that?
Yes, -lang qb. Hmmm...not sure how to do that?
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
@MrSwiss - I am migrating an old QuickBasic project to FreeBasic, doing -lang qb so that I can get it up and running as quickly as possible, then work on moving to FB syntax. :)
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
@MrSwiss,
My previous post was for davidshq.
@davidshq,
How do you compute the size of mtn() ?
Is there DEFINT before in the code?
In qb, mtn() size (in bytes) >= 4 + (w * h * bpp)
My previous post was for davidshq.
@davidshq,
How do you compute the size of mtn() ?
Is there DEFINT before in the code?
In qb, mtn() size (in bytes) >= 4 + (w * h * bpp)
Last edited by fxm on Dec 03, 2016 21:32, edited 2 times in total.
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
@davidshq,
IMO, you are creating double work: to FB -lang "QB" then to FB -lang "FB",
simply makes no sense ...
IMO, you are creating double work: to FB -lang "QB" then to FB -lang "FB",
simply makes no sense ...
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
@fxm - In QuickBasic I've never had to do that...so I don't think it does. The .vga file is a BSAVE, VGA resolution.
@MrSwiss - There are a lot of changes to make if I move to FB, with the -lang qb I have only two or three remaining - namely, adding a sound library and loading these BSAVE images.
@MrSwiss - There are a lot of changes to make if I move to FB, with the -lang qb I have only two or three remaining - namely, adding a sound library and loading these BSAVE images.
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
What is the size of the image to load ?
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
Hmmm...I don't have any dimensions for them. I was hoping just to use the files as the memory dumps they are, but it sounds like it may be easier to export them to a modern format like jpg and then load them in - since I have a way to figure out dimensions then...as I don't know of any way to extract the dimensions.
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
And exactly these tasks are so much simpler, in -lang "FB".davidshq wrote:namely, adding a sound library and loading these BSAVE images
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
I get the dimensions with lang "qb"
But get an error with bload (64 bit) and no picture(32 bit)
All OK with lang "fb"
But get an error with bload (64 bit) and no picture(32 bit)
All OK with lang "fb"
Code: Select all
#lang "qb"
screen 19,32
Function GetSize(bmp As String,byref x as long,byref y as long) As long 'get bitmap width/height
if Open (bmp For Binary access read As #1)=0 then
Get #1, 19, X
Get #1, 23, Y
Close #1
else
print bmp;" not found"
end if
GetSize= x*y
End Function
dim as string file
file = "num6.bmp" '<------------- YOUR FILE
dim as long w,h
if GetSize(file,w,h) then print w,h else print "ERROR":sleep:end
redim as long a((w+1)*(h+1))
bload(file,@(a(0)))
put(0,0),@a(0)
sleep
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
@MrSwiss - I won't disagree that these tasks are simpler in FB, the issue is if I use FB then lots more of the QB code becomes invalid.
@dodicat - Thanks for the code snippet! It seems to "load" the image, but it shows a bunch of pixels and not the image, it also gives the dimensions as: 1 and 128.
@dodicat - Thanks for the code snippet! It seems to "load" the image, but it shows a bunch of pixels and not the image, it also gives the dimensions as: 1 and 128.
Re: BLOAD / VARPTR Causing EXCEPTION_ACCESS_VIOLATION
How sure are you of your .vga file? Are %100 sure it is a valid bmp image?
Rename it xxx.bmp and try to load it in paint or another graphics program.
@dodicat:
According to the help file in lang QB the second paramter of the screen statement is 'colormode' and it is ignored. I'm not sure why you include it.
Your code does work with bmp files 8bit bit depth. It shows the picture with slightly off colors.
Rename it xxx.bmp and try to load it in paint or another graphics program.
@dodicat:
According to the help file in lang QB the second paramter of the screen statement is 'colormode' and it is ignored. I'm not sure why you include it.
Your code does work with bmp files 8bit bit depth. It shows the picture with slightly off colors.