(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
06-03-24 03:01 PM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - Exporting and Importing 8-bit Bitmaps
  
User name:
Password:
Reply:
 
Options: - -
Quik-Attach:
Preview for more options

Max size 1.00 MB, types: png, gif, jpg, txt, zip, rar, tar, gz, 7z, ace, mp3, ogg, mid, ips, bz2, lzh, psd

UserPost
Disch
Posts: 94/202
Fine fine.


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

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


Is that better?
HyperHacker
Posts: 1479/5072
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.
Kyoufu Kawa
Posts: 652/1353
But Dish, you know you can't just assign a value to a function. That's like claiming ð equals exactly three!
Disch
Posts: 93/202
CreateDIBSection = love
HyperHacker
Posts: 1468/5072
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).
Kyoufu Kawa
Posts: 647/1353
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.
Disch
Posts: 92/202
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)
Guy Perfect
Posts: 224/451
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.
Kyoufu Kawa
Posts: 617/1353
Wrong forum.

*Kyoufu Kawa moves this to Programming.
Xeon
Posts: 6/70
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
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.012 seconds; used 357.16 kB (max 405.77 kB)