Click here to Skip to main content
15,917,859 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHi... Great People.... Pin
deldeep9-Mar-05 19:16
deldeep9-Mar-05 19:16 
GeneralRe: Hi... Great People.... Pin
Tareq Ahmed Siraj9-Mar-05 20:11
Tareq Ahmed Siraj9-Mar-05 20:11 
GeneralRe: Hi... Great People.... Pin
deldeep11-Mar-05 18:42
deldeep11-Mar-05 18:42 
GeneralReadDebuggeeMemory Pin
Aleksan9-Mar-05 19:16
Aleksan9-Mar-05 19:16 
Generalhelp needed SafeArrayAccessData Pin
arusmemon9-Mar-05 18:25
arusmemon9-Mar-05 18:25 
GeneralRe: help needed SafeArrayAccessData Pin
Tareq Ahmed Siraj9-Mar-05 19:40
Tareq Ahmed Siraj9-Mar-05 19:40 
QuestionHow to Transfer the image Captured using Screen Capture Code to other machine Pin
karmegakumar9-Mar-05 18:13
karmegakumar9-Mar-05 18:13 
AnswerRe: How to Transfer the image Captured using Screen Capture Code to other machine Pin
spinoza16-May-05 21:42
spinoza16-May-05 21:42 
Look at the code below you can get the CxImage class from An article from Davide Pizzolato. Use some Transfer function to transfer the buffer to the client and decode the image and show it.




BYTE* MyIOCP::GetJPGCompressedDesktopCapture(UINT &nArraySize, int nWidth, int nHeight, BYTE nquality)
{
// get the desired window from dialog box
HWND hwnd=::GetDesktopWindow();
// get window size
CRect r;
::GetWindowRect(hwnd,&r);

int nX, nY, nX2, nY2; // coordinates of rectangle to grab
int xScrn, yScrn; // screen resolution
nArraySize=-1;
BYTE* retbuffer=NULL;

// prepare the DCs
HDC dstDC = ::GetDC(NULL);
HDC srcDC = ::GetWindowDC(hwnd); //full window (::GetDC(hwnd); = clientarea)
HDC memDC = ::CreateCompatibleDC(dstDC);

nX = r.left;
nY = r.top;
nX2 = r.right;
nY2 = r.bottom;
// get screen resolution
xScrn = GetDeviceCaps(srcDC, HORZRES);
yScrn = GetDeviceCaps(srcDC, VERTRES);
//make sure bitmap rectangle is visible

if (nX < 0)
nX = 0;

if (nY < 0)
nY = 0;

if (nX2 > xScrn)
nX2 = xScrn;

if (nY2 > yScrn)
nY2 = yScrn;

// nWidth = nX2 - nX;
// nHeight = nY2 - nY;



// create a bitmap compatible with the screen DC

HBITMAP bm =::CreateCompatibleBitmap(dstDC, nWidth, nHeight);
HBITMAP oldbm = (HBITMAP)::SelectObject(memDC,bm);

// copy the screen and resize to the bitmap

//TRACE("%i,%i",nWidth,nHeight);
// Set Correct Stretchmode
::SetStretchBltMode(memDC,HALFTONE);
::StretchBlt(memDC,0,0,nWidth,nHeight,srcDC,nX,nY,nX2,nY2,SRCCOPY);

//::BitBlt(memDC, 0, 0, nWidth, nHeight, srcDC, nX,nY , SRCCOPY);

// Create a JPG image From the bitmap..

CxImage newimage(CXIMAGE_FORMAT_JPG);
newimage.CreateFromHBITMAP(bm);


// free objects
DeleteObject(SelectObject(memDC,oldbm));
DeleteObject(memDC);



// Encode the image to the memory

CxMemFile MemFile;

//newimage.SetCodecOption(0x10,CXIMAGE_FORMAT_JPG);

// Change so that we dont have a transparent background.
newimage.SetTransIndex(-1);

// If Color change it to 24 bit bitmap.
if (!newimage.IsGrayScale())
newimage.IncreaseBpp(24);

newimage.SetJpegQuality(nquality);
MemFile.Open();

// You have to encode and decode it to compress it in reality.
// ?? Very very strange..
BOOL bRet=FALSE;
if(newimage.Encode(&MemFile,CXIMAGE_FORMAT_JPG))
{
if(MemFile.Seek(0,SEEK_SET))
bRet=newimage.Decode(&MemFile,CXIMAGE_FORMAT_JPG);
}

nArraySize=(UINT)MemFile.Size();

if(bRet)
retbuffer=MemFile.GetBuffer();

// Close & Clean up
MemFile.Close();
newimage.Destroy();
return retbuffer;
}
GeneralMemory Problems with new, delete and CObArray Pin
NeoHobbit9-Mar-05 16:54
NeoHobbit9-Mar-05 16:54 
GeneralRe: Memory Problems with new, delete and CObArray Pin
Christian Graus9-Mar-05 17:05
protectorChristian Graus9-Mar-05 17:05 
GeneralRe: Memory Problems with new, delete and CObArray Pin
NeoHobbit9-Mar-05 17:14
NeoHobbit9-Mar-05 17:14 
GeneralGetOpenFileName in a service Pin
TheGreatAndPowerfulOz9-Mar-05 14:48
TheGreatAndPowerfulOz9-Mar-05 14:48 
GeneralRe: GetOpenFileName in a service Pin
TheGreatAndPowerfulOz9-Mar-05 14:52
TheGreatAndPowerfulOz9-Mar-05 14:52 
GeneralRe: GetOpenFileName in a service Pin
xxrl9-Mar-05 17:06
xxrl9-Mar-05 17:06 
GeneralRe: GetOpenFileName in a service Pin
Ryan Binns9-Mar-05 17:28
Ryan Binns9-Mar-05 17:28 
GeneralRe: GetOpenFileName in a service Pin
TheGreatAndPowerfulOz10-Mar-05 10:23
TheGreatAndPowerfulOz10-Mar-05 10:23 
Generalget exe path Pin
Marcus Spitzmiller9-Mar-05 14:07
Marcus Spitzmiller9-Mar-05 14:07 
GeneralRe: get exe path Pin
Christian Graus9-Mar-05 14:47
protectorChristian Graus9-Mar-05 14:47 
GeneralRe: get exe path Pin
Marcus Spitzmiller9-Mar-05 14:59
Marcus Spitzmiller9-Mar-05 14:59 
GeneralRe: get exe path Pin
gamitech9-Mar-05 21:13
gamitech9-Mar-05 21:13 
Generalmergesort Pin
Ylis9-Mar-05 9:24
Ylis9-Mar-05 9:24 
Generalhelp me!!! Pin
kookoorikoo9-Mar-05 9:06
kookoorikoo9-Mar-05 9:06 
GeneralRe: help me!!! Pin
Ylis9-Mar-05 9:27
Ylis9-Mar-05 9:27 
GeneralProblem with main MDI Frame window Pin
Anonymous9-Mar-05 8:56
Anonymous9-Mar-05 8:56 
GeneralRe: Problem with main MDI Frame window Pin
Ryan Binns9-Mar-05 17:30
Ryan Binns9-Mar-05 17:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.