|
Post by mathiasw on Feb 4, 2014 0:40:37 GMT -8
Salut,
I want to make a simple test for gameduino2: I want to use a graphic as background and then use a second graphic to move over the background. I have both graphic as PNG, the moving graphic has parts that are transparent. The documentation appears to me pretty sparse and perhaps it is so obvious that I cannot see it, but I am struggling with this apparently simple task. Instead of continuing to stumble forward I would like to ask the gameduino Gurus to post a simple demo that does this with a short guide on how to convert the PNG whilst preserving transparency etc.
Any help is appreciated and I promise you a nice demo afterwards.
Ciao, Mathias PS: I showed the gameduino2 on a maker meeting in Basel last week and the resonance was fabulous! Cloud have sold plenty of them...
|
|
|
Post by brunovr on Feb 4, 2014 10:45:28 GMT -8
hi, i don't understand how many persons have the gameduino, nobody response to the question about !
i also tried to do this, for icon button, but i'm not been able. I suppose that you must convert it on a sprite in a GD2 format, but i not understand how ! after make a sprite you can move with GD.Vertex2ii(x,y.....)
ciao ciao
|
|
|
Post by jamesbowman on Feb 4, 2014 19:02:24 GMT -8
The Gameduino 2 asset converter uses a transparency format by default, so if you convert the two PNG files into Gameduino 2 data with:
gd2asset picture1.png picture2.png
Then in your code (after you load the assets as described in the Gameduino 2 book), you can draw the two images with:
GD.Clear(); GD.Begin(BITMAPS); GD.Vertex2ii(100, 100, PICTURE1_HANDLE, 0); GD.Vertex2ii(100, 100, PICTURE2_HANDLE, 0); GD.swap();
This draws both images at screen XY (100,100) - you can change these values each frame to make "picture2" move around.
|
|
|
Post by brunovr on Feb 5, 2014 11:59:03 GMT -8
Hi James,
thank's for the response, the question now is how to use "gd2asset picture1.png picture2.png"
I think that is linux python? I have MAC & XP, please tell me how and where can i use gd2asset.
Your book is very simply e beautiful, but there is no explanation how to create gd2 files, ad the use of gd2asset and the example how to use the tools for create sprites and background and music files from wave to ima via SoX (Mac & XP?)
Thank's so much for the answers and for create this beautiful display.
ciao
from Italy
|
|
|
Post by mathiasw on Feb 5, 2014 14:20:33 GMT -8
Salut, I was quite successful: - I installed Python under Windows following the guide from the home page of gameduino2
- I did not set the path, so I copied temporarily the PNG files into the directory c:\Python27\scripts
- In a cmd window I executed c:\Python27\python.exe gd2asset file1.png file2.png file3.png
This gives me the load_assets.h file that has the graphics defined and I used the sprite example to get my sketch. So far I have been successful to display the first png and then the second one on top preserving the transparency. When rotating, it is imperative that the rotated bitmap is a squared one with the rotation center in the middle of the square. I have posted the interim solution in the show/tell section of the forum to show how amazing this display is. The next steps are to add the minute and hour handle as well as the little pointers. I may have to switch to an Arduino Mega due to the memory consumption, but my goal is to have this running on an Uno. Using the command: c:\Python27\python.exe gd2asset -f myfiles.gd2 -o myfiles_asset.h file1.png file2.png file3.png produces a GD2 file that is then loaded through the #define in the .h file. I expect this to reduce the memeory consumption on the Arduino. Ciao, Mathias
|
|
|
Post by mathiasw on Feb 6, 2014 3:06:45 GMT -8
Salut, the python code seems to have a serious error: I tried to work with the GD2 file and the bitmap is loaded completely wrong: the lower part of the clock face is shown but the upper part is overwritten with garbage. I have included the png files as well as the gd2 file. Perhaps someone can either tell me what I am doing wrong or generate the correct GD2 file. Ciao, Mathias Clock.zip (98.27 KB)
|
|
|
Post by christianc on Feb 6, 2014 3:36:58 GMT -8
Hello,
i try your file, and a superbe snow on the screen, a big problem !
excuse me for my English, i am french
Thanks
Christian
|
|
|
Post by brunovr on Feb 6, 2014 5:46:13 GMT -8
Wow!, this is a problem that i've found. When you use a big image, i think that the memory doesn't been able to insert anotrer image. I'm try to do a program to see the "tree.jpg" and another image... not work, the second image is distorted.
If the image is small 64x64 pixel, you can see a lot of image, so if the first image is 260x480 (backgroud jpg) the other image is distorted.
Help please.
|
|
|
Post by mathiasw on Feb 6, 2014 7:01:26 GMT -8
Salut, it looks liek a bitmap size issue to me as well. I have changed the size by 20% so that the clock face has now 214 pixel in height and width. Now all bitmaps get displayed as expected. I also noticed, that the handling of the transformation matrix is a bit tricky. To rotate the next hand, I first have to rotate back the previous hand. So I translate the bitmap of the first hand to the rotation origin, rotate and translate back. Then I draw the bitmap. Then I translate again to the origin and rotate backwards before I start rotating the next hand. With that I now have three hands (hour, minute and second) rotating. I now need to iron out the exact pixel position of the rotation for each hand and then I will publish the code. I will then also test to use the GD2 file from SD-card as it shrinks down the code on the Arduino from 28k to 9k. Ciao, Mathias @christian: si jamais, tu peux m'écrire en Français. Je suis Allemand mais je parle aussi Français (et surtout il y a Google Translate )
|
|
|
Post by mathiasw on Feb 7, 2014 13:40:04 GMT -8
Salut,
@james: can you tell us a bit the limits that are given by Gameduino2 so that we can adjust the graph sizes instead of "trial and error"?
Ciao, Mathias
|
|
|
Post by jamesbowman on Feb 7, 2014 17:25:42 GMT -8
The memory limit is 256KBytes - that is how much storage the GPU has for images, etc.
So the "tree" image that is on the microSD card is 480x272 pixels, and in memory it requires 2 bytes per pixel. So it uses 480 * 272 * 2 bytes, or 261120 bytes. Since the total is 262144 bytes, very little is left over for more graphics.
Put another way, if your images are 2 bytes per pixel - e.g. JPEGs - then your total number of pixels must be less than 131072.
|
|
|
Post by jamesbowman on Feb 7, 2014 17:27:11 GMT -8
Matthias,
For your clock hands, I think it may be easier if you use "cmd_loadidentity()" before each hand. This resets the bitmap transform matrix.
|
|
|
Post by jinteki2501 on Feb 25, 2014 23:01:13 GMT -8
The memory limit is 256KBytes - that is how much storage the GPU has for images, etc. So the "tree" image that is on the microSD card is 480x272 pixels, and in memory it requires 2 bytes per pixel. So it uses 480 * 272 * 2 bytes, or 261120 bytes. Since the total is 262144 bytes, very little is left over for more graphics. Put another way, if your images are 2 bytes per pixel - e.g. JPEGs - then your total number of pixels must be less than 131072. Aside from image size limitations due to available memory, are there also restrictions on the image dimensions? I ask because I had a .png file that was 44x44 pixels that I used gd2asset to convert to a .gd2 file, but when I ran my sketch the Gameduino2 kept showing an error message (white text on a blue background) saying that it could not load the .gd2 file. When I resized the .png file to 64x64 and created a new .gd2 file using gd2asset, the Gameduino2 loaded the .gd2 file without issue. Each time I tried a new .gd2 file, I had an appropriate .h file to load the assets. The image/tile size is the only thing that I changed to get the image to load. I have not read anything to indicate that the tile size would have been a problem, but I am still wondering why my 44x44 pixel tile did not load. Did I overlook something?
|
|
|
Post by jamesbowman on Mar 5, 2014 6:04:43 GMT -8
Hmm, there are no hardware restrictions on the size of a bitmap, so 44x44 should work fine. From the sound of it (white text on a blue background) the error message is caused by a missing .gd2 file on the SDcard. Could it be that the file didn't get copied to the card for the 44x44 image?
|
|
|
Post by neuroflux on Jun 18, 2014 14:40:01 GMT -8
Hmm, there are no hardware restrictions on the size of a bitmap, so 44x44 should work fine. From the sound of it (white text on a blue background) the error message is caused by a missing .gd2 file on the SDcard. Could it be that the file didn't get copied to the card for the 44x44 image? Sorry to Hi-jack the thread for a minute... Hey James, Awesome work with the GD2 - I just wondered whether I can sample a colour from a BITMAP and turn it transparent? I can't seem to find any information (or I might be blind). Cheers
|
|