(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-21-24 06:01 PM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - Exporting and Importing 8-bit Bitmaps New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
Xeon
The master of the universe...


 





Since: 03-09-06
From: Omaha, NE

Last post: 6610 days
Last view: 6610 days
Posted on 03-10-06 02:13 PM Link | Quote
Yes, I am trying to export GBA graphics data to an 8-bit indexed bitmap, importing and exporting, in my overworld sprite editor, and to be honest I have no clue at all at how to do it. I tried on many attempts and failed, I have no idea how the hell to write the bitmap data correctly. Writing the bitmap header and palletes is easy, its the actual data im having trouble with.

My horrible attempt at coding a bitmap export routine.

'Dim bmpHeader As BITMAPINFOHEADER
Dim bmpFileHeader As BITMAPFILEHEADER
Dim bmpInfoHeader As BITMAPINFOHEADER
Dim bytCurrentRow() As Byte
Dim bytTempBuffer() As Byte
Dim bytTempBuffer2() As Byte
Dim lngCurrentPosition As Long
Dim lWidth As Long, lHeight As Long
lWidth = (m_lngGraphicWidthBlocks * 8)
lHeight = (m_lngGraphicHeightBlocks * 8)

ReDim bytTempBuffer(((m_lngGraphicWidthBlocks * 8) * (m_lngGraphicHeightBlocks * 8)) - 1)
ReDim bytTempBuffer2((((m_lngGraphicWidthBlocks * 8) * (m_lngGraphicHeightBlocks * 8)) / 2) - 1)

bmpFileHeader.bfType = 19778 'BM
bmpFileHeader.bfSize = 118 + (((m_lngGraphicWidthBlocks * 8) * (m_lngGraphicHeightBlocks * 8)) \ 2)
bmpFileHeader.bfOffBits = 118

bmpInfoHeader.biSize = 40
bmpInfoHeader.biWidth = m_lngGraphicWidthBlocks * 8
bmpInfoHeader.biHeight = m_lngGraphicHeightBlocks * 8
bmpInfoHeader.biPlanes = 1
bmpInfoHeader.biCompression = 0
bmpInfoHeader.biSizeImage = ((m_lngGraphicWidthBlocks * 8) * (m_lngGraphicHeightBlocks * 8)) \ 2
bmpInfoHeader.biXPelsPerMeter = 0
bmpInfoHeader.biYPelsPerMeter = 0
bmpInfoHeader.biBitCount = 4
bmpInfoHeader.biClrUsed = 0
bmpInfoHeader.biClrImportant = 0

For YLine = 0 To m_lngGraphicHeightBlocks - 1
For XLine = 0 To m_lngGraphicWidthBlocks - 1
For Y = 0 To 7
For X = 0 To 7
bytTempBuffer((((XLine * 8) + X) + ((YLine * 8) + Y) * (m_lngGraphicWidthBlocks * 8))) = EditBuffer(lngCurrentPosition + X)
Next X
lngCurrentPosition = lngCurrentPosition + 8
Next Y
Next XLine
Next YLine

lngCurrentPosition = 0
For i = 0 To UBound(bytTempBuffer) Step 2
bytTempBuffer2(lngCurrentPosition) = (bytTempBuffer(i + 1) * 16) Or bytTempBuffer(i)
Next i


Open App.Path & "\Dump.bmp" For Binary As #1
Put #1, , bmpFileHeader
Put #1, , bmpInfoHeader
Put #1, , PaletteData2
Put #1, , bytTempBuffer2
Close #1
Kyoufu Kawa
Intends to keep Rom Hacking in one piece until the end








Since: 11-18-05
From: Catgirl Central Station

Last post: 6301 days
Last view: 6301 days
Posted on 03-10-06 02:33 PM Link | Quote
Wrong forum.

*Kyoufu Kawa moves this to Programming.
Guy Perfect









Since: 11-18-05

Last post: 6303 days
Last view: 6302 days
Posted on 03-20-06 12:19 AM Link | Quote
You'll need to consult the .bmp file format to get a good understanding of what that stuff does. All .bmp files have a BITMAPFILEHEADER at the beginning, followed by a BITMAPINFOHEADER, followed by the pixel data itself, left to right, bottom to top.

You'll have to do some hefty research on implementing palettes and indexes if you want to import and export 8bpp .bmp images.

But for the data, just write every byte of data. The scanlines for .bmp are bottom-to-top, so you need to remember to write those to the file thusly. So for a 3×3 image:

A B C
D E F
G H I

You will write the pixels to the file as GHIDEFABC.
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6581 days
Last view: 6581 days
Posted on 03-20-06 12:51 AM Link | Quote
Also remember that rows are padded to a 4-byte boundary, so you might have to add padding unless the circumstances are just so.

For example, an 8-bit bitmap with a width of 17 must actually have 20 bytes of pixel data per row -- the last 3 of which are not used (just padding)
Kyoufu Kawa
Intends to keep Rom Hacking in one piece until the end








Since: 11-18-05
From: Catgirl Central Station

Last post: 6301 days
Last view: 6301 days
Posted on 03-20-06 02:51 PM Link | Quote
Actually, Beegee... scanline direction depends on the height. I can't remember which was what, but the height can be negative, and that determines the scanline order.
HyperHacker

Star Mario
Finally being paid to code in VB! If only I still enjoyed that. <_<
Wii #7182 6487 4198 1828


 





Since: 11-18-05
From: Canada, w00t!
My computer's specs, if anyone gives a damn.
STOP TRUNCATING THIS >8^(

Last post: 6302 days
Last view: 6302 days
Posted on 03-22-06 01:58 PM Link | Quote
I don't think that applies to actual bitmap files, only API calls. *checks* Nope.

Do you actually need to have the images stored externally, or is it just so you can display them? It'd be much easier and faster to just create a bitmap in memory (using CreateCompatibleBitmap and CreateCompatibleDC).
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6581 days
Last view: 6581 days
Posted on 03-22-06 02:09 PM Link | Quote
CreateDIBSection = love
Kyoufu Kawa
Intends to keep Rom Hacking in one piece until the end








Since: 11-18-05
From: Catgirl Central Station

Last post: 6301 days
Last view: 6301 days
Posted on 03-23-06 09:51 AM Link | Quote
But Dish, you know you can't just assign a value to a function. That's like claiming ð equals exactly three!
HyperHacker

Star Mario
Finally being paid to code in VB! If only I still enjoyed that. <_<
Wii #7182 6487 4198 1828


 





Since: 11-18-05
From: Canada, w00t!
My computer's specs, if anyone gives a damn.
STOP TRUNCATING THIS >8^(

Last post: 6302 days
Last view: 6302 days
Posted on 03-23-06 10:51 AM Link | Quote
You can in C. That would just make calling CreateDIBSection equivilant to calling love.

Course if that's supposed to be VB code then no, what the hell. And if it's C, it's missing a semicolon.
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6581 days
Last view: 6581 days
Posted on 03-23-06 02:26 PM Link | Quote
Fine fine.


typedef HBITMAP (*fnc)(HDC,const BITMAPINFO*,UINT,void**,HANDLE,DWORD);

int IsFunctionLove(fnc function)
{
  return (function == CreateDIBSection);
}


Is that better?
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - Exporting and Importing 8-bit Bitmaps |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.015 seconds; used 392.84 kB (max 486.97 kB)