🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14187

Saving BITMAP to file

#14187
From: CC
Date: Wed, 03 Sep 2003 15:51
26 lines
1858 bytes
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??
Technical Details
Message-ID: <3f560dbd$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,c4a703bacbe5d797,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-09-03 09:10:31 PST
From: "CC" <Xcurtc@tmscorp.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Saving BITMAP to file
Date: Wed, 3 Sep 2003 10:51:03 -0500
Lines: 28
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: 208.254.250.201
Message-ID: <3f560dbd$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1062604221 208.254.250.201 (3 Sep 2003 08:50:21 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail