here's a trick to replace one colour by another lightningfast i saw that skn3[ac] did a code that do the same job in the newsletter (a real nice piece of code)
i've got 1-2ms for the entire 800x600 screen and 3ms for a 1280x1024 my code don't use any special b+ commands except some optional parameters for cretateimage() i have comented the line to replace for b2D compatibility so just comment the B+code and uncomment the b2D code if you wan't to use it in b2D/ 3d(not tested)
hope someone like this trick :)
i've got 1-2ms for the entire 800x600 screen and 3ms for a 1280x1024 my code don't use any special b+ commands except some optional parameters for cretateimage() i have comented the line to replace for b2D compatibility so just comment the B+code and uncomment the b2D code if you wan't to use it in b2D/ 3d(not tested)
;//-------------------------DEMO PART-------------------- Graphics 800,600,0,1 Global imge=CreateImage(800,600,1,2) ;blitz + ;Global imge=CreateImage(800,600) ;blitz 2D SetBuffer ImageBuffer(imge) Color 255,0,0 For a=1 To 100 Text Rnd(800),Rnd(600),"this is the color to replace" Next SetBuffer BackBuffer() DrawBlock imge,0,0 Color 255,255,255 Text 0,0,"press any key to replace the color " Flip WaitKey Global k ;call the Function WaitKey k=MilliSecs() imge=replacecolor(255,0,0,255,255,0,imge) timer=MilliSecs()-k DrawBlock imge,0,0 Color 255,255,255:Text 0,0,"taken "+timer Flip WaitKey ;----------------- End ;----------------/DEMOPART------------------// ;--------------------- ;function ;--------------------- Function replacecolor(rz,gz,bz,rr,gg,bb,image) w=ImageWidth(image) h=ImageHeight(image) temp=CreateImage(w,h,1,2) ; blitz + ;temp=CreateImage(w,h); blitz 2d SetBuffer ImageBuffer(temp) Color rr,gg,bb Rect 0,0,w,h,1 MaskImage image,rz,gz,bz DrawImage image,0,0 SetBuffer BackBuffer() FreeImage image Return temp End Function
hope someone like this trick :)