Ich habe meine alte Antwort verschrottet, da sie irrelevant war. Das neue on verwendet auch OpenCV (da ich versuche, ein OpenCV-Bild anzuzeigen), aber es kann an jedes Framework angepasst werden.
Der Kern Code ist, wo es einen Adressenspeicher nimmt address
, und die Anzahl der Bytes durch numrows
, numcols
und byte_size
und liest diese Bytes in einen Puffer zu lesen. Ich bin sicher, dass Sie , dass Teil des Codes für Ihre eigenen Bedürfnisse anpassen können.
#include "stdafx.h"
#include <windows.h>
#include <cv.h>
#include <highgui.h>
#include <iostream>
using namespace std;
using namespace cv;
void imshow_debug(const LPCVOID address, const int numrows, const int numcols, const int type, const int byte_size, const int step, const string windows_title)
{
// Initialize
unsigned long PID;
SIZE_T read_bytes = 0;
// Allocate space for the image
const int bytes_to_read = numrows*numcols*byte_size;
uchar *image_data = new uchar[bytes_to_read];
Mat Image(numrows,numcols,type,image_data,step);
// Get the handle and PID
HWND handle = FindWindowA(0, windows_title.c_str());
if (!FindWindowA(0, windows_title.c_str()))
{
printf("Window %s not found!", windows_title);
exit(0);
}
GetWindowThreadProcessId(handle, &PID); /* Get windows PID from a window handle */
HANDLE WindowsProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, false, PID);
// Read the image
ReadProcessMemory(WindowsProcessHandle,address,image_data,bytes_to_read,&read_bytes);
if(bytes_to_read != read_bytes)
{
cout<<"Could not read entire image"<<endl;
exit(0);
}
// Display the image
namedWindow("Image");
imshow("Image",Image);
waitKey();
// Clean up
CloseHandle(WindowsProcessHandle);
delete[]image_data;
}
int main(int argc, char* argv[])
{
imshow_debug((LPVOID)0x03af0370,300,300,CV_64F,sizeof(double),2400,"C:\\Documents and Settings\\jacobm\\My Documents\\Visual Studio 2005\\Projects\\Head\\debug\\SSR_VideoComp.exe");
return 0;
}
Ich interessiere mich für genau die gleiche Aufgabe. Gibt es Fortschritte bei dem Problem? Sie haben die Antwort mit dem Link zu imdebug akzeptiert, aber es erfordert Änderungen am Quellcode und widerspricht Ihrem eigenen Kommentar: http://stackoverflow.com/questions/1549129/debugging-image-rendering-im-visual-c-anyy-helpful -add-ins # comment1425286_1549543, oder? – Mikhail