the is no "in between" and lockbits is part of the managed space. its just that a 24bpp bitmap is effectively an array of bytes, one byte for red, one for green and one for blue and that for each pixel. lockbits/scan0 allows you to directly access the RGB value of each pixel with the performance of a normal array read/write operation. i have not checked but i am sure that fastpix is actually using lockbits/scan0, but it encapsulates this away from you which is fair enough.
but now comes the clou. i realized that the correct way to do this is not accessing pixels but instead using a color transformation matrix when calling drawimage.
try this out:
Code:Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim img As New Bitmap("c:\kill\test.jpg") Dim matrix As New Imaging.ColorMatrix( New Single()() {New Single() {1, 0, 0, 0, 0}, New Single() {0, 1, 0, 0, 0}, New Single() {0, 0, 0, 0, 0}, New Single() {0, 0, 0, 1, 0}, New Single() {0, 0, 0, 0, 1} }) Dim Attributes As New Imaging.ImageAttributes Attributes.SetColorMatrix(matrix) Using g As Graphics = PictureBox1.CreateGraphics g.DrawImage(img, New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, Attributes) End Using End Sub




Reply With Quote