- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I am making my first attempt to use CreateDIBSection, more or less basing it on Charles Petzold's example in Programming Windows. Here are the relevant sections of my code:
type (t_bitmapinfoheader) bmih
type (t_bitmapinfo) m_bmi
byte mgb
pointer (pmgb,mgb)
.
.
call ZeroMemory(loc(m_bmi),sizeof(bmih))
m_bmi%bmiHeader%biSize = sizeof(bmih)
m_bmi%bmiHeader%biWidth = 200
m_bmi%bmiHeader%biHeight = 200
m_bmi%bmiHeader%biPlanes = 1
m_bmi%bmiHeader%biBitCount = 24
m_bmi%bmiHeader%biCompression = BI_RGB
m_bmi%bmiHeader%biSizeImage = 0
m_bmi%bmiHeader%biXPelsPerMeter = 0
m_bmi%bmiHeader%biYPelsPerMeter = 0
m_bmi%bmiHeader%biClrUsed = 0
m_bmi%bmiHeader%biClrImportant = 0
hWndTiffBM = CreateDIBSection(hdc,m_bmi,0,loc(pmgb),NULL,0)
write(errcode,'(I6)')GetLastError()
The errcode always returns 8, which converts to "Not enough storage is available to process this command."
Please can someone tell me what's going on here? I find it very hard to generalise from the examples I can find, almost all of which are in C - whatI long for is an example in Fortran. Any help greatly appreciated.
Many thanks in advance,
Mike
I am making my first attempt to use CreateDIBSection, more or less basing it on Charles Petzold's example in Programming Windows. Here are the relevant sections of my code:
type (t_bitmapinfoheader) bmih
type (t_bitmapinfo) m_bmi
byte mgb
pointer (pmgb,mgb)
.
.
call ZeroMemory(loc(m_bmi),sizeof(bmih))
m_bmi%bmiHeader%biSize = sizeof(bmih)
m_bmi%bmiHeader%biWidth = 200
m_bmi%bmiHeader%biHeight = 200
m_bmi%bmiHeader%biPlanes = 1
m_bmi%bmiHeader%biBitCount = 24
m_bmi%bmiHeader%biCompression = BI_RGB
m_bmi%bmiHeader%biSizeImage = 0
m_bmi%bmiHeader%biXPelsPerMeter = 0
m_bmi%bmiHeader%biYPelsPerMeter = 0
m_bmi%bmiHeader%biClrUsed = 0
m_bmi%bmiHeader%biClrImportant = 0
hWndTiffBM = CreateDIBSection(hdc,m_bmi,0,loc(pmgb),NULL,0)
write(errcode,'(I6)')GetLastError()
The errcode always returns 8, which converts to "Not enough storage is available to process this command."
Please can someone tell me what's going on here? I find it very hard to generalise from the examples I can find, almost all of which are in C - whatI long for is an example in Fortran. Any help greatly appreciated.
Many thanks in advance,
Mike
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - michaelgreen
Hi All,
I am making my first attempt to use CreateDIBSection, more or less basing it on Charles Petzold's example in Programming Windows. Here are the relevant sections of my code:
type (t_bitmapinfoheader) bmih
type (t_bitmapinfo) m_bmi
byte mgb
pointer (pmgb,mgb)
.
.
call ZeroMemory(loc(m_bmi),sizeof(bmih))
m_bmi%bmiHeader%biSize = sizeof(bmih)
m_bmi%bmiHeader%biWidth = 200
m_bmi%bmiHeader%biHeight = 200
m_bmi%bmiHeader%biPlanes = 1
m_bmi%bmiHeader%biBitCount = 24
m_bmi%bmiHeader%biCompression = BI_RGB
m_bmi%bmiHeader%biSizeImage = 0
m_bmi%bmiHeader%biXPelsPerMeter = 0
m_bmi%bmiHeader%biYPelsPerMeter = 0
m_bmi%bmiHeader%biClrUsed = 0
m_bmi%bmiHeader%biClrImportant = 0
hWndTiffBM = CreateDIBSection(hdc,m_bmi,0,loc(pmgb),NULL,0)
write(errcode,'(I6)')GetLastError()
The errcode always returns 8, which converts to "Not enough storage is available to process this command."
Please can someone tell me what's going on here? I find it very hard to generalise from the examples I can find, almost all of which are in C - whatI long for is an example in Fortran. Any help greatly appreciated.
Many thanks in advance,
Mike
I am making my first attempt to use CreateDIBSection, more or less basing it on Charles Petzold's example in Programming Windows. Here are the relevant sections of my code:
type (t_bitmapinfoheader) bmih
type (t_bitmapinfo) m_bmi
byte mgb
pointer (pmgb,mgb)
.
.
call ZeroMemory(loc(m_bmi),sizeof(bmih))
m_bmi%bmiHeader%biSize = sizeof(bmih)
m_bmi%bmiHeader%biWidth = 200
m_bmi%bmiHeader%biHeight = 200
m_bmi%bmiHeader%biPlanes = 1
m_bmi%bmiHeader%biBitCount = 24
m_bmi%bmiHeader%biCompression = BI_RGB
m_bmi%bmiHeader%biSizeImage = 0
m_bmi%bmiHeader%biXPelsPerMeter = 0
m_bmi%bmiHeader%biYPelsPerMeter = 0
m_bmi%bmiHeader%biClrUsed = 0
m_bmi%bmiHeader%biClrImportant = 0
hWndTiffBM = CreateDIBSection(hdc,m_bmi,0,loc(pmgb),NULL,0)
write(errcode,'(I6)')GetLastError()
The errcode always returns 8, which converts to "Not enough storage is available to process this command."
Please can someone tell me what's going on here? I find it very hard to generalise from the examples I can find, almost all of which are in C - whatI long for is an example in Fortran. Any help greatly appreciated.
Many thanks in advance,
Mike
Make sure you use hdc=CreateCompatibleDC(0) to get a valid device context handle.
Then try the CreateDIBsection call with zeros as the last four arguments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. declare mgb as INTEGER(1), and pmgb as INTEGER(INT_PTR_KIND()) or similar
2. I don't think you want LOC(pmgb) which is too many levels of indirection, just LOC(mgb).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Paul Curtis
1. declare mgb as INTEGER(1), and pmgb as INTEGER(INT_PTR_KIND()) or similar
2. I don't think you want LOC(pmgb) which is too many levels of indirection, just LOC(mgb).
Hi Guys, thanks for replies.
I tried every combination of suggestions and none worked. But what I did find was a problem with the statement:
m_bmi%bmiHeader%biBitCount = 24
If I make the value 0, GetLastError returns a 0 errcode, but the handle returned by CreateDIBSection is null. All other values for the BitCount generate an 8 for the errcode.
According to the documentation, the 4th argument should be a pointer to a pointer, which is why I used LOC(pmgb). I tried LOC(mgb) but that made no difference.
I have been using CreateCompatibleBitmap successfully for some time to display TIFF images. The trouble with this is my users want to display bigger images and/or multiple images and CreateCompatibleBitmap soon uses up all available resources. From what I have read CreateDIBSection may be the way to go, but I can't even get past first base with it - even Petzold says it's a weird function. Any further suggestions greatly appreciated.
Many thanks
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
I think you made a mistake about ppvbits argument of CreateDibSection. This argument is "a pointer to a variable that receives a pointer to the location of the DIB bit values".
See http://msdn.microsoft.com/en-us/library/dd183494%28VS.85%29.aspx
So I will write :
type (t_bitmapinfo) m_bmi
integer ptr_mgb
.
.
call ZeroMemory(loc(m_bmi%bmiHeader),sizeof(m_bmi%bmiHeader))
m_bmi%bmiHeader%biSize = sizeof(m_bmi%bmiHeader)
m_bmi%bmiHeader%biWidth = 200
m_bmi%bmiHeader%biHeight = 200
m_bmi%bmiHeader%biPlanes = 1
m_bmi%bmiHeader%biBitCount = 24
m_bmi%bmiHeader%biCompression = BI_RGB
hWndTiffBM = CreateDIBSection(hdc,m_bmi,0,ptr_mgb,NULL,0)
After the return of he function, ptr_mgb will contain the value of the pointer to the location of the DIB bit values.
I think you made a mistake about ppvbits argument of CreateDibSection. This argument is "a pointer to a variable that receives a pointer to the location of the DIB bit values".
See http://msdn.microsoft.com/en-us/library/dd183494%28VS.85%29.aspx
So I will write :
type (t_bitmapinfo) m_bmi
integer ptr_mgb
.
.
call ZeroMemory(loc(m_bmi%bmiHeader),sizeof(m_bmi%bmiHeader))
m_bmi%bmiHeader%biSize = sizeof(m_bmi%bmiHeader)
m_bmi%bmiHeader%biWidth = 200
m_bmi%bmiHeader%biHeight = 200
m_bmi%bmiHeader%biPlanes = 1
m_bmi%bmiHeader%biBitCount = 24
m_bmi%bmiHeader%biCompression = BI_RGB
hWndTiffBM = CreateDIBSection(hdc,m_bmi,0,ptr_mgb,NULL,0)
After the return of he function, ptr_mgb will contain the value of the pointer to the location of the DIB bit values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - gvautier
Hello
I think you made a mistake about ppvbits argument of CreateDibSection. This argument is "a pointer to a variable that receives a pointer to the location of the DIB bit values".
See http://msdn.microsoft.com/en-us/library/dd183494%28VS.85%29.aspx
So I will write :
type (t_bitmapinfo) m_bmi
integer ptr_mgb
.
.
call ZeroMemory(loc(m_bmi%bmiHeader),sizeof(m_bmi%bmiHeader))
m_bmi%bmiHeader%biSize = sizeof(bmih)
m_bmi%bmiHeader%biWidth = 200
m_bmi%bmiHeader%biHeight = 200
m_bmi%bmiHeader%biPlanes = 1
m_bmi%bmiHeader%biBitCount = 24
m_bmi%bmiHeader%biCompression = BI_RGB
hWndTiffBM = CreateDIBSection(hdc,m_bmi,0,ptr_mgb,NULL,0)
After the return of he function, ptr_mgb will contain the value of the pointer to the location of the DIB bit values.
I think you made a mistake about ppvbits argument of CreateDibSection. This argument is "a pointer to a variable that receives a pointer to the location of the DIB bit values".
See http://msdn.microsoft.com/en-us/library/dd183494%28VS.85%29.aspx
So I will write :
type (t_bitmapinfo) m_bmi
integer ptr_mgb
.
.
call ZeroMemory(loc(m_bmi%bmiHeader),sizeof(m_bmi%bmiHeader))
m_bmi%bmiHeader%biSize = sizeof(bmih)
m_bmi%bmiHeader%biWidth = 200
m_bmi%bmiHeader%biHeight = 200
m_bmi%bmiHeader%biPlanes = 1
m_bmi%bmiHeader%biBitCount = 24
m_bmi%bmiHeader%biCompression = BI_RGB
hWndTiffBM = CreateDIBSection(hdc,m_bmi,0,ptr_mgb,NULL,0)
After the return of he function, ptr_mgb will contain the value of the pointer to the location of the DIB bit values.
Thanks very much for the suggestion. What you say makes sense. I tried it, it compiles OK, but the error code is still 8. Any more ideas anyone?
Many thanks
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - michaelgreen
Thanks very much for the suggestion. What you say makes sense. I tried it, it compiles OK, but the error code is still 8. Any more ideas anyone?
Many thanks
Mike
Your original code produces a handle value that makes sense (it is not FALSE, NULL, 0xFFFFFFFF, or 1), and the pointer value appears OK as well. Maybe it will work anyway!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - anthonyrichards
Your original code produces a handle value that makes sense (it is not FALSE, NULL, 0xFFFFFFFF, or 1), and the pointer value appears OK as well. Maybe it will work anyway!
Effectively, the GetLastError() return value must be considered only if the called function fails and set an error return value in that case a NUL value.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page