Quote Originally Posted by supray View Post
Hi
does PixelArray retrun a array for each horizontal row of the image ?
No, it just returns a single array for the whole image. This is for reasons of efficiency: one dimensional arrays are quite a bit faster to index than two dimensional arrays. In your code, you are mixing up the two approaches. If you are using PixelArray you would normally calculate the index as y * bitmap.Width + x. But FastPix.GetPixel and SetPixel do that calculation for you. So you could change your loop to this:
Code:
Using fp As New FastPix(b)       
     For x As Integer = 0 To b.Width - 1 Step 20
           For y As Integer = 0 To b.Height - 1 Step 20
              fp.SetPixel(x, y, Color.Orange)          
           Next
     Next
End Using
PictureBox2.Image = b
The Step value above gives the pixel spacing of the grid lines, so I guess you want something less than 200 pixels!

By the way, Graphics commands like DrawLine and DrawImage don't have the efficiency drawbacks of Bitmap.SetPixel and Bitmap.GetPixel. So you might consider drawing your grid in the Paint sub of the PictureBox, instead of using FastPix. It wouldn't surprise me if it was even more efficient. For example:
Code:
Private Sub PictureBox1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
     Using pn As New Pen(Brushes.Orange)
	pn.DashStyle = Drawing2D.DashStyle.Dot
	For x As Integer = 0 To PictureBox1.Width Step 20
		e.Graphics.DrawLine(pn, x, 0, x, PictureBox1.Height)
	Next
	For y As Integer = 0 To PictureBox1.Height Step 20
		e.Graphics.DrawLine(pn, 0, y, PictureBox1.Width, y)			
        Next
     End Using
End Sub
If you want a different dot spacing, you could set the pen's DashStyle to Custom instead of to Dot as above:
Code:
pn.DashStyle = Drawing2D.DashStyle.Custom
pn.DashPattern = {1, 3}
That would give a 1 pixel dash (a dot) with 3 pixels of space.

BB