Hey
sry for my bad introducing of my problem.
Okay i have two threads: tcpServer who accepts the incoming Clientconnections and read the raw pixel data from the socket and a Photon application which display the raw pixel data as an Image.
Okay now the Photon app has an Pointer to the Server and reads the Data. (you can see it in the setImageArea() Function of my MyPhoton-class)
i now want to add a Callback to read the whole time the raw pixel data and display it.
This is the code where i create a new Photon Window:
int MyPhoton::startPhoton()
{
std::cout << "startPhoton()" << std::endl;
PhDim_t size;
size.h = 240;
size.w = 200;
int n;
std::cout << "Init()" << std::endl;
if (PtInit(NULL) == -1)
PtExit(EXIT_FAILURE);
n = 0;
PtSetArg(&args[n++], Pt_ARG_WINDOW_TITLE, "ImageWindow", 0);
PtSetArg(&args[n++], Pt_ARG_DIM, &size,0);
std::cout << "create ImageWindow()" << std::endl;
frontWindow = PtCreateWidget(PtWindow, Pt_NO_PARENT, n, args);
setImageArea(frontWindow);
PtRealizeWidget(frontWindow);
PtMainLoop();
return (EXIT_SUCCESS);
}
And after i created a new Photon Window i add an ImageArea to the Window with the actually readed raw pixel data.
int MyPhoton::setImageArea(PtWidget_t* parent)
{
std::cout << "Set ImageArea" << std::endl;
//get the Data from the tcp Server
const unsigned int* framePic = tcpServer->getFrame()->GetDefishedImage();
memset(&directServerImage, 0, sizeof(PhImage_t));
directServerImage.image = (char*) framePic;
directServerImage.type = Pg_IMAGE_DIRECT_8888;
directServerImage.size.h = 240;
directServerImage.size.w = 640;
directServerImage.alpha = 0;
directServerImage.bpl = 5120;
directServerImage.colors = 0;
directServerImage.flags |= Ph_RELEASE_IMAGE_ALL;
int n = 0;
int imageArea_drag_cb( PtWidget_t *, void *, PtCallbackInfo_t *);
PtCallback_t callbacks[] = { {imageArea_drag_cb, NULL} };
PtSetArg( &args[n++], Pt_CB_IMAGEAREA_DRAG, callbacks, sizeof(callbacks)/sizeof(callbacks[0]));
PtSetArg( &args[n++], Pt_ARG_DIM, &directServerImage.size, 0 );
PtSetArg( &args[n++], Pt_ARG_IMAGEAREA_IMAGE, &directServerImage, sizeof(PhImage_t));
imageArea = PtCreateWidget( PtImageArea, parent, n, args );
return Pt_CONTINUE;
}
and my callback method activates when i drag the ImageArea:
int imageArea_drag_cb( PtWidget_t *w, void *data, PtCallbackInfo_t *cbInfo)
{
PhImage_t* img;
img = PxLoadImage("/home/write100.bmp",NULL);
img->flags |= Ph_RELEASE_IMAGE_ALL;
PtSetResource(w ,Pt_ARG_IMAGEAREA_IMAGE, img, sizeof(PhImage_t) );
return Pt_CONTINUE;
}
This Code Works, but you can see that im loading an Image from an existing bitmap.
Now i want to load the image from the tcpServer in my callback.
How can i made this?
How can i get a Server Pointer which shows to the tcpServer ?
and can i made the callback to a classfunction of MyPhoton?
then i could have acces to the tcp Server, but i think thats not working.
i hope somebody understands me and can give me a hint
with best regards
nudels