Click here to Skip to main content
15,901,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Compare two bitmap Pin
MAAK14-Feb-03 1:31
MAAK14-Feb-03 1:31 
GeneralRe: Compare two bitmap Pin
jeremysay14-Feb-03 2:12
jeremysay14-Feb-03 2:12 
GeneralRe: Compare two bitmap Pin
MAAK14-Feb-03 2:41
MAAK14-Feb-03 2:41 
GeneralRe: Compare two bitmap Pin
jeremysay14-Feb-03 3:18
jeremysay14-Feb-03 3:18 
GeneralRe: Compare two bitmap Pin
jeremysay14-Feb-03 4:27
jeremysay14-Feb-03 4:27 
GeneralRe: Compare two bitmap Pin
MAAK14-Feb-03 6:14
MAAK14-Feb-03 6:14 
GeneralRe: Compare two bitmap Pin
jeremysay14-Feb-03 10:23
jeremysay14-Feb-03 10:23 
GeneralRe: Compare two bitmap Pin
MAAK14-Feb-03 15:13
MAAK14-Feb-03 15:13 
The problem is as I expected in the previous reply. You are working with DDBs (Decive Dependent Bitmaps) and not DIB (Decive Independent Bitmaps). As far as I know there is no easy way (if exist) to get the bits of DDBs, and the BITMAP structure returned from them points to NULL memory address.

To be more clear any bitmaps got from windows DC , clients DC or any bitmaps created compatible with them are DDBs, and I think, but not sure, that they have variable size.

DIBs are the bitmaps that are normally used in file saving and it has a definit size.
More information about DDBs and DIBs

Hope you are not disappointed, but there is an easy solution, especially since you use VC++7 and have the CImage class.

All you have to do is, instead of bliting into a memory DC compatible with the window DC, you should create a CImage object and blit int it the window DC;

this is how to be get a DIB from DDB using CImage.
CDC         *dcP;
CDC         memDC;
CRect       WndRect;

dcP = GetWindowDC();
GetWindowRect(WndRect); //the window rect is the rect of the whole window
                            //while the client rect is of the client area only

CImage im; //CImage object
    //this is to create a DIB using CImage, the parameters are width, height,
    //color depth
im.Create(WndRect.Width(), WndRect.Height(), 24);
    //CImage::GetDC() return an HDC to the bitmap so you can use it
    //as any other dc
memDC.Attach(im.GetDC()); //attach the HDC into the memDC object
    //blit the window DC
memDC.BitBlt(0, 0, WndRect.right,WndRect.bottom, dcP,2 , 2, SRCCOPY);
memDC.Detach(); //detach the image HDC to prevent its destruction
im.ReleaseDC(); //this is needed for every call to GetDC()
    HBITMAP hbmp = im.Detach(); //you now have handle to DIB ready for use

The CImage is included in <atlimage.h> and please note that it needs the GDI+ runtimes. The GDI+ is inlcude in a file named gdiplus.dll, it comes already with WinXP and VS.Net, but if you are going to use it at any system other than WinXP then the DLL should be put with the application file.

For the clipboard part, copying DIBs to clipboard is more complicated than copying DDBs, you may refer to this page in the msdn, SetClipboardData Function .

However if think that you can just copy DDBs to clipboard then convert them to DIB when pasting.

I hope you are not bored from that lecture;)
GeneralRe: Compare two bitmap Pin
jeremysay14-Feb-03 21:48
jeremysay14-Feb-03 21:48 
GeneralRe: Compare two bitmap Pin
MAAK14-Feb-03 23:14
MAAK14-Feb-03 23:14 
GeneralRe: Compare two bitmap Pin
jeremysay17-Feb-03 3:10
jeremysay17-Feb-03 3:10 
GeneralRe: Compare two bitmap Pin
jeremysay14-Feb-03 5:01
jeremysay14-Feb-03 5:01 
GeneralRe: Compare two bitmap Pin
includeh1014-Feb-03 23:57
includeh1014-Feb-03 23:57 
GeneralMFC accelerators & activeX Pin
peterchen13-Feb-03 22:47
peterchen13-Feb-03 22:47 
GeneralGet the HWND value of a Dialog Pin
Willem B13-Feb-03 22:41
Willem B13-Feb-03 22:41 
GeneralRe: Get the HWND value of a Dialog Pin
bryce13-Feb-03 22:50
bryce13-Feb-03 22:50 
GeneralRe: Get the HWND value of a Dialog Pin
Willem B13-Feb-03 23:03
Willem B13-Feb-03 23:03 
GeneralRe: Get the HWND value of a Dialog Pin
bryce13-Feb-03 23:08
bryce13-Feb-03 23:08 
GeneralRe: Get the HWND value of a Dialog Pin
Willem B13-Feb-03 23:13
Willem B13-Feb-03 23:13 
Generalhide titlebar Pin
bryce13-Feb-03 22:25
bryce13-Feb-03 22:25 
GeneralRe: hide titlebar Pin
Hans Ruck13-Feb-03 23:07
Hans Ruck13-Feb-03 23:07 
Generalissue caused precompiled header Pin
dsuratman13-Feb-03 20:38
dsuratman13-Feb-03 20:38 
GeneralRe: issue caused precompiled header Pin
Michael Dunn13-Feb-03 23:30
sitebuilderMichael Dunn13-Feb-03 23:30 
Generaldev Pin
Anonymous13-Feb-03 19:28
Anonymous13-Feb-03 19:28 
Generaluint40 Pin
Victor Boctor13-Feb-03 18:10
Victor Boctor13-Feb-03 18:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.