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.

Graphics > What GXF File Format best to you use for?

#21526 - Lord - Sun May 30, 2004 11:00 pm

First of all, hi. :)

I'm really glad i finally found a Forum full of other guys working with the GBA for fun or whatever. ;)

However, due to the lack of a good 16*16 Color Tile Map-Editor, i've decided to code my own(seems to be best to me either way).
Now I'm facing a little problem with that:

I don't know what GFX File Format I should use. It has to support a 16 Color Palette, should not be compressed and have a good documentation so I can strip the Pal an the Pal entry for any Pixel. Any suggestions? If you know of a good converting library(for Delphi) I would also welcome that.

You might say I could use TBitmap, but afaik you can only get each pixel's color, not its Palette Entry? If I'm wrong with that please tell me, too ^^.

Sorry for nearly asking for Delphi rather that C, but I thougt I could give it a shot.

Hoping for a good time here,

Lord.

#21527 - wintermute - Mon May 31, 2004 12:02 am

http://nessie.gbadev.org/

#21528 - sajiimori - Mon May 31, 2004 12:52 am

Windows BMPs carry their palettes, and they can be 16 color uncompressed.

#21534 - Lord - Mon May 31, 2004 9:27 am

MapEd is kind of messed up for me in every version(I only se half of the Layer I'm working on), and I don't see a possibility to open a(or multiple, rather) Palette(s) after importing my 16 Color Map Data?

Sajiimori, do you know of any page that Describes these 16 color uncompressed Bitmaps?

Thanks, Lord.

#21536 - keldon - Mon May 31, 2004 11:43 am

This covers it all.

http://www.fortunecity.com/skyscraper/windows/364/bmpffrmt.html

p.s. even though you're in Delphi, you can freely use the Windows API. The structures given, such as BITMAPINFOHEADER, etc. are Win API structures.

The WIN API comes with Delphi, (win32.hlp or sometimes windows.hlp). To use the Windows API simply import them into your project using uses Windows.

Maybe using a windows bitmap may have advantages over using TBitmap, or you could mix their usage as I think I remember you could use a TBitmap like a bitmap.

#21537 - Lord - Mon May 31, 2004 12:23 pm

Thanks for this great Site and andvice :)

Well but now that I've startet with writing my own interpreter I think I'll continue doing it that way nevertheless since it is fun ^^

Edit:Besides do you think its wise to use WinAPI functions to Plot the Pixels on my form or should I rather use DirectDraw for speed reaons?

Thanks again, Lord.

#21539 - isildur - Mon May 31, 2004 2:21 pm

Lord wrote:
Thanks for this great Site and andvice :)

Well but now that I've startet with writing my own interpreter I think I'll continue doing it that way nevertheless since it is fun ^^

Edit:Besides do you think its wise to use WinAPI functions to Plot the Pixels on my form or should I rather use DirectDraw for speed reaons?

Thanks again, Lord.


I would not bother doing it with DirectDraw, it's overkill I think. The gdi is usually fast enough.

#21550 - sajiimori - Mon May 31, 2004 7:20 pm

Maybe use DirectDraw if you plan on having fully animated previews with parallax scrolling and all that.

#21559 - Akolade - Mon May 31, 2004 11:30 pm

Using Directdraw/Directx is nice as it allows easy scaling/rotation. Plus you can simulate transparency if necessary.
Though it can take a little learning to get going.

#21581 - keldon - Tue Jun 01, 2004 11:18 am

Code:
hdc = GetDC ( hWnd );
backbuffer = CreateCompatibleDC ( hdc );
backbufferBitmap = CreateDIBSection ( hdc, bitmapinfo, DIB_PAL_COLORS, &backbufferBits, NULL, NULL );
SelectObject ( backbuffer, backbufferBitmap );

{ backbufferBits is the pointer to the actual pixels }

BitBlt ( hdc, 0, 0, width, height, backbuffer, 0, 0, SRCCOPY )
ReleaseDC ( hWnd, hdc )


That's the code required to write directly to the window bitmap buffer; all that's required for this is a valid BITMAPINFO structure. &backbufferBits means the address of backbufferBits in C, can't remember it in Delphi.

However the datatypes are slightly different in Delphi ( for some reason ), and there is a lot of tinkering around with type casting - mostly relying on byte arrays. Also you have to manually set the size yourself, which is a bummer, since some datatypes, such as hCursor are quite mysterious as to how many bytes they actually are. Just assume 4 bytes unless stated otherwise, and the cbSize is also counted - so the BITMAPINFOHEADER, for example is 40 bytes.

Also working in 24/32 bit colours is a must; if you are unsure how to do that I can give you the code. 24 bit colour is supported in 16 bit screen modes also.

Quote:
Using Directdraw/Directx is nice as it allows easy scaling/rotation. Plus you can simulate transparency if necessary.
Though it can take a little learning to get goin

I think the tutorials packed in the DirectX.hlp file work pretty well in teaching direct draw functions.

#21592 - Akolade - Tue Jun 01, 2004 4:56 pm

Yes, the DX tutorials are pretty good. What I found tricky at first was combining MFC with DX. I would suggest to anyone new to it to just make a very simple program at first, just to get the basic structure of what you need to get going, then go from there.
Like, make a dialog window with an area for some DX graphics.

So far I've spent more time working on my tools than my GBA code I swear..