Re: CreateCompatibleBitmap Size limits?? I need LARGE bitmaps!

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Mike -

I've read your article (thanks) and I've been playing with ways to go beyond
the memory limitations I'm getting in CreateDIBSection.
I've tried using a mapped file, but CreateDIBSection still fails at the same
size as when I did not use a mapped file.
I'm just curious if you could try this code on your system and let me know
the results?
*************
Dim bi As BITMAPINFO
Dim hfile As Long
Dim HFILEMAP As Long
Dim fmapname As String
Dim lWidth as Long
Dim lHeight as Long
lWidth=13200
lHeight=10200
With bi.bmiHeader
.biBitCount = 32
.biPlanes = 1
.biCompression = BI_RGB
.biSize = Len(bi.bmiHeader)
.biWidth = lWidth
.biHeight = lHeight
.biSizeImage = (lWidth * .biBitCount) + &H1F
.biSizeImage = .biSizeImage And Not &H1F&
.biSizeImage = .biSizeImage \ &H8
.biSizeImage = .biSizeImage * .biHeight
End With
fmapname = "C:\junkfile"
If Dir(fmapname) <> vbNullString Then
Kill fmapname
End If
hfile = CreateFile(fmapname, GENERIC_READ Or GENERIC_WRITE, 0, 0,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
HFILEMAP = CreateFileMapping(hfile, 0, PAGE_READWRITE, 0,
bi.bmiHeader.biSizeImage, "MyMapping")
compDC = CreateCompatibleDC(0)
mybitmap = CreateDIBSection(compDC, bi, DIB_RGB_COLORS, 0, HFILEMAP, 0)
'<-- Fails here
CloseHandle hfile
CloseHandle HFILEMAP

*************

"Mike D Sutton" wrote:

Would you be kind enough to point me to a sample or provide one (vb6) ?
I need a DC and a bitmap to render to.

Have a look at the DIB article on my site, that should give you all the code and information you need.
You may also want to go through the DC and/or DDB articles if you want more of a background on GDI.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@xxxxxxxx
WWW: Http://EDais.mvps.org/



.



Relevant Pages

  • Re: Confused with CreateDIBSection
    ... Got time yesterday implementing all the changes and the CreateDIBSection ... Exit Sub ... Dim hSysBrush As Long ...
    (microsoft.public.vb.winapi.graphics)
  • Picturebox & StretchBlt
    ... Dim lWidth As Long ... Dim lHeight As Long ... Dim myPicture as StdPicture ...
    (microsoft.public.vb.winapi.graphics)