Article View: borland.public.cppbuilder.nativeapi
Article #6902Re: CreateDIBitmap
From: Damon Chandler (TeamB)
Date: Thu, 31 Mar 2005 21:33
Date: Thu, 31 Mar 2005 21:33
32 lines
2350 bytes
2350 bytes
Hi Bob, CreateDIBitmap() is a misnomer--the function actually creates a device-dependent bitmap (DDB). DDBs take on the format of the screen's current display settings, so if your code works on XP but not on Server 2003, the first thing I'd suggest is to test the code when both systems are set to the same display settings (they might already be this way). Also, do you really need a DDB? In the vast majority of cases, it's better to use a DIB section bitmap instead of a DDB. A DIB section bitmap also has an associated HBITMAP, but the format of a DIB section isn't restricted to the format of the screen. Have a look at the CreateDIBSection() function on MSDN, or if you're using the VCL, you can create a TBitmap, which uses a DIB section (as long as the PixelFormat property is not pfDevice; see http://tinyurl.com/42nec). Good luck, -- Damon (TeamB) C++Builder Developer's Journal http://bcbjournal.com BCB Commonly Asked Questions http://bcbjournal.com/bcbcaq Bob wrote: > I am creating a bitmap from a DIB. It works fine on WIndows XP, but it does > not work on Windows 2003 Server. > > hBitmap = CreateDIBitmap(hdc, &bmi->bmiHeader, CBM_INIT, img.bmpbits, bmi, > DIB_RGB_COLORS ); > > hBitmap equal null after the function call. GetLastError returns 8. Any > ideas what I am doing wrong?
Technical Details
Message-ID:
<424c6cb6$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<424c5f1c$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d49bdc82792f17ff X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 31 Mar 2005 16:33:51 -0500 From: "Damon Chandler (TeamB)" <editor@_REMOVE_THIS_SPAM_GUARD_bcbjournal.com> User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: CreateDIBitmap References: <424c5f1c$1@newsgroups.borland.com> In-Reply-To: <424c5f1c$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 69.202.106.187 Message-ID: <424c6cb6$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1112304822 69.202.106.187 (31 Mar 2005 13:33:42 -0800) Lines: 32 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail