QUOTE(mark.bottomley @ 1 Jul, 2009 - 04:25 PM)

You are doing too much math inside the loop. Use 2 loops as it will be much faster (I don't know whether it will make it to 30x). I'm not sure if the pictures are stored in row or column major order so experiment with exchanging the nesting of the loops - I believe the one below is the faster one. This setup only changes the value you care about - Alpha channel.
Also define the variables OUTSIDE the loop as they get recreated and destroyed for each iteration.
e.g.
CODE
Dim rowMax as Integer = Key.Height - 1
Dim colMax as Integer = Key.Width - 1
For row = 0 to rowMax
For col = 0 to colMax
Main.GetPixel(col, row).A = Key.GetPixel(col, row).R
Next
Next
Thanks for your reply mark.
Actually this function was only a small part of the code. which i managed to override all in all. However, I found out that what is really causing my code to go slow is the WriteByte. i am trying to write to an unmanaged Array in the memory (i only have its IntPtr) and it is an array of bytes. so i am using:
CODE
for index as integer = 0 to byteCount-1 'byteCount is ByteArray.length
Marshal.WriteByte(ArrayPtr,index,ByteArray(index))
next
this code is taking alot of time. it is awfully slow. Any alternative to do the same thing?