It is currently Sat May 25, 2013 1:11 am

All times are UTC + 10 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Arduino and Swordfish Basic Graphic Converter
PostPosted: Thu Nov 29, 2012 9:46 pm 
Offline
Site Admin
Site Admin
User avatar

Joined: Fri Mar 26, 2010 10:30 pm
Posts: 1863
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:
Attachment:
screen-capture.png
screen-capture.png [ 40.75 KiB | Viewed 437 times ]


Top
 Profile  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Sun Dec 02, 2012 10:23 pm 
Offline
I practically live here!
I practically live here!

Joined: Fri Feb 18, 2011 4:24 am
Posts: 251
can't wait to see this


Top
 Profile E-mail  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Sun Dec 02, 2012 10:56 pm 
Offline
Site Admin
Site Admin
User avatar

Joined: Fri Mar 26, 2010 10:30 pm
Posts: 1863
Well wait no more! Here's the initial release:
Attachment:
Arduino and Swordfish Graphic Converter.exe.zip [46.27 KiB]
Downloaded 16 times


Attachment:
screen-capture.png
screen-capture.png [ 35.96 KiB | Viewed 425 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...)


Top
 Profile  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Mon Dec 03, 2012 1:14 pm 
Offline
I practically live here!
I practically live here!
User avatar

Joined: Mon Aug 13, 2012 4:23 am
Posts: 171
Location: Sarasota, Florida
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:
File comment: Blown up picture
2 big.png
2 big.png [ 473 Bytes | Viewed 412 times ]
File comment: The picture I used
2.png
2.png [ 187 Bytes | Viewed 412 times ]

_________________
Joshua
Top
 Profile E-mail  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Mon Dec 03, 2012 7:32 pm 
Offline
Site Admin
Site Admin
User avatar

Joined: Fri Mar 26, 2010 10:30 pm
Posts: 1863
Quote:
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:

Quote:
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:
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.

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

Quote:
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...


Top
 Profile  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Mon Dec 03, 2012 9:08 pm 
Offline
I practically live here!
I practically live here!
User avatar

Joined: Mon Aug 13, 2012 4:23 am
Posts: 171
Location: Sarasota, Florida
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


Top
 Profile E-mail  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Mon Dec 03, 2012 9:48 pm 
Offline
Site Admin
Site Admin
User avatar

Joined: Fri Mar 26, 2010 10:30 pm
Posts: 1863
Well I added more features anyway!
Attachment:
screen-capture-15.png
screen-capture-15.png [ 57.1 KiB | Viewed 406 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.
Attachment:
screen-capture-14.png
screen-capture-14.png [ 36.11 KiB | Viewed 406 times ]


And here's the download:
Attachment:


Top
 Profile  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Fri Dec 07, 2012 8:30 am 
Offline
I practically live here!
I practically live here!

Joined: Fri Feb 18, 2011 4:24 am
Posts: 251
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


Top
 Profile E-mail  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Fri Dec 07, 2012 7:12 pm 
Offline
Site Admin
Site Admin
User avatar

Joined: Fri Mar 26, 2010 10:30 pm
Posts: 1863
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?


Top
 Profile  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Fri Dec 07, 2012 10:34 pm 
Offline
I practically live here!
I practically live here!

Joined: Fri Feb 18, 2011 4:24 am
Posts: 251
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)


Top
 Profile E-mail  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Fri Dec 07, 2012 11:00 pm 
Offline
Site Admin
Site Admin
User avatar

Joined: Fri Mar 26, 2010 10:30 pm
Posts: 1863
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 :)


Top
 Profile  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Sat Dec 08, 2012 1:15 am 
Offline
I practically live here!
I practically live here!

Joined: Fri Feb 18, 2011 4:24 am
Posts: 251
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.


Top
 Profile E-mail  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Sat Dec 08, 2012 3:40 am 
Offline
I practically live here!
I practically live here!

Joined: Fri Feb 18, 2011 4:24 am
Posts: 251
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 ??


Top
 Profile E-mail  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Sun Dec 09, 2012 9:41 pm 
Offline
Site Admin
Site Admin
User avatar

Joined: Fri Mar 26, 2010 10:30 pm
Posts: 1863
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)


Top
 Profile  
 
 Post subject: Re: Arduino and Swordfish Basic Graphic Converter
PostPosted: Sun Dec 09, 2012 10:01 pm 
Offline
I practically live here!
I practically live here!

Joined: Fri Feb 18, 2011 4:24 am
Posts: 251
I did most if not all except the 32 x 32 and output data type.
will give it a go.
THANKS


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme made by Keenen Wheeler