CopyBank problems (image2mem)

BlitzPlus Forums/BlitzPlus Programming/CopyBank problems (image2mem)

Aeronux(Posted 2007) [#1]
Alrighty... so, we've got this here code below that's acting up. It works on one machine (an older laptop) and not on another (a gaming PC equipped with a 8800GTS). We figure it's a legacy issue or something, but we're wondering what you guys think.

The code is part of a larger blending code that we use for our intro. The code works for two of three images, and then decides to die in here on the last line, CopyBank. Ideas?

Thanks ahead of time, all help is greatly appreciated!

Function image2mem(video.video, image)
	video\image =image
	video\width =ImageWidth (image)
	video\height=ImageHeight(image)
	video\buffer=ImageBuffer(image)
	
	LockBuffer video\buffer
	
	video\format=LockedFormat(video\buffer)
	video\pitch =LockedPitch (video\buffer)
	video\pixels=LockedPixels(video\buffer)
	video\size=video\pitch*video\height

	UnlockBuffer video\buffer

	If video\bank<>0 Then FreeBank video\bank
	video\bank=CreateBank(video\size)

	CopyBank video\pixels,0,video\bank,0,video\size	;where the error happens!
End Function



Andres(Posted 2007) [#2]
video\size=video\pitch*video\height

don't you need to multiplay that with (format / 8) or something?


Matty(Posted 2007) [#3]
The calculation is correct.

What I think it is is that the buffer is no longer locked and so the video\pixels bank which comes from lockedpixels(video\buffer) is not necessarily still a valid bank. Try moving the unlockbuffer after the copybank routine.


Aeronux(Posted 2007) [#4]
Okay. I moved it, and it works as far as I can tell (it doesnt crash anymore), and then the program continues on until it reaches this function here (then dies).

Function blend(video1.video, video2.video, video3.video, x, y, alpha)
time1=MilliSecs()

;crashes on alpha32, below.
alpha32(video1\bank, video1\width, video1\height, video1\pitch, video2\bank, video2\width, video2\height, video2\pitch, video3\pixels, x, y, 2, alpha)

time2=MilliSecs()
DrawImage video3\image,x,y
Return time2-time1
End Function


So... I'm thinking that it's not really loading it correctly, cause it doesnt trigger an error, until it gets to trying to actually use the video objects.

Ideas?


Matty(Posted 2007) [#5]
What is in the alpha32 function? It is not a standard blitz command, I've not seen it before.


Aeronux(Posted 2007) [#6]
unfortunately its part of a blend dll. We got it from the archives here:

http://blitzbasic.com/toolbox/toolbox.php?tool=38

i guess the source is there... idk, itd be cool to figure it out, but we might just decide to make an intro movie instead and play that somehow, instead of having the program render it for us.

thx though :D