Article View: borland.public.cppbuilder.nativeapi
Article #14198Re: Saving BITMAP to file
From: Gnum
Date: Thu, 04 Sep 2003 03:16
Date: Thu, 04 Sep 2003 03:16
45 lines
2320 bytes
2320 bytes
"CC" <Xcurtc@tmscorp.com> wrote in message
news:3f560dbd$1@newsgroups.borland.com...
> Greetings all.
> Thanks to code supplied by Bob Gonder,
> I have code that will take a snapshot of the desktop window, and copy to a
> bitmap structure.
> Does anyone have any good code references for saving an HBITMAP to a file?
> (i think i
> need a device independent version of the bitmap also before saving to
file?)
> Many thanks,
> CurtC
>
> Example code:
> HDC hScreenDC=NULL;
> HDC hmemDC=NULL;
> HBITMAP hmemBM=NULL;
> int ScreenWidth=-1;
> int ScreenHeight=-1;
> hScreenDC = GetWindowDC(0);
> ScreenWidth = GetDeviceCaps(hScreenDC, HORZRES);
> ScreenHeight = GetDeviceCaps(hScreenDC, VERTRES);
> hmemDC = CreateCompatibleDC( hScreenDC );
> hmemBM = CreateCompatibleBitmap(hScreenDC,ScreenWidth,ScreenHeight);
> SelectObject(hmemDC, hmemBM);
> BitBlt(hmemDC, 0, 0, ScreenWidth, ScreenHeight, hScreenDC, 0,
> 0,SRCCOPY);
>
> Hmmm- How do I save contents to file??
Try to use VCL TImage, TPicture and TBitmap... I'm not pretty sure which
one,
but absolutely have no doubts that one year ago I succesfully saved such
picture,
by setting it's Handle to your hmemBM and then Save....().
Hope it helps...
Gnum
>
>
Technical Details
Message-ID:
<3f56ae4a@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3f560dbd$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,c4a703bacbe5d797 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-09-03 20:28:03 PST Reply-To: "Gnum" <alexanderL@marketpulse.biz> From: "Gnum" <alexanderL@marketpulse.biz> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f560dbd$1@newsgroups.borland.com> Subject: Re: Saving BITMAP to file Date: Thu, 4 Sep 2003 15:16:56 +1200 Lines: 47 Organization: MarketPulse X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 203.109.192.137 Message-ID: <3f56ae4a@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1062645322 203.109.192.137 (3 Sep 2003 20:15:22 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail