- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All ?
Is there anyone know that how to deallocate the memory(*ppvBits) used in CreateDIBSection ?
Following is a pieces of my code.
Thanks a lot.
!*
!***HBITMAP CreateDIBSection(
!*** HDC hdc, // handle to device context
!*** CONST BITMAPINFO *pbmi,
!*** // pointer to structure containing bitmap size,
!*** // format, and color data
!*** UINT iUsage, // color data type indicator: RGB values or
!*** // palette indexes
!*** VOID *ppvBits, // pointer to variable to receive a pointer to
!*** // the bitmap's bit values
!*** HANDLE hSection, // optional handle to a file mapping object
!*** DWORD dwOffset // offset to the bitmap bit values within the
!*** // file mapping object
!***);
!****************************************************************************
!*** OpenGL -> Bitmap -> Printer
!****************************************************************************
use dfwina, W32_Null => null, W32_Arc => Arc
use dfopngl
use Module_Print
use Module_Window
implicit real*8 (a-h,o-z),integer*4 (i-n)
interface
integer*4 function SetMemDCPixelFormat(hDC)
!DEC$ if defined(_x86_)
!DEC$ attributes stdcall, alias : '_SetMemDCPixelFormat@4' :: SetMemDCPixelFormat
!DEC$ else
!DEC$ attributes stdcall, alias : 'SetMemDCPixelFormat' :: SetMemDCPixelFormat
!DEC$ end if
integer*4 hDC
end function SetMemDCPixelFormat
end interface
type (T_BITMAPINFOHEADER) :: bmih
type (T_BITMAPINFO) :: m_bmi
iflag = 1
!// Initialize the bitmap header info.
call ZeroMemory(loc(m_bmi),sizeof(bmih))
m_bmi.bmiHeader.biSize = sizeof(bmih)
m_bmi.bmiHeader.biWidth = nXRes
m_bmi.bmiHeader.biHeight = nYRes
m_bmi.bmiHeader.biPlanes = 1
m_bmi.bmiHeader.biBitCount = 24
m_bmi.bmiHeader.biCompression = BI_RGB
m_bmi.bmiHeader.biSizeImage = m_bmi.bmiHeader.biWidth*m_bmi.bmiHeader.biHeight*3
m_bmi.bmiHeader.biXPelsPerMeter = int(2840.0D0/72.0D0*dble(Print.DPI.cx)*facts) ! int(2840./72.*Print.DPI.cx*facts) // Print.DPI.cx*facts DPI
m_bmi.bmiHeader.biYPelsPerMeter = int(2840.0D0/72.0D0*dble(Print.DPI.cy)*facts) ! int(2840./72.*Print.DPI.cy*facts) // Print.DPI.cy*facts DPI
m_bmi.bmiHeader.biClrUsed = W32_Null
m_bmi.bmiHeader.biClrImportant = W32_Null
!// create DIB
m_hDib = CreateDIBSection(W32_Null,m_bmi,DIB_RGB_COLORS,loc(m_pBitmapBits),W32_Null,0)
!// create memory device context
m_hMemDC = CreateCompatibleDC(W32_Null)
if(m_hMemDC == W32_Null) then
iflag = 0
return
end if
m_hOldDib = SelectObject(m_hMemDC,m_hDib)
!// setup pixel format
if(not(SetMemDCPixelFormat(m_hMemDC))) then
if(m_hOldDib /= W32_null) i = SelectObject(m_hMemDC,m_hOldDib)
i = DeleteObject(m_hDib)
i = DeleteDC(m_hMemDC)
m_hDib = W32_Null
m_hMemDC = W32_Null
iflag = 0
return < br> end if
!// create memory rendering context
m_hMemRC = fwglCreateContext(m_hMemDC)
if(m_hMemRC == W32_Null) then
if(m_hOldDib /= W32_null) i = SelectObject(m_hMemDC,m_hOldDib)
i = DeleteObject(m_hDib)
i = DeleteDC(m_hMemDC)
m_hDib = W32_Null
m_hMemDC = W32_Null
iflag = 0
return
end if
!// Store current rendering and device contexts
m_hOldDC = fwglGetCurrentDC()
m_hOldRC = fwglGetCurrentContext()
!// Make this m_hMemRC the current OpenGL rendering context
i = fwglMakeCurrent(m_hMemDC,m_hMemRC)
Is there anyone know that how to deallocate the memory(*ppvBits) used in CreateDIBSection ?
Following is a pieces of my code.
Thanks a lot.
!*
!***HBITMAP CreateDIBSection(
!*** HDC hdc, // handle to device context
!*** CONST BITMAPINFO *pbmi,
!*** // pointer to structure containing bitmap size,
!*** // format, and color data
!*** UINT iUsage, // color data type indicator: RGB values or
!*** // palette indexes
!*** VOID *ppvBits, // pointer to variable to receive a pointer to
!*** // the bitmap's bit values
!*** HANDLE hSection, // optional handle to a file mapping object
!*** DWORD dwOffset // offset to the bitmap bit values within the
!*** // file mapping object
!***);
!****************************************************************************
!*** OpenGL -> Bitmap -> Printer
!****************************************************************************
use dfwina, W32_Null => null, W32_Arc => Arc
use dfopngl
use Module_Print
use Module_Window
implicit real*8 (a-h,o-z),integer*4 (i-n)
interface
integer*4 function SetMemDCPixelFormat(hDC)
!DEC$ if defined(_x86_)
!DEC$ attributes stdcall, alias : '_SetMemDCPixelFormat@4' :: SetMemDCPixelFormat
!DEC$ else
!DEC$ attributes stdcall, alias : 'SetMemDCPixelFormat' :: SetMemDCPixelFormat
!DEC$ end if
integer*4 hDC
end function SetMemDCPixelFormat
end interface
type (T_BITMAPINFOHEADER) :: bmih
type (T_BITMAPINFO) :: m_bmi
iflag = 1
!// Initialize the bitmap header info.
call ZeroMemory(loc(m_bmi),sizeof(bmih))
m_bmi.bmiHeader.biSize = sizeof(bmih)
m_bmi.bmiHeader.biWidth = nXRes
m_bmi.bmiHeader.biHeight = nYRes
m_bmi.bmiHeader.biPlanes = 1
m_bmi.bmiHeader.biBitCount = 24
m_bmi.bmiHeader.biCompression = BI_RGB
m_bmi.bmiHeader.biSizeImage = m_bmi.bmiHeader.biWidth*m_bmi.bmiHeader.biHeight*3
m_bmi.bmiHeader.biXPelsPerMeter = int(2840.0D0/72.0D0*dble(Print.DPI.cx)*facts) ! int(2840./72.*Print.DPI.cx*facts) // Print.DPI.cx*facts DPI
m_bmi.bmiHeader.biYPelsPerMeter = int(2840.0D0/72.0D0*dble(Print.DPI.cy)*facts) ! int(2840./72.*Print.DPI.cy*facts) // Print.DPI.cy*facts DPI
m_bmi.bmiHeader.biClrUsed = W32_Null
m_bmi.bmiHeader.biClrImportant = W32_Null
!// create DIB
m_hDib = CreateDIBSection(W32_Null,m_bmi,DIB_RGB_COLORS,loc(m_pBitmapBits),W32_Null,0)
!// create memory device context
m_hMemDC = CreateCompatibleDC(W32_Null)
if(m_hMemDC == W32_Null) then
iflag = 0
return
end if
m_hOldDib = SelectObject(m_hMemDC,m_hDib)
!// setup pixel format
if(not(SetMemDCPixelFormat(m_hMemDC))) then
if(m_hOldDib /= W32_null) i = SelectObject(m_hMemDC,m_hOldDib)
i = DeleteObject(m_hDib)
i = DeleteDC(m_hMemDC)
m_hDib = W32_Null
m_hMemDC = W32_Null
iflag = 0
return < br> end if
!// create memory rendering context
m_hMemRC = fwglCreateContext(m_hMemDC)
if(m_hMemRC == W32_Null) then
if(m_hOldDib /= W32_null) i = SelectObject(m_hMemDC,m_hOldDib)
i = DeleteObject(m_hDib)
i = DeleteDC(m_hMemDC)
m_hDib = W32_Null
m_hMemDC = W32_Null
iflag = 0
return
end if
!// Store current rendering and device contexts
m_hOldDC = fwglGetCurrentDC()
m_hOldRC = fwglGetCurrentContext()
!// Make this m_hMemRC the current OpenGL rendering context
i = fwglMakeCurrent(m_hMemDC,m_hMemRC)
Link Copied
0 Replies
![](/skins/images/872293744008A34B36F8ABF94A46CC66/responsive_peak/images/icon_anonymous_message.png)
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