How is Simon's example in the Newsletter so fast? This is SLIGHTLY faster than Blitz commands, but nowhere near as fast as his. As far as I can tell, he isn't doing anything different from this: Write your data to a bank, then copy the bank to a buffer.
Actually, My ReadPixel is twice as fast, and my WritePixel is much slower.
Actually, My ReadPixel is twice as fast, and my WritePixel is much slower.
Graphics 640,480,32,2 buffer=BackBuffer();ImageBuffer(i) w=GraphicsWidth();ImageWidth(i) h=GraphicsHeight();ImageHeight(i) start=MilliSecs() LockBuffer buffer For x=0 To w-1 For y=0 To h-1 ReadPixelFast(x,y,buffer) WritePixelFast x,y,RGB(0,0,255),buffer Next Next UnlockBuffer buffer time1=MilliSecs()-start Flip start=MilliSecs() LockBuffer buffer pixels=LockedPixels(buffer) pitch=LockedPitch(buffer) bits=LockedFormat(buffer) fakepixels=CreateBank(w*h*bits) CopyBank pixels,0,fakepixels,0,w*h*bits For x=0 To w-1 For y=0 To h-1 readpixelfaster x,y,fakepixels,pitch,bits WritePixelFaster x,y,RGB(255,0,255),fakepixels,pitch,bits Next Next CopyBank fakepixels,0,pixels,0,w*h*bits FreeBank fakepixels UnlockBuffer buffer time2=MilliSecs()-start Flip Notify "Blitz: "+time1+Chr(10)+"Faster?: "+time2 End Function ReadPixelFaster(x,y,pixels,pitch,bits) offset=y*pitch+bits*x Select bits Case 4 Return PeekInt(pixels,offset) Case 2 Return PeekShort(pixels,offset) End Select End Function Function WritePixelFaster(x,y,ARGB,pixels,pitch,bits) offset=y*pitch+bits*x Select bits Case 4 PokeInt pixels,offset,ARGB Case 2 PokeShort pixels,offset,ARGB End Select End Function