Gimp For Tiles

Topics on software tools like TileStudio, comments on documentation and tutorials (or the lack of) should go here.

Gimp For Tiles

Postby Nender » Tue Apr 07, 2009 8:13 pm

Can someone throw up a quick guide on the steps necessary to use The GIMP for creating tiles? I've poked around a little, but no dice so far. I note it does have a C source code export option, but it dumps it at too high quality.
Any help is appreciated.
Nender
 
Posts: 6
Joined: Tue Apr 07, 2009 8:06 pm

Re: Gimp For Tiles

Postby pragma » Tue Apr 07, 2009 8:56 pm

Nender wrote:Can someone throw up a quick guide on the steps necessary to use The GIMP for creating tiles? I've poked around a little, but no dice so far. I note it does have a C source code export option, but it dumps it at too high quality.
Any help is appreciated.


I have something that will convert an image, like a PNG to the needed C format: See here: http://uzebox.org/forums/viewtopic.php?f=3&t=251

Contact me if you're interested in the layer-export GIMP script referenced in that thread. I'm using for development here and while slow, it does the job.
User avatar
pragma
 
Posts: 175
Joined: Sat Sep 20, 2008 2:16 am
Location: Washington, DC

Re: Gimp For Tiles

Postby uze6666 » Tue Apr 07, 2009 9:27 pm

Hey, this needs to be on the Wiki! Putting it right away.

Uze
User avatar
uze6666
Site Admin
 
Posts: 2670
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada

Re: Gimp For Tiles

Postby Nender » Wed Apr 08, 2009 6:37 pm

Thanks for the response! I've actually looked at the code and tried to get it working before, but I've had issues. If you copy the code in firefox, you get extra spaces in each line, which python complains about. (Actually, looking at the wiki, I see that you have the same issue, uze.) After fixing this by visiting with safari, it complained about extra characters.
Code: Select all
  File "./convert.py", line 33
        if opt == "-6" or opt == "-l":
     ^
SyntaxError: invalid character in identifier

I know zip about python, but it would be great if someone could post a confirmed working .py file of the script.
Nender
 
Posts: 6
Joined: Tue Apr 07, 2009 8:06 pm

Re: Gimp For Tiles

Postby pragma » Wed Apr 08, 2009 8:25 pm

Nender wrote:Thanks for the response! I've actually looked at the code and tried to get it working before, but I've had issues. If you copy the code in firefox, you get extra spaces in each line, which python complains about. (Actually, looking at the wiki, I see that you have the same issue, uze.) After fixing this by visiting with safari, it complained about extra characters.
Code: Select all
  File "./convert.py", line 33
        if opt == "-6" or opt == "-l":
     ^
SyntaxError: invalid character in identifier

I know zip about python, but it would be great if someone could post a confirmed working .py file of the script.


Python is strange in that whitespace on the left margin is significant. It is used to define scope, like in if-statements, class declarations and method def-statements. Also, mixing spaces and tabs is a bad idea since it looks for the exact same whitespace sequence to distinguish such scopes. While that seems like a boneheaded design choice, it's nothing that a quick regex to replace tabs with spaces can't handle.

Anyway, the wiki page has been updated with the latest-and-greatest from my toolbox. I used a <pre> tag in the wiki itself to make sure that the left-margin stays as intended.
User avatar
pragma
 
Posts: 175
Joined: Sat Sep 20, 2008 2:16 am
Location: Washington, DC

Re: Gimp For Tiles

Postby uze6666 » Wed Apr 08, 2009 8:59 pm

Ahhh spaces & Python. Can you guys post it as a zip file? I'll add it like that to the Wiki to avoid the problem.

Thanks

Uze
User avatar
uze6666
Site Admin
 
Posts: 2670
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada

Re: Gimp For Tiles

Postby pragma » Wed Apr 08, 2009 9:17 pm

Bump

I added the .xcf layer import script to the wiki as well, since I'm at a loss for a better solution to that particular problem.
User avatar
pragma
 
Posts: 175
Joined: Sat Sep 20, 2008 2:16 am
Location: Washington, DC

Re: Gimp For Tiles

Postby Nender » Wed Apr 08, 2009 9:47 pm

I'm getting this when I try to run it:
Code: Select all
File "/Users/nathan/Desktop/convert.py", line 104, in <module>
    (r,g,b) = data[xofs+x,yofs+y]
IndexError: image index out of range

Any wisdom?
Nender
 
Posts: 6
Joined: Tue Apr 07, 2009 8:06 pm

Re: Gimp For Tiles

Postby pragma » Thu Apr 09, 2009 3:01 pm

Nender wrote:I'm getting this when I try to run it:
Code: Select all
File "/Users/nathan/Desktop/convert.py", line 104, in <module>
    (r,g,b) = data[xofs+x,yofs+y]
IndexError: image index out of range

Any wisdom?


I'm sorry you're having trouble with this. It really should be less troublesome than what you're dealing with.

What can you tell me about the source image? Resolution, color depth? Was it generated by my GIMP script? Also, what command-line options are you using?

Offhand, I'd say that the rows and columns selected are too wide/tall for your source image. This util doesn't do any bounds checking :oops: , so that could be problem.
User avatar
pragma
 
Posts: 175
Joined: Sat Sep 20, 2008 2:16 am
Location: Washington, DC

Re: Gimp For Tiles

Postby Nender » Thu Apr 09, 2009 4:47 pm

Code: Select all
Macintosh:~ nathan$ python /Users/nathan/Desktop/convert.py -8 /Users/nathan/Code/uzebox-read-only/gfx/fonts_8x8.png
Traceback (most recent call last):
  File "/Users/nathan/Desktop/convert.py", line 104, in <module>
    (r,g,b) = data[xofs+x,yofs+y]
IndexError: image index out of range

The full command and error. I was actually just using the example command you suggested in original script post. Oh! It looks like it is dumping a file... I can't tell if it ran to completion though.
Code: Select all
Macintosh:~ nathan$ cat /Users/nathan/Code/uzebox-read-only/gfxfonts_8x8.c
/* Autogenerated by convertgfx.py - do not modify */#include <avr/pgmspace.h>
unsigned char fonts_8x8[] PROGMEM = {
/* tile number: 0 */
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* tile number: 1 */
   0x00,0x00,0xff,0xff,0xff,0x00,0x00,0x00,
   0x00,0x00,0xff,0xff,0xff,0x00,0x00,0x00,
   0x00,0x00,0xff,0xff,0xff,0x00,0x00,0x00,
   0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,
   0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

//Cut out for brevity

/* tile number: 63 */
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* tile number: 64 */

I'm not sure why it stops on the last tile.
Nender
 
Posts: 6
Joined: Tue Apr 07, 2009 8:06 pm

Next

Return to Tools, Documentation & Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests

cron