"reading" a picture, convert to array

belozero

Member
Joined
Mar 4, 2010
Messages
12
Programming Experience
Beginner
Hello coders. as i said in my previous post, i am attempting to create a side-scrolling platformer. my issue now is collision detection. what i am attempting to do is create a bitmap in paint that wont be the real background, but will color-code the map. all i need to do is to have something "read" the .bmp. it needs to do this by taking multiples of (5,5) pixels and depending on the color, input data into an array. i've attaqtched a picture of my first map i've created. hopefully it helps.

green = non-moveable area (floor/walls)
lime = floor you con jump through from botom to top, but can walk on
brown = ladders, ropes
yellow = doors
gold = move to next area
 

Attachments

  • Tutorial1_START mini.bmp
    46 KB · Views: 35
well it looks like it SHOULD work, it isnt coming up with an error or anything, but i'm getting "Color= [EMPTY]" no matter what coordinates i put in :| please help.
 
GetPixel function will never return Color.Empty, there must be some other mistake in your code.
 
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     MsgBox(GetPixel(panelGameArea.Location.X + 5, panelGameArea.Location.Y + 5).ToString)
End Sub

Public Function GetPixel(ByVal x As Integer, ByVal y As Integer) As Color
End Function

below is a screenshot of the error.

EDIT: is there a reason all of the attachments i upload are all red x's?

basically, the picture is just of a standard message box that says "Color[Empty]" and i don't know why it isn't working.
 

Attachments

  • Color[Empty].bmp
    68.9 KB · Views: 30
Last edited:
Public Function GetPixel ( _
x As Integer, _
y As Integer _
) As Color
This is the signature of the Bitmap.GetPixel function, it is not something you define in your user code. See the Examples section of the documentation page I linked you to how to use the Bitmap.GetPixel method.
 
Back
Top