Page 1 of 1
Posted: Wed Apr 16, 2003 11:37 am
by BackupUser
Restored from previous forum. Originally posted by raphael.
Code: Select all
static char bitmapbuffer[sizeof(BITMAPINFO)+16];
static BITMAPINFO *bitmap_header;
for (cc = 0; cc bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitmap_header->bmiHeader.biPlanes = 1;
bitmap_header->bmiHeader.biBitCount = 32;
bitmap_header->bmiHeader.biCompression = BI_BITFIELDS;
bitmap_header->bmiHeader.biWidth = surface_width;
bitmap_header->bmiHeader.biHeight = -surface_height;
((unsigned long *)bitmap_header->bmiColors)[0] = 0x00FF0000;
((unsigned long *)bitmap_header->bmiColors)[1] = 0x0000FF00;
((unsigned long *)bitmap_header->bmiColors)[2] = 0x000000FF;
thanks in advance for any hints!
Posted: Wed Apr 16, 2003 9:48 pm
by BackupUser
Restored from previous forum. Originally posted by Thomas.
It's incomplete so you cannot translate this. In general this is just pointers and structures.
Posted: Thu Apr 17, 2003 7:50 am
by BackupUser
Restored from previous forum. Originally posted by raphael.
Originally posted by Thomas
It's incomplete so you cannot translate this
well, it is complete. what information do you need?
Posted: Thu Apr 17, 2003 4:47 pm
by BackupUser
Restored from previous forum. Originally posted by Thomas.
the definition of the bitmap fields?
Posted: Thu Apr 17, 2003 6:09 pm
by BackupUser
Restored from previous forum. Originally posted by raphael.
they are part of the win32-api (wingdi.h)
Code: Select all
typedef struct tagBITMAPINFOHEADER{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER, FAR *LPBITMAPINFOHEADER, *PBITMAPINFOHEADER;
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO, FAR *LPBITMAPINFO, *PBITMAPINFO;
Posted: Thu Apr 17, 2003 7:55 pm
by BackupUser
Restored from previous forum. Originally posted by ebs.
raphael,
The BITMAPINFO and BITMAPINFOHEADER structures have PB definitions. You can see them in the Structure Viewer tool in the editor.
Are you sure the C code is correct? I'm a little puzzled because the char array bitmapbuffer is initialized to sizeof(BITMAPINFO) + 16 bytes (8 + 16 = 24 bytes), but the for statement initializes sizeof(BITMAPINFOHEADER) + 16 bytes (40 + 16 = 56 bytes).
Let me know,
Eric
Originally posted by raphael
Code: Select all
static char bitmapbuffer[sizeof(BITMAPINFO)+16];
static BITMAPINFO *bitmap_header;
for (cc = 0; cc bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitmap_header->bmiHeader.biPlanes = 1;
bitmap_header->bmiHeader.biBitCount = 32;
bitmap_header->bmiHeader.biCompression = BI_BITFIELDS;
bitmap_header->bmiHeader.biWidth = surface_width;
bitmap_header->bmiHeader.biHeight = -surface_height;
((unsigned long *)bitmap_header->bmiColors)[0] = 0x00FF0000;
((unsigned long *)bitmap_header->bmiColors)[1] = 0x0000FF00;
((unsigned long *)bitmap_header->bmiColors)[2] = 0x000000FF;
thanks in advance for any hints!
Posted: Fri Apr 18, 2003 12:04 am
by BackupUser
Restored from previous forum. Originally posted by raphael.
Originally posted by ebs
The BITMAPINFO and BITMAPINFOHEADER structures have PB definitions. You can see them in the Structure Viewer tool in the editor.
i just wanted to show thomas the 'original' definition because he asked
Code: Select all
Are you sure the C code is correct? I'm a little puzzled because the char array bitmapbuffer is initialized to sizeof(BITMAPINFO) + 16 bytes (8 + 16 = 24 bytes), but the for statement initializes sizeof(BITMAPINFOHEADER) + 16 bytes (40 + 16 = 56 bytes).
yes, the code is correct. i'm not sure if the structures are correct in purebasic though.
isn't 'bmiHeader' in BITMAPINFO of type BITMAPINFOHEADER instead of long?
BITMAPINFO would be bigger than BITMAPINFOHEADER then. that's what i understand from the wingdi.h at least.
so, that's the mainpart i don't understand:
shouldn't
Code: Select all
bitmap_header->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
be like
Code: Select all
bitmap_header\bmiHeader\biSize = sizeof(BITMAPINFOHEADER)
in pb?
i'd be a happy man if you could help me...
Posted: Fri Apr 18, 2003 1:31 pm
by BackupUser
Restored from previous forum. Originally posted by ebs.
raphael,
yes, the code is correct. i'm not sure if the structures are correct in purebasic though. isn't 'bmiHeader' in BITMAPINFO of type BITMAPINFOHEADER instead of long? BITMAPINFO would be bigger than BITMAPINFOHEADER then. that's what i understand from the wingdi.h at least.
Yes, I looked it up in the APIViewer and I agree with you. In PureBasic, I think this is correct:
Code: Select all
Structure BITMAPINFO
bmiHeader.BITMAPINFOHEADER
bmiColors.b[4]
EndStructure
NOT
Code: Select all
Structure BITMAPINFO
bmiHeader.l
bmiColors.l
EndStructure
Maybe someone thought that the bmiHeader element was supposed to be a pointer (long), but I don't think so. You'll notice that I made bmiColors an array of 4 bytes (like the RGBQUAD structure) instead of a long. This should be the same thing, just a little easier to assign the colors individually.
shouldn't
bitmap_header->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
be like
bitmap_header\bmiHeader\biSize = sizeof(BITMAPINFOHEADER)
in pb?
Yes, but the bitmap_header variable is just a pointer to the bitmapbuffer memory, so I think you can do something like this:
Code: Select all
; note new structure which includes the extra 16 bytes
Structure BITMAPINFOPLUS16
bmiHeader.BITMAPINFOHEADER
bmiColors.b[4]
extrabytes.b[16]
EndStructure
; all fields should be initialized to 0 when created
bitmapbuffer.BITMAPINFOPLUS16
bitmapbuffer\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bitmapbuffer\bmiHeader\biPlanes = 1
bitmapbuffer\bmiHeader\biBitCount = 32
bitmapbuffer\bmiHeader\biCompression = #BI_BITFIELDS
bitmapbuffer\bmiHeader\biWidth = surface_width
bitmapbuffer\bmiHeader\biHeight = -surface_height
bitmapbuffer\bmiColors[0] = $ff
bitmapbuffer\bmiColors[1] = $ff
bitmapbuffer\bmiColors[2] = $ff
I'm not sure why the C code uses longs when setting the bmiColors values. I believe they are bytes, not longs, as the definition of RGBQUAD is an array of four bytes.
Hope this helps,
Eric
Posted: Fri Apr 18, 2003 11:05 pm
by BackupUser
Restored from previous forum. Originally posted by raphael.
so i was kinda right and the pb-structure isn't correct thus making
a translation impossible (without defining an own structure).
fred, another topic on your list?
thank you very much for your effort!