blending images?

Blitz3D Forums/Blitz3D Programming/blending images?

is it possable to blend an image into another one?
like u gather and save a screen hot of game then average it in with another
would look kinda like this?
graphics 800,600,32,1
setbuffer backbuffer()
car=loadimage("car.bmp")
dude_thats_behind_window_in_car=loadimage("dude.bmp")
while not keydown(1)
    drawimage dude_thats_behind_window_in_car,x,y
        blendimagestobackground(car)
  flip
  cls
wend

function blendimagestobackground(car)
  ;stuff goes in here
end function

any ideas how to do this?

This should work .... As you can see ... it's dog slow. The percent param should be between 0 and 1.0.

Stevie

Graphics 800,600,16,1

;load starting image
Global Image1 = LoadImage( "Screenshot003.bmp")
;load ending image
Global Image2 = LoadImage( "Screenshot006.bmp")
;create image to be displayed same size as other 2
Global Image3 = CreateImage( ImageWidth( Image1), ImageHeight( Image1) )

Dir = 10
Cur = 0

While Not KeyDown(1)

	Cur = Cur + Dir : If Cur = 0 Or Cur = 100 Dir = - Dir
	IMAGEblend( Image1, Image2 , Image3 , Floor(Cur) / 100.0 )
	DrawImage Image3, 0,0
	Flip
	
Wend

;========================================================================================
;========================================================================================
;========================================================================================

Function IMAGEblend( Image1, Image2 , Image3 , Percent# )

	IW = ImageWidth( Image1 )
	IH = ImageHeight( Image1 )

	LockBuffer ImageBuffer( Image1 )
	LockBuffer ImageBuffer( Image2 )
	LockBuffer ImageBuffer( Image3 )
		
	For j = 0 To IH- 1
		For i = 0 To IW - 1
		
			;get colour info from image 1
			argb1 = ReadPixelFast( i,j, ImageBuffer( image1 ) )
			r1 = ( argb1 And $FF0000) Shr 16
			g1 = ( argb1 And $FF00 ) Shr 8  
			b1 = ( argb1 And $FF )  
			a1 = ( argb1 And $FF000000 ) Shr 24
			
			;get colour info from image 2
			argb2 = ReadPixelFast( i,j, ImageBuffer( image2 ) )
			r2 = ( argb2 And $FF0000) Shr 16
			g2 = ( argb2 And $FF00 ) Shr 8  
			b2 = ( argb2 And $FF )  
			a2 = ( argb2 And $FF000000 ) Shr 24

			;interpolate colours from image 1 to image 2			
			r = r1 + ( r2 - r1 ) * Percent
			g = g1 + ( g2 - g1 ) * Percent
			b = b1 + ( b2 - b1 ) * Percent
			a = a1 + ( a2 - a1 ) * Percent
			
			argb = ( a Shl 24 ) Or ( r Shl 16 ) Or ( g Shl 8 ) Or b	
			WritePixelFast i , j , argb, ImageBuffer( Image3 )
		Next
	Next			

	UnlockBuffer ImageBuffer( Image1 )
	UnlockBuffer ImageBuffer( Image2 )
	UnlockBuffer ImageBuffer( Image3 )
	SetBuffer BackBuffer()
	
End Function

;========================================================================================
;========================================================================================
;========================================================================================


I would rather use a pixelperfect sprite of the image, then use EntityAlpha. That's fast enough to blend multiple images simultanously. There may be some ready to use solutions in the archives.

it isn't that slow.(only if ur using normal sized images instead of screenshots) anyway thanks stevie. ps how do u make the window inside of the fourms?

{codebox}
YOUR CODE
{/codebox}

But change the {} to []