Graphics Converter

Post here to let others know of a project you're working on.

Moderators: Chuckt, Garth, bitfogav

Post Reply [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
User avatar
Saimaster13
I practically live here!
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

Post by Saimaster13 » Tue Oct 09, 2012 10:54 am

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?
Joshua

User avatar
brad
Site Admin
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

Post by brad » Thu Oct 11, 2012 11:00 pm

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 :)

User avatar
Saimaster13
I practically live here!
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

Post by Saimaster13 » Fri Oct 12, 2012 12:19 am

Sounds cool! Also, just a heads up, in my code the 0s are walls and 1s are an open space.
Joshua

User avatar
brad
Site Admin
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

Post by brad » Fri Oct 12, 2012 9:29 am

Saimaster13 wrote:Sounds cool! Also, just a heads up, in my code the 0s are walls and 1s are an open space.
Is your code above using 1's as walls and 0's as free 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):
screen-capture-15.png
screen-capture-15.png (14.55 KiB) Viewed 13967 times
You then click convert. It will convert all pixels to 1's and 0's and copy them to the clipboard:
screen-capture-12.png
screen-capture-12.png (17.81 KiB) Viewed 13967 times
You then paste it into your code:
screen-capture-13.png
screen-capture-13.png (19.27 KiB) Viewed 13967 times
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):
screen-capture-14.png
screen-capture-14.png (21.33 KiB) Viewed 13967 times
I just saw I need to fix the brackets in the green and blue - will do that later!

User avatar
Saimaster13
I practically live here!
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

Post by Saimaster13 » Fri Oct 12, 2012 12:17 pm

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

User avatar
Saimaster13
I practically live here!
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

Post by Saimaster13 » Mon Oct 15, 2012 10:32 pm

I just changed the code to 0s = spaces and 1s = walls
Joshua

User avatar
brad
Site Admin
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

Post by brad » Tue Oct 16, 2012 5:17 am

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.

User avatar
Saimaster13
I practically live here!
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

Post by Saimaster13 » Tue Oct 16, 2012 5:21 am

No worries, I won't really be needing it soon, still working on the program basics.
Joshua

User avatar
brad
Site Admin
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

Post by brad » Tue Oct 16, 2012 8:46 pm

Okay no worries. I will try again this week sometime to see if I can export it for you.

Post Reply
[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
[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

Who is online

Users browsing this forum: No registered users and 2 guests