Home > Software engineering >  About LoadImage and BitBlt cooperate image is drawn on the HDC reduce image quality problems
About LoadImage and BitBlt cooperate image is drawn on the HDC reduce image quality problems

Time:11-16


The first slice the original image is
With LoadImage and BitBlt drawn to form is the same as shown in figure 2
down in qualityAsk bosses that function will make the image down, and if there is any solution

CodePudding user response:

To add a question
After the image is drawn, not flushed to form
Want to drag the window manually refresh to display,
Windowupdate redrawwindow movewindow setwindowpos tried all invalid
For bosses to save

CodePudding user response:


 
LRESULT a CALLBACK WndProc (HWND HWND, UINT message, WPARAM WPARAM, LPARAM LPARAM)
{
The switch (the message)
{
In case the WM_PAINT:
{
PAINTSTRUCT ps;
HDC HDC=BeginPaint (hWnd, & amp; Ps);

//load the bitmap
HBITMAP hBmp=(HBITMAP) LoadImage (NULL, _T (" C: \ \ TEMP \ \ a. mp "),
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTCOLOR);
If (hBmp!=NULL)
{
//get the bitmap information
BITMAP bmInfo;
GetObject (hBmp, sizeof (bmInfo), & amp; BmInfo);

//create & amp; Elected to the bitmap
HDC hMemDC=CreateCompatibleDC (HDC);
HGDIOBJ hOldBmp=SelectObject (hMemDC hBmp);

//map
BitBlt (HDC, 0, 0, bmInfo bmWidth, bmInfo. BmHeight, hMemDC, 0, 0, SRCCOPY);

//restore bitmap
SelectObject (hMemDC hOldBmp);
//end cleanup
DeleteDC (hMemDC);
DeleteObject (hBmp);
}

EndPaint (hWnd, & amp; Ps);
break;
}
Case WM_DESTROY:
{
The PostQuitMessage (0);
break;
}
Default:
{
break;
}
}

Return DefWindowProc (hWnd, message, wParam, lParam);
}

CodePudding user response:

BitBlt last one parameter, change the try
The second question, in the PAINT message in picture image?

CodePudding user response:

Prior to map calls:
SetStretchBltMode (hDC, COLORONCOLOR);//prevent color distortion

CodePudding user response:

See you this source code

CodePudding user response:

red reference 4 floor - fly reply:
prior to map calls:
SetStretchBltMode (hDC, COLORONCOLOR);//to prevent color distortion


CodePudding user response:

red reference 4 floor - fly reply:
prior to map calls:
SetStretchBltMode (hDC, COLORONCOLOR);//to prevent color distortion

CodePudding user response:

reference 1st floor Automatical_Machine response:
add a question
After the image is drawn, not flushed to form
Want to drag the window manually refresh to display,
Windowupdate redrawwindow movewindow setwindowpos tried all invalid
For bosses to save

Where is the loading and drawing images are you?

CodePudding user response:

Maybe try map with
Dc. SetStretchBltMode (HALFTONE);
  • Related