Arduino and Swordfish Basic Graphic 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
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

Arduino and Swordfish Basic Graphic Converter

Post by brad » Thu Nov 29, 2012 9:46 pm

Hi everyone, I have been slowly working on my Graphic Conversion program for Arduino and Swordfish IDE's.

Basically it will allow you to open up a graphic (most probably one you have drawn yourself for a game you are making for a microcontroller) and you can then convert it into individual 1's and 0's organised into either bytes, words or longwords. It will output the data to either Swordfish Basic arrays or Arduino arrays.

It will be quite a handy project for those making their own games - right Joshua!

Hopefully it will be finished this weekend but here's a screenshot of the work in progress:
screen-capture.png
screen-capture.png (40.75 KiB) Viewed 17566 times

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[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: Arduino and Swordfish Basic Graphic Converter

Post by MrDEB » Sun Dec 02, 2012 10:23 pm

can't wait to see this

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: Arduino and Swordfish Basic Graphic Converter

Post by brad » Sun Dec 02, 2012 10:56 pm

Well wait no more! Here's the initial release:
Arduino and Swordfish Graphic Converter.exe.zip
(46.27 KiB) Downloaded 516 times
screen-capture.png
screen-capture.png (35.96 KiB) Viewed 17554 times
You will need Visual Basic Extensions installed. Try loading it up and if it gives you any errors please let me know.

It's quite straight forward to use the only real requirement is that the width of your graphic is divisible by 8, 16 or 32 (because the output data will be in one of these formats). Just draw your image up in Paint.

You can then select which colors you want to actually get spit out in the output (for example, for your RED / GREEN matrix game Joshua, you would only need the red and green data) As you select these it will update the program memory required for the graphic.

Select what programming language you are using (it will update the output data types to suit) and then select which output data type you want (lots of 8bits, 16bits or 32bits)

Type in the name that you want your array to be (for example if you have a picture of a room in a game you are making, you might call it Room1)

Then click convert (and wait a few seconds - or longer depending on how big the image is and the speed of your computer) A message box will appear telling you that the data has been copied to the clipboard. All you need to do is paste it into swordfish or arduino.

Joshua - let me know if the output data is incorrect - I did some research and even tested it so it seems to be okay though.

And lastly, in a later release I will add the option for you to select which part of the graphic is a barrier (for example you might not want to be able to walk through the red walls, you could just do this in your code to watch out for a certain color but in games I have made sometimes you want to be able to walk through colors even though they are the same color as ones you can't walk through (if that makes sense...)

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: Arduino and Swordfish Basic Graphic Converter

Post by Saimaster13 » Mon Dec 03, 2012 1:14 pm

This is a nice program. It may also be useful if you could choose whether the data outputs a color as a 1 or a 0. (example: red black red is either 101 or 010.)


I found a few few problems/bugs though:

I put red and green in a picture and the program switched the data (red is green, green is red.)
I tried putting yellow into a picture and it did not do red or green.
I put orange in the picture and only updated MyDataGreen (so probably red.)

The data set the program outputted:
const prog_uint8_t MyDataRed[8]PROGMEM={0b11111001, 0b11111101, 0b11111101, 0b11111101, 0b11111101, 0b11111001, 0b11110000, 0b11111110};
const prog_uint8_t MyDataGreen[8]PROGMEM={0b11000110, 0b10111010, 0b10111010, 0b11111010, 0b11111010, 0b11110110, 0b11101111, 0b10000001};


Bugs or no bugs, this is still an awesome program! It'll make map making a whole lot easier for my game!.
Attachments
2 big.png
Blown up picture
2 big.png (473 Bytes) Viewed 17541 times
2.png
The picture I used
2.png (187 Bytes) Viewed 17541 times
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: Arduino and Swordfish Basic Graphic Converter

Post by brad » Mon Dec 03, 2012 7:32 pm

This is a nice program. It may also be useful if you could choose whether the data outputs a color as a 1 or a 0. (example: red black red is either 101 or 010.)
No Worries, I should be able to add that tonight.


I found a few few problems/bugs though:
I put red and green in a picture and the program switched the data (red is green, green is red.)
I haven't been able to replicate this fault - red comes up as red and green as green :)

Code: Select all

I tried putting yellow into a picture and it did not do red or green.
I should have explained a little more as to how it works. The program simply checks the intensity of red, green and blue in each pixel. if it is greater than 127 (255 is the highest you can get per color) it will deem that color to be there and will set it to a 1, if it is less than 128, then the programs deems that color to be too dark and assigns it a 0. For your yellow color, there must have been a greater green component compared to red and that's why only green came through. I will modify the program so you can adjust the intensity level that it allows colors to pass through at. I will also give you an output image so you can see what the image would look like in your game.
I put orange in the picture and only updated MyDataGreen (so probably red.)
Same as above, there must not have been enough red in the color :)
Bugs or no bugs, this is still an awesome program! It'll make map making a whole lot easier for my game!.
Thanks for the feedback, I'll make these changes and then see how it works for you. Once you think it's all good - I'll release it out on the arduino forums etc...

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: Arduino and Swordfish Basic Graphic Converter

Post by Saimaster13 » Mon Dec 03, 2012 9:08 pm

My bad, I forgot to put black in the areas that were white, so I thought 1 was off (which is why I wanted an ability to change that) which made me think that red and green were switched...


Anyway, it works fine now that I realize what it does, and yellow IS both red and green.

Thanks Brad!

(Sorry for my misconception.)
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: Arduino and Swordfish Basic Graphic Converter

Post by brad » Mon Dec 03, 2012 9:48 pm

Well I added more features anyway!
screen-capture-15.png
screen-capture-15.png (57.1 KiB) Viewed 17535 times
:arrow: Now there is a color adjustment (which basically just changes how bright the colors need to be to be included in the conversion. You will need to click convert each time you adjust the color setting.
:arrow: I have also added an invert data option so now you will get logic 0's to turn the LED's on (great for common anode matrix devices)
:arrow: I have also brought back the output image preview - so you can see what the image will look like on a matrix display - great for when you are trying to get the color adjustment just right!
:arrow: Not a new feature but you can click and drag the original image and place it where ever you like - perhaps next to the converted image to see the difference...

Here's some examples of different color settings with a sonic the hedgehog image: (notice the higher the number, the harder it is for a color to get counted in the conversion so the darker the output looks.
screen-capture-14.png
screen-capture-14.png (36.11 KiB) Viewed 17535 times
And here's the download:
Arduino and Swordfish Graphic Converter VER2.exe.zip
(47.44 KiB) Downloaded 494 times

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[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: Arduino and Swordfish Basic Graphic Converter

Post by MrDEB » Fri Dec 07, 2012 8:30 am

must be missing something?
I have visual basic 2010 express so how to use the graphic converter etc.
Seems I had this issue way back when

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: Arduino and Swordfish Basic Graphic Converter

Post by brad » Fri Dec 07, 2012 7:12 pm

You don't need to have Visual Basic Express 2010 (you only need that if you wanted to edit graphic converter in some way)

What error does it give you?

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[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: Arduino and Swordfish Basic Graphic Converter

Post by MrDEB » Fri Dec 07, 2012 10:34 pm

No errors yet as I load the visual basic express or the graphic converter but what to do next??
I tried opening the graphic converter into the VB express but nothing happens. Going to try again today, yesterday was kinda busy with honey do's (wife is off on Tuesdays and Thursdays)

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: Arduino and Swordfish Basic Graphic Converter

Post by brad » Fri Dec 07, 2012 11:00 pm

The graphic converter is a completely stand alone program. You don't need to (and can't) open it in Visual Studio. You can only open Visual Studio projects and source code in Visual Studio, I have only uploaded the .exe file which means it can only be run on it's own.

All you need to do is download the file, unzip it and then double click the .exe file :)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[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: Arduino and Swordfish Basic Graphic Converter

Post by MrDEB » Sat Dec 08, 2012 1:15 am

I did that and get the graphic converter screen but tried inputing various data in the little black boxes but I must be doing something wrong or not doing something right. Going to play with it more to figure it out.

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[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: Arduino and Swordfish Basic Graphic Converter

Post by MrDEB » Sat Dec 08, 2012 3:40 am

making some progress
Drew a graphic in PAINT then opened it in graphic converter. It looked like it started to convert but it seemed to stop?
Will try to be able to input data into the little boxes but ??

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: Arduino and Swordfish Basic Graphic Converter

Post by brad » Sun Dec 09, 2012 9:41 pm

Just follow these steps:

1. Make a new graphic in paint (try 32 x 32 pixels)
2. Draw what ever you want in the graphic
3. Save the graphic (to somewhere you will remember)
4. Open the graphic conversion software.
5. Goto 'File - Open' then open your graphic
6. Leave all settings as is, except I would change the output data type to longwords (because your image is 32pixels wide)
7. Click convert - it should be very quick for such a small image.
8. Your data is now available in the clipboard (just paste it into swordfish - if that's what you are using)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[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: Arduino and Swordfish Basic Graphic Converter

Post by MrDEB » Sun Dec 09, 2012 10:01 pm

I did most if not all except the 32 x 32 and output data type.
will give it a go.
THANKS

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 9 guests