|
-
May 14th, 2009, 04:37 AM
#16
Re: GDI+ screenshot save to JPG
Use wchar_t instead bcos your application is not a unicode application.
Code:
SYSTEMTIME SysTime;
GetLocalTime(&SysTime);
wchar_t filename[200];
memset(filename,0,sizeof(filename));
wsprintfW(filename,L"screen%02d:%02d:%02d h.jpeg",SysTime.wHour,SysTime.wMinute,SysTime.wSecond);
-
May 14th, 2009, 04:51 AM
#17
Re: GDI+ screenshot save to JPG
thx it compiles... but doesn't save screenshot to anywhere =\ without formatting it was saving it fine , maybe i used filename wrong? =\
full code
Code:
void gdiscreen()
{
SYSTEMTIME SysTime;
GetLocalTime(&SysTime);
wchar_t filename[200];
memset(filename,0,sizeof(filename));
wsprintfW(filename,L"C:\\screen%02d:%02d:%02d h.jpeg",SysTime.wHour,SysTime.wMinute,SysTime.wSecond);
using namespace Gdiplus;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
{
HDC scrdc, memdc;
HBITMAP membit;
scrdc = ::GetDC(0);
int Height = GetSystemMetrics(SM_CYSCREEN);
int Width = GetSystemMetrics(SM_CXSCREEN);
memdc = CreateCompatibleDC(scrdc);
membit = CreateCompatibleBitmap(scrdc, Width, Height);
HBITMAP hOldBitmap =(HBITMAP) SelectObject(memdc, membit);
BitBlt(memdc, 0, 0, Width, Height, scrdc, 0, 0, SRCCOPY);
Gdiplus::Bitmap bitmap(membit, NULL);
CLSID clsid;
GetEncoderClsid(L"image/jpeg", &clsid);
bitmap.Save(filename, &clsid);
SelectObject(memdc, hOldBitmap);
DeleteObject(memdc);
DeleteObject(membit);
::ReleaseDC(0,scrdc);
}
GdiplusShutdown(gdiplusToken);
}
-
May 14th, 2009, 04:59 AM
#18
Re: GDI+ screenshot save to JPG
You need to put the drive and folder path for the file path. If you are using Vista and is using UAC, your application do not have the permission to save to C drive. Use C drive and a folder in your file path.
Last edited by CBasicNet; May 14th, 2009 at 05:00 AM.
Reason: Edited for Vista
-
May 14th, 2009, 05:02 AM
#19
Re: GDI+ screenshot save to JPG
but it was saving to C drive fine when i used only screen.jpg as a name, you sure about permissions?
-
May 14th, 2009, 05:06 AM
#20
Re: GDI+ screenshot save to JPG
Perhaps colon ":" is not valid for a file name.
-
May 14th, 2009, 05:09 AM
#21
Re: GDI+ screenshot save to JPG
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|