» »

[C++]Kako narediti screenshot?

[C++]Kako narediti screenshot?

*ziga* ::

Zivjo zanima me kako v C++ narediti screenshot, ki ni extra velik? (torej v .jpg formatu).


Sem ze preiskal slo-tech in par drugih strani samo nisem mel se srece, da bi kaj delalo...

LP

DubleG ::

MFC?
GA-P55M-UD2,i5,12GB RAM,Radeon HD 4850,Crucial SSD 64GB,
WD 320GB,WD 5000GB,RevoDrive X2 100GB

xyd1 ::

GDI+?

*ziga* ::

Lahko tudi z GDI samo, da dela in da exe ne bo prevec velik.

LP

xyd1 ::

Vključiš knjižnico
#include <GdiPlus.h>


tukaj pa imaš funkcijo
ps: popravi pot kam ti naj shranjuje, če uporabljaš visto, 7, mislim da ne moreš shranjevat v c:, to funkcijo sem pobral pred časom z interneta...

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);
}


pps: več pomoči ti pa skoraj da ne morem ponudit, ker sem jo sam uporabljal in je funkcija delovala, tako da se nisem pretirano ubadal z njo.

Zgodovina sprememb…

  • spremenilo: xyd1 ()

snow ::

Z QT knjižico: http://qt.nokia.com/doc/4.0/widgets-scr...

Maš cel gui zraven za neke dodatne nastavitve.
Random mutation plus nonrandom cumulative natural selection - Richard Dawkins

*ziga* ::

@xyd1

Dobim sledec error in se mi niti ne sanja zakanj...

error C3861: 'GetEncoderClsid': identifier not found

Senitel ::

Imaš?
#include <gdiplus.h>

*ziga* ::

Ja imam ja...

xyd1 ::

Če se ne motim, moraš še v linker dodati eno komponento,... malo pobrskaj po netu.

edit našo: http://www.codeguru.com/forum/showthrea...
ammm to vključi
#pragma comment( lib, "gdiplus" )

al pa v linker (odvisno od programa - devcpp, ms c++),.. citiram:

To compile and link the code, you need to add the gdiplus.lib to Project Properties->Linker->Input->Additional Dependencies. Or you can put the below pragma in source code.

Zgodovina sprememb…

  • spremenilo: xyd1 ()

*ziga* ::

Sem probal vstavit oboje ampak error ostaja isto :(
Uporabljam Visual Studio 2008.

W3by ::

Tukaj imaš mankajočo funkcijo (ni problem v knjižnici):

http://msdn.microsoft.com/en-us/library...

Zgodovina sprememb…

  • spremenil: W3by ()

*ziga* ::

Zdaj dobim se vec errorjev...

(52) : error C2065: 'ImageCodecInfo' : undeclared identifier
(52) : error C2065: 'pImageCodecInfo' : undeclared identifier
(54) : error C3861: 'GetImageEncodersSize': identifier not found
(58) : error C2065: 'pImageCodecInfo' : undeclared identifier
(58) : error C2065: 'ImageCodecInfo' : undeclared identifier
(58) : error C2059: syntax error : ')'
(59) : error C2065: 'pImageCodecInfo' : undeclared identifier
(62) : error C2065: 'pImageCodecInfo' : undeclared identifier
(62) : error C3861: 'GetImageEncoders': identifier not found
(66) : error C2065: 'pImageCodecInfo' : undeclared identifier
(66) : error C2228: left of '.MimeType' must have class/struct/union
(68) : error C2065: 'pImageCodecInfo' : undeclared identifier
(68) : error C2228: left of '.Clsid' must have class/struct/union
(69) : error C2065: 'pImageCodecInfo' : undeclared identifier
(74) : error C2065: 'pImageCodecInfo' : undeclared identifier

Zgodovina sprememb…

  • spremenil: *ziga* ()


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

kje zaceti z c++ ?

Oddelek: Programiranje
323757 (2065) Monster
»

Visual C++ 6.0 - enostaven FTP client

Oddelek: Programiranje
61115 (909) Monster
»

Kako uporabiti to funkcijo [c++]

Oddelek: Programiranje
5956 (892) StratOS
»

DevC++ težava?

Oddelek: Programiranje
181612 (1480) Gundolf
»

Win32 Console Project

Oddelek: Programiranje
6873 (821) Fury

Več podobnih tem