gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Image Conversion Tool Recommendations

#111587 - blackcoat - Fri Dec 08, 2006 1:22 am

Though the FAQ points to the vast library of tools available for converting images to a format useable by the DS, is there any standard tool (or set of tools) used by people here in the community?


I ask because I am just starting my first homebrew project, and I am a bit stumped with what should be a simple image conversion. As with a few other people, I too am following Patatersoft's tutorial to help get me started. The first part of the tutorial teaches you how to display background images in Mode 5. For the images, Patatersoft suggests using gfx2gba (manual) -- which is different than the identically named gfx2gba -- and then using his hConvert tool to set the alpha bit for the DS. The resulting object file can be run through the `bin2o` rule in devKitARM's "base_rules" makefile and linked.

Long story short, when I do this, I get a black screen on top and on bottom. Interestingly enough, my code does work since I can run Patatersoft's pre-generated .bin files through `bin2o`, link them, and the backgrounds show up. My own images seem to be the problem, and here is what I am doing right now:

  1. Crop the original .gif file using GIMP, and producing two 256x192 .bmp's with indexed color.
  2. Convert all .bmp's to .raw.c with gba2fx. From my makefile:
Code:
${DATA}/%.bin: $(ART)/%.bmp
   gfx2gba -q -fsrc -o$(BUILD) $<

  • Run the .raw.c through hConvert to set the alpha bit.

    hConvert only takes a single filename as an argument and has no options, so this should not be a useage issue. I'm guessing that my problem could be one of the following things:

    • I am not using gfx2gba correctly.
    • hConvert doesn't set the alpha bit correctly, giving me a transparent images (black screen) instead of something opaque.
    • I have not properly saved my image with GIMP. It should be noted that I have not figured out how to adjust color depth in GIMP, but I did opt for a 256-color palette when switching to Indexed color and saving the .bmp's.


    So, what works for you? How do you get your backgrounds on to the DS? Any tool suggestions + command line options would be greatly appreciated.
  • #111627 - Sausage Boy - Fri Dec 08, 2006 4:04 pm

    You can change the color mode in the gimp using Image->Mode->Indexed or something like that. I've found that .pcx files work well for me with gfx2gba, but I recommend you to get git.
    _________________
    "no offense, but this is the gayest game ever"

    #111630 - blackcoat - Fri Dec 08, 2006 4:48 pm

    Sausage Boy,
    Thank you for the advice, I really appreciate it. However, something is still going wrong, and I don't know what it is....

    As you suggested, I tried using .pcx with gfx2gba, and made sure that the image was using Indexed color (already was since I'm converting from .gif). The final product had the same result: two black screens.

    Then, I tried my hand with git, which definitely looks like a step up (once again, thank you!). Here's what I'm doing right now in my makefile:

    Code:
    $(DATA)/%.bin: $(ART)/%.pcx
       git $< -gB16 -ftb -fh! -o$(DATA)/.


    From there, I run the resulting .bin through the `bin2o` rule, link the .elf, and build the .nds and .ds.gba executables. Once again, black screens.

    Just to make sure that I am not insane, I copied Patatersoft's .bin files over my own, touched them, and re-made the project. Sure enough, those display just fine.

    Am I using the correct options for generating a Mode 5 background?

    #111888 - headspin - Mon Dec 11, 2006 12:25 pm

    You can try using jpeg or my fixbit15 tool on the binary output produced by gfx2gba.

    http://headkaze.drunkencoders.com/
    _________________
    Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

    #112079 - blackcoat - Wed Dec 13, 2006 1:06 am

    !!! Progress !!!

    Thank you, headspin.

    As it turns out, my problem was two-fold:
    1) hconvert wasn't working for me
    2) My images were unexpectedly using 32-bit color

    I still don't know why 'hconvert' wasn't working for me, but 'fixbit15' did the trick. As suggested by headspin, I tried using that with the binary output from `gfx2gba`, and that finally produced something on screen (albeit distorted).

    Though still experimental and unsupported, `gfx2gba` does convert images using 32-bit color depth. My conversion rule in the makefile has now morphed into this:
    Code:
    $(DATA)/%.bin: $(ART)/%.pcx
       gfx2gba -q -fraw -c32k -o$(BUILD) $<
       fixbit15 $(BUILD)/$(basename $(notdir $<)).raw


    And that works for me!

    I still have not figured out how to adjust the color depth in GIMP. My images were already using a 256-color palette, but the colors themselves were still 32-bit. Anyway, I've got this working now.

    Does everyone here use Photoshop for editing their initial images?

    #112085 - tepples - Wed Dec 13, 2006 3:05 am

    blackcoat wrote:
    I still have not figured out how to adjust the color depth in GIMP.

    What error do you get when you try Image > Mode > Indexed... and then make sure it's still indexed when you save?
    _________________
    -- Where is he?
    -- Who?
    -- You know, the human.
    -- I think he moved to Tilwick.

    #112099 - blackcoat - Wed Dec 13, 2006 6:17 am

    tepples, GIMP is not giving me any errors, and I am using version 2.2.13.

    My original artwork files are .gif, so they're already using indexed color. Just to be sure that nothing strange is going on, I can convert them to RGB, then back to Indexed mode. The Indexed color dialog appears, and I choose "Generate Optimum Palette" with a maximum of 256 colors. I then save a copy as a ".pcx". In the past, I was saving as .bmp without RLE, but .pcx is working for me at the moment, so I'm sticking with it.

    When opening up the resulting .pcx in GIMP, I get the following information from the View -> Info Window:

    • Pixel dimensions: 256 x 192 pixels
    • Print size: 3.556 x 2.667 inches
    • Resolution: 72 x 72 dpi
    • Scale ratio: 100.00
    • Number of layers: 1
    • Size in memory: 292 KB
    • Display type: Indexed Color (256 colors)
    • Visual class: True Color
    • Visual depth: 24


    Notice the last few statistics: a 256 color palette, but 24-bit True Color depth. This is what GIMP gives to me, so that's what I end up working with. Aside from "use Photoshop", are there any suggestions on how to create images with 16-bit color depth ?

    #112123 - oofrab - Wed Dec 13, 2006 1:59 pm

    blackcoat wrote:
    Aside from "use Photoshop", are there any suggestions on how to create images with 16-bit color depth ?


    You could use the command line program 'convert' from the ImageMagick suite and supply it with the option '-depth 16'.

    Edit: Hmm, I believe this is WRONG. I am not able to do this with convert.

    #112128 - tepples - Wed Dec 13, 2006 3:01 pm

    You can truncate your 24/32 bit color images to 15-bit color by doing Image > Colors > Posterize and choosing 32 levels.
    _________________
    -- Where is he?
    -- Who?
    -- You know, the human.
    -- I think he moved to Tilwick.

    #112135 - blackcoat - Wed Dec 13, 2006 4:37 pm

    Wow, this just keeps getting even more bizarre.

    tepples, I tried posterizing the image as you suggested using 32 levels. The result:

    • Pixel dimensions: 256 x 192 pixels
    • Print size: 3.556 x 2.667 inches
    • Resolution: 72 x 72 dpi
    • Scale ratio: 100.00
    • Number of layers: 1
    • Size in memory: 776 KB
    • Display type: Indexed Color (106 colors)
    • Visual class: True Color
    • Visual depth: 24


    So, there are now fewer colors being used, the image has mysteriously jumped in size, and still no change in color depth. Tried making the project again, and same result: the images do not display properly unless I use gfx2gba with the -c32k option.

    #112151 - tepples - Wed Dec 13, 2006 7:09 pm

    blackcoat wrote:
    tepples, I tried posterizing the image as you suggested using 32 levels. The result:

    • Pixel dimensions: 256 x 192 pixels
    • Size in memory: 776 KB

    I think the size in memory includes the image's undo history. Try clearing the undo history.
    _________________
    -- Where is he?
    -- Who?
    -- You know, the human.
    -- I think he moved to Tilwick.