I'm getting error 12, "segmentation violation signal," which I have no idea what that means. I ran it in a debugger and got "Exception Access Violation at ADR (dec/hex) 24/18"
In both cases it seems to be at:
jpeg_create_decompress( @jinfo )
which I think is a call to the jpeg DLL... which I doubt has any bugs?
I'm running FB 1.09.0 under Windows XP in a virtual machine (which I don't think should matter?)
Is there anyone who can shed some light on what exactly a "segmentation violation signal" is or what an ADR is? I'm pretty lost here; I have no idea what to do next.
Here is the code:
Code: Select all
on error goto jpegErr
#include "fbgfx.bi"
#include "jpeglib.bi"
const SCR_W = 640
const SCR_H = 480
const SCR_BPP = 32
dim e as long
dim el as long
declare function imageread_jpg( byval filename as zstring ptr, _
byval bpp as integer ) as FB.IMAGE ptr
print "setting screen"
sleep
screenres SCR_W, SCR_H, SCR_BPP
print "gfx screen"
sleep
dim as FB.IMAGE ptr img = imageread_jpg( "jump.JPG", SCR_BPP )
print "reading file"
sleep
if( img = 0 ) then
end 1
end if
put (0,0), img, pset
sleep
imagedestroy( img )
end
'':::::
function imageread_jpg( byval filename as zstring ptr, _
byval bpp as integer ) as FB.IMAGE ptr
print "in read"
dim as FILE ptr fp = fopen( filename, "rb" )
if( fp = NULL ) then
return NULL
end if
print "opened file"
sleep
dim jinfo as jpeg_decompress_struct
print "jinfo struc"
sleep
jpeg_create_decompress( @jinfo )
print "decompressed"
sleep
dim jerr as jpeg_error_mgr
jinfo.err = jpeg_std_error( @jerr )
print "jinfo, err"
sleep
jpeg_stdio_src( @jinfo, fp )
jpeg_read_header( @jinfo, TRUE )
jpeg_start_decompress( @jinfo )
print "about to dim row"
sleep
dim row as JSAMPARRAY
row = jinfo.mem->alloc_sarray( cast( j_common_ptr, @jinfo ), _
JPOOL_IMAGE, _
jinfo.output_width * jinfo.output_components, _
1 )
dim img as FB.IMAGE ptr
img = imagecreate( jinfo.output_width, jinfo.output_height )
dim as byte ptr dst = cast( byte ptr, img + 1 )
print "goint to while loop"
sleep
do while jinfo.output_scanline < jinfo.output_height
jpeg_read_scanlines( @jinfo, row, 1 )
'' !!!FIXME!!! no grayscale support
imageconvertrow( *row, 24, dst, bpp, jinfo.output_width )
dst += img->pitch
loop
print "done loop"
sleep
jinfo.mem->free_pool( cast( j_common_ptr, @jinfo ), JPOOL_IMAGE )
jpeg_finish_decompress( @jinfo )
print "almost done"
sleep
jpeg_destroy_decompress( @jinfo )
fclose( fp )
print "closed file"
sleep
function = img
end function
jpegErr:
e = err
el = erl
print "error #";e; " on line" ;el
sleep