Home > Software engineering >  There are only black and white after the BitBlt map
There are only black and white after the BitBlt map

Time:10-13

 
Void CMapData: : ReSize (int w, int h)
{
If (w==Width& & H==Height)
The return;
The CDC myDC;
CBitmap myMap, * oldmyMap;
The CBrush b;
Int ww=w> The Width? W: Width;
Int hh=h> Height? H: the Height;
MyDC. CreateCompatibleDC (& amp; PDC);
MyMap. CreateCompatibleBitmap (& amp; PDC, ww, hh);
OldmyMap=myDC. SelectObject (& amp; MyMap);

Biggest reateSolidBrush (RGB (0,0,255));
MyDC. FillRect (CRect (0, 0, ww, hh), & amp; B);
MyDC. BitBlt (0, 0, Width, Height, & amp; PDC, 0, 0, SRCCOPY);/////backup of the current drawing


PDC. SelectObject (oldmap);
The map. The DeleteObject ();

Map. CreateCompatibleBitmap (& amp; PDC, w, h);
Oldmap=pDC. SelectObject (& amp; The map);

PDC. BitBlt (0, 0, w, h, & amp; MyDC, 0, 0, SRCCOPY);///back to the new size of the bitmap;

Width=w;
Height=h;
MyDC. SelectObject (oldmyMap);
MyDC. DeleteDC ();
MyMap. DeleteObject ();
B.D eleteObject ();

OldPoint=newPoint=CPoint (1, 1);

}

CodePudding user response:

Aunt consult everybody, in the code not found what's the problem, after the paste only black and white, the color of the original image,

CodePudding user response:

CClientDC myDC (this);

CodePudding user response:

This function just want to realize the current pDC on the size of the map, including pDC, the map is initialized,

CodePudding user response:

 
Virtual BOOL CreateCompatibleDC (pDC) CDC *;

The Return Value

Nonzero if the function is successful; Otherwise 0.

The Parameters

PDC

A pointer to A device context. If pDC is NULL, the function creates A memory device context that is compatible with the system display.

Few

Creates a memory device context that is compatible with the device specified by pDC. A memory device context is a block of memory that represents a display surface. It can be 2 prepare images in memory before copying them to the actual device surface of the compatible device.

When a memory device context is created, GDI automatically selects a 1 - by - 1 monochrome stock bitmap for it. The GDI output functions provides can be 2 with a memory device context only if a bitmap has had created and selected into that context.



When a memory device context is created, GDI automatically selects a 1 - by - 1 monochrome stock bitmap for it.

CodePudding user response:

Don't understand, you mean I don't need to choose a MyMap MyDC?

CodePudding user response:

Such as
 
Void CLeftView: : ontouch * pDC (CDC)
{
CVC60Doc * pDoc=GetDocument ();
ASSERT_VALID (pDoc);
//
If (pDoc - & gt; GetLeftBitmap ())//m_hBmpLeft)
{//not client the rect only!
The SIZE of sz=GetTotalSize ();
Sz. Cx -=10;//gap
Sz. Cy -=10;
The CDC memDC;
MemDC. CreateCompatibleDC (pDC);
HBITMAP hOldBitmap=(HBITMAP) memDC. SelectObject (pDoc - & gt; GetLeftBitmap ());//m_hBmpLeft);
PDC - & gt; BitBlt (4, 4, sz. Cx, sz, cy, & amp; MemDC, 0, 0, SRCCOPY);//may bigger then client
MemDC. SelectObject (hOldBitmap);
}
The else
{
PDC - & gt; TextOut (10, 10, "the Open 24 bits of a bitmap!" );
}
}


Void CLeftView: : ontouch (pDC) CDC *//this color dc dc is

The CDC memDC;
MemDC. CreateCompatibleDC (pDC);//this is color dc dc

CodePudding user response:

Wanted to ask you is that pDC is global, please a memdc, I also met the Pal how broken?
  • Related