Global gfx Global frame Graphics 640,480,16,1 gfx = LoadImage("monkey4.jpg") ; 640x480 background image frame = LoadImage("frame4.png") ; 640x480 overlay image, color 0,255,0 transparent MaskImage frame,0,255,0 Global overlay_image = CreateImage(1,1) ; temp image for overlay While Not KeyHit(1) If KeyHit(15) create_overlay(100,100,540,380) ; create it display_overlay(100,100) ; show it and deal with inventory EndIf DrawImage gfx,0,0 Flip Wend ; Create the overlay Function create_overlay(xstart,ystart,xend,yend) FreeImage overlay_image width = xend - xstart height = yend - ystart overlay_image = CreateImage(width,height) CopyRect xstart,ystart,width,height,0,0,ImageBuffer(gfx),ImageBuffer(overlay_image) SetBuffer ImageBuffer(overlay_image) LockBuffer For y = 0 To height For x = 0 To width temp1 = ReadPixel(x,y) orgb = (temp1 And 255) orgg = (temp1 And 65280) Shr 8 orgr = (temp1 And 16711680) Shr 16 temp2 = (orgr + orgg + orgb) Shr 3 ; Average red/green/blue, and darken WritePixel x,y,temp2 + (temp2 Shl 8) + (temp2 Shl 16) ; write greyscale pixels Next Next UnlockBuffer SetBuffer BackBuffer() End Function ; Show the overlay and the function where you ; can deal with all inventory code. Function display_overlay(ox,oy) While Not KeyHit(15) DrawImage gfx,0,0 DrawImage overlay_image,ox,oy DrawImage frame,0,0 Flip Wend End Function
Working, completely different and a lot less memory intensive.
Have fun :)
Tracer