| |

VerySource

 Forgot password?
 Register
Search
View: 840|Reply: 7

What ’s so bad about drawing a bitmap like this, why the client area is completely dark

[Copy link]

3

Threads

29

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-1-4 22:50:01
| Show all posts |Read mode
void CClipTest2View :: OnDraw (CDC * pDC)
{
CClipTest2Doc * pDoc = GetDocument ();
ASSERT_VALID (pDoc);
Ranch
         // Get bitmap from clipboard
HBITMAP hBmp = CCopyScr :: GetFromClip (this-> GetSafeHwnd ());

BITMAP bm;
GetObject (hBmp, sizeof (BITMAP),&bm);

CBitmap bmpDraw;
bmpDraw.CreateBitmap (bm.bmWidth, bm.bmHeight, bm.bmPlanes, bm.bmBitsPixel, bm.bmBits);

CDC memDC; // Define a compatible DC
memDC.CreateCompatibleDC (pDC); // Create compatible DC

CBitmap * pbmpOld = memDC.SelectObject (&bmpDraw); // Save the original DDB and select the new DDB into the DC
pDC-> BitBlt (0, 0, bm.bmWidth, bm.bmHeight,&memDC, 0, 0, SRCCOPY);

memDC.SelectObject (pbmpOld); // Selected into the original DDB
}
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-4 22:51:02
| Show all posts
bmpDraw.CreateBitmap (bm.bmWidth, bm.bmHeight, bm.bmPlanes, bm.bmBitsPixel, bm.bmBits);
After the create is complete, you need to load bitmap, either read from the file or load the bitmap ID in the resource
Reply

Use magic Report

3

Threads

29

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

 Author| Post time: 2020-1-4 23:09:02
| Show all posts
kkedward: What else should Load do after Create, not just one.
I'm in the Web mode. I want to read the bitmap from the clipboard, convert it to Base64, and then save it into the background database. So neither files nor resources will work.
Reply

Use magic Report

3

Threads

29

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

 Author| Post time: 2020-1-4 23:21:01
| Show all posts
Mainly take a part from some graphics, then draw a few strokes, and then save to the database
Reply

Use magic Report

3

Threads

29

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

 Author| Post time: 2020-1-11 20:45:02
| Show all posts
Does anyone know why? I draw both resources and files, and now I want to cut them from the clipboard and draw.
Reply

Use magic Report

0

Threads

57

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-13 12:09:01
| Show all posts
DEBUG to see if you really successfully obtained the bitmap file
Reply

Use magic Report

0

Threads

59

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-1-14 17:00:02
| Show all posts
You selected the bitmap you created, of course, it is completely dark
Reply

Use magic Report

0

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-1-26 19:09:01
| Show all posts
BITMAP bm;
GetObject (hBmp, sizeof (BITMAP),&bm);

CBitmap bmpDraw;
bmpDraw.CreateBitmap (bm.bmWidth, bm.bmHeight, bm.bmPlanes, bm.bmBitsPixel, bm.bmBits);

Replace with the above
CBitmap bmpDraw;
bmpDraw.Attach (hBmp);
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list