|
-
April 1st, 2008, 05:39 PM
#1
Trying to speed up process of loading bitmap
Hello: I'm working with the drawing class and am having big time issues with slowness when using GetPixel and SetPixel. I found some great script online that I'm trying to work with http://www.codeproject.com/KB/vb/Fas...48#xx2489348xx) and it basically locks up the bitmap and stores the pixels into an array to work with.
When using it, it works for some of my bitmaps...but bombs for others. this is the error I get:
Index was outside the boundws of the array(see ''it bombs on this line: ' to see exact line below).
I understand that the array isn't big enough but i don't understand why it works for some of my bitmaps and not others.
When I save my bitmaps, I save them as 24 bit rgb color 300 dpi. I don't know much about resolutions and what format is best to save them as.
Has anyone here has experience working with bitmaps and drawing class? I could sure use any dirrection..here.
thanks,
Proctor
Code:
Public Function GetPixel(ByVal x As Integer, ByVal y As Integer) As Color
If Not Me.locked Then
Throw New Exception("Bitmap not locked.")
Return Nothing
End If
If Me.IsAlphaBitmap Then
Dim index As Integer = ((y * Me.Width + x) * 4)
Dim b As Integer = Me.rgbValues(index)
Dim g As Integer = Me.rgbValues(index + 1)
Dim r As Integer = Me.rgbValues(index + 2)
Dim a As Integer = Me.rgbValues(index + 3)
Return Color.FromArgb(a, r, g, b)
Else
Dim index As Integer = ((y * Me.Width + x) * 3)
'it bombs on this line: Dim b As Integer = Me.rgbValues(index)
Dim g As Integer = Me.rgbValues(index + 1)
Dim r As Integer = Me.rgbValues(index + 2)
Return Color.FromArgb(r, g, b)
End If
End Function
Last edited by PeejAvery; April 1st, 2008 at 06:34 PM.
Reason: Added code tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|