Error C2664 "HRESULT ATL: : CImage: : Save (LPCTSTR, const GUID & amp;) Throw () const 1 cannot be the parameter ": from" const char [17] "into" cost * "ConsoleApplication7 c: \ users \ user \ documents \ visual studio 2015 \ projects \ ConsoleApplication7 \ ConsoleApplication7 \ ConsoleApplication7 CPP 38
How to solve it
CodePudding user response:
HRESULT ATL: : CImage: : Save (LPCTSTR, const GUID & amp;) Throw () constWhere is a const char [17] "assigned to a cost * object?
CodePudding user response:
Fyi:# pragma comment (lib, "user32")
# pragma comment (lib, "gdi32")
#include
#include
#include
#include
#include
#include
#include
Void DrawPic (HDC HDC, char * buf, int len) {
HGLOBAL hMem=GlobalAlloc (GMEM_FIXED, len);
BYTE * pMem=(BYTE *) GlobalLock (hMem);
Memcpy (pMem, buf, len);
Cost * pStream;
Retrieves the hr=CreateStreamOnHGlobal (pMem, FALSE, & amp; PStream);
CImage img.
Img. Load (pStream);
Img. The Draw (HDC, CPoint (0, 0));
Img. Destroy ();
PStream - & gt; Release ();
GlobalUnlock (hMem);
GlobalFree (hMem);
}
//HWND WINAPI GetConsoleWindow ();
Void HideTheCursor () {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut=GetStdHandle (STD_OUTPUT_HANDLE);
If (GetConsoleCursorInfo (hStdOut, & amp; CciCursor)) {
CciCursor. BVisible=FALSE;
SetConsoleCursorInfo (hStdOut, & amp; CciCursor);
}
}
Void ShowTheCursor () {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut=GetStdHandle (STD_OUTPUT_HANDLE);
If (GetConsoleCursorInfo (hStdOut, & amp; CciCursor)) {
CciCursor. BVisible=TRUE;
SetConsoleCursorInfo (hStdOut, & amp; CciCursor);
}
}
Int main () {
The HWND HWND;
HDC HDC.
HFONT HFONT;
HBITMAP HBM;
HDC hdcBits;
BITMAP bm.
System (" color F0 ");
System (" CLS ");
HideTheCursor ();
HWND=GetConsoleWindow ();
HDC=GetDC (HWND);
Hfont=CreateFont (48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Chinese regular script");
SelectObject (HDC, hfont);
TextOut (HDC, 10, 10, "this is a bubble," 8);
DeleteObject (hfont);
HBM=(HBITMAP) LoadImage (0, "C: \ \ Windows \ \ Soap Bubbles. BMP", IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
If (HBM) {
HdcBits=CreateCompatibleDC (HDC);
GetObject (HBM, sizeof (BITMAP), & amp; Bm);
SelectObject (hdcBits, HBM);
BitBlt (HDC, 200, 10, bm. BmWidth, bm. BmHeight, hdcBits, 0, 0, SRCCOPY);
DeleteDC (hdcBits);
DeleteObject (HBM);
}
getch();
The FILE * f;
F=fopen (c: \ \ "new \ \ TMP JPG", "rb");
If (f) {
Int fl=filelength (fileno (f));
Char * buf=(char *) malloc (fl);
If (buf) {
Fread (buf, fl, 1, f);
}
The fclose (f);
If (buf) {
DrawPic (HDC, buf, fl);
Free (buf);
}
}
ReleaseDC (HWND, HDC);
getch();
07 system (" color ");
System (" CLS ");
ShowTheCursor ();
return 0;
}
CodePudding user response: