Hello,
how can i set the Resource for a Widget (Especially ImageArea)?
when i try to set the Resource with the third parameter that is not a pointer, then i get the Memory fault error.
int callback2(PtWidget_t* w, void* data, PtCallbackInfo_t* cbInfo)
{
std::cout << "callback2" << std::endl;
CircularBuffer* circB = (CircularBuffer*) data;
PhImage_t img;
memset(&img,0,sizeof(PhImage_t));
img.type = Pg_IMAGE_DIRECT_8888;
img.size.h = 240;
img.size.w = 640;
img.alpha = 0;
img.bpl = 5120;
img.colors = 0;
std::cout << "getBuf" << std::endl;
img.image = circB->getBuf();
img.flags |= Ph_RELEASE_IMAGE_ALL;
PtSetResource(w, Pt_ARG_IMAGEAREA_IMAGE, &img, 0);
return Pt_CONTINUE;
}
but even when i create a PhImage_t Pointer and load it with an existing bmp file,
...
PhImage_t* img = PxLoadImage("/home/write.bmp", NULL);
img->flags |= Ph_RELEASE_IMAGE_ALL;
PtSetResource(w, Pt_ARG_IMAGEAREA_IMAGE, img,0);
...
then it works.
But when i dont load an image and want to change the data, i cant. (like img->size.w = 640;).
then i get the Memory fault error.
int callback2(PtWidget_t* w, void* data, PtCallbackInfo_t* cbInfo)
{
std::cout << "callback2" << std::endl;
CircularBuffer* circB = (CircularBuffer*) data;
PhImage_t* img;
memset(img,0,sizeof(PhImage_t));
img->type = Pg_IMAGE_DIRECT_8888;
img->size.h = 240;
img->size.w = 640;
img->alpha = 0;
img->bpl = 5120;
img->colors = 0;
std::cout << "getBuf" << std::endl;
img->image = circB->getBuf();
img->flags |= Ph_RELEASE_IMAGE_ALL;
PtSetResource(w, Pt_ARG_IMAGEAREA_IMAGE, img, 0);
return Pt_CONTINUE;
}
now, how can i set the resource without to savind the pic to a bitmap file and then loading it?
i hope somebody can help me
with best regards
nudels