Graphics Converter
Moderators: Chuckt, Garth, bitfogav
- Saimaster13
- I practically live here!
- Posts: 176
- Joined: Mon Aug 13, 2012 4:23 am
- Location: Sarasota, Florida [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Graphics Converter
Speaking of your graphics converter, how would I make one for myself? I want to take a picture in paint and be able to convert it pixel by pixel to an array of numbers based on the colors. How would I go about doing that? I am trying to make a game map at least 32x32 pixels big, and I need to have an array of numbers to tell the game what type of block is on that pixel.
For example, a simple 8x8 game map would look like this:
int map[8] = {B11111111, B10000001, B10111001, B10111001, B10111001, B10000001, B10000011, B11111111}
(which looks something like this:
B11111111
B10000001
B10111001
B10111001
B10111001
B10000001
B10000011
B11111111
)
where 1s are blocked paths, and 0s are open areas.
Anyway, I would want to go in paint, get 8x8 pixels or however many I wanted, then 1s as black and 0s as white then use a program to convert the data into a string. How can I do this? What program is best to use?
For example, a simple 8x8 game map would look like this:
int map[8] = {B11111111, B10000001, B10111001, B10111001, B10111001, B10000001, B10000011, B11111111}
(which looks something like this:
B11111111
B10000001
B10111001
B10111001
B10111001
B10000001
B10000011
B11111111
)
where 1s are blocked paths, and 0s are open areas.
Anyway, I would want to go in paint, get 8x8 pixels or however many I wanted, then 1s as black and 0s as white then use a program to convert the data into a string. How can I do this? What program is best to use?
Joshua
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Graphics Converter
I used Visual Basic 2010 to write my conversion program.
I will certainly try and set some time aside this weekend to modify my program to suit your code and will post details of it for you.
Let me get back to you
I will certainly try and set some time aside this weekend to modify my program to suit your code and will post details of it for you.
Let me get back to you

- Saimaster13
- I practically live here!
- Posts: 176
- Joined: Mon Aug 13, 2012 4:23 am
- Location: Sarasota, Florida [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Graphics Converter
Sounds cool! Also, just a heads up, in my code the 0s are walls and 1s are an open space.
Joshua
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Graphics Converter
Is your code above using 1's as walls and 0's as free space?Saimaster13 wrote:Sounds cool! Also, just a heads up, in my code the 0s are walls and 1s are an open space.
Also, are you using 1's as open space and 0's as walls because you are using common a anode matrix? if so, I recommend that you just use 1's as walls and 0's as open space, and then to make it work with your common anode display - just invert the data as you are sending it out to the matrix.
I have finished the converter program for you but I am having trouble exporting it to an exe that you can use. I will have to look into it more over the weekend. Here is what it does though:
You open the program, then open your 8x8 image (this one is an all red pixel face) you then click the colours that you want to convert (in this case, we only need red): You then click convert. It will convert all pixels to 1's and 0's and copy them to the clipboard: You then paste it into your code: if you had selected blue and green, you would also get that data in the output (which would be all zero's in this case due to no blue or green pixels): I just saw I need to fix the brackets in the green and blue - will do that later!
- Saimaster13
- I practically live here!
- Posts: 176
- Joined: Mon Aug 13, 2012 4:23 am
- Location: Sarasota, Florida [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Graphics Converter
The above code uses 1s as walls and 0s as spaces, but in my real code it is the opposite. I am using common anode displays, but the code uses 0s as walls so that players cannot go into any uncoded parts of the map since they are all walls (0s).
Joshua
- Saimaster13
- I practically live here!
- Posts: 176
- Joined: Mon Aug 13, 2012 4:23 am
- Location: Sarasota, Florida [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Graphics Converter
Sorry I forgot to get back to you about this. I didn't get to work on it again just yet but will hopefully get around to it soon - I don't know exactly why it is not exporting for me.
- Saimaster13
- I practically live here!
- Posts: 176
- Joined: Mon Aug 13, 2012 4:23 am
- Location: Sarasota, Florida [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Graphics Converter
No worries, I won't really be needing it soon, still working on the program basics.
Joshua
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Graphics Converter
Okay no worries. I will try again this week sometime to see if I can export it for you.
Who is online
Users browsing this forum: No registered users and 2 guests