David McMinn(deleted)
|
How to use PgBlit correctly?
|
David McMinn(deleted)
01/28/2012 5:37 PM
post91220
|
How to use PgBlit correctly?
Hello,
I am trying to use PgBlit() to copy an area of an image to another location in the same image. Can PgBlit() can be used
for this purpose?
I can't seem to get it to work though. I have a PhImage_t and am displaying it in a PtImageArea. I am using a memory
context to draw to the image and I can see it updating (I draw lines to see that the image updates) but I do not see the
movement that I think should be caused by the PgBlit() call.
The code I am using is shown below. Is there something that I am doing that is wrong?
Thanks.
PmMemoryContext_t *mc; // Memory context to draw onto image
PhDim_t image_size = g_MasterImage.size;
PhPoint_t origin = {0, 0};
mc = PmMemCreateMC(&g_MasterImage, &image_size, &origin);
if (mc)
{
// Set memory context as current draw context
PmMemStart(mc);
PhRect_t area;
PhPoint_t offset;
area.ul.x = 0;
area.ul.y = 40;
area.lr.x = g_MasterImage.size.w - 1;
area.lr.y = 85;
offset.x = 0;
offset.y = 10;
PgSetStrokeColor(Pg_WHITE);
PgDrawILine(rand() % g_MasterImage.size.w,
rand() % g_MasterImage.size.h,
rand() % g_MasterImage.size.w,
rand() % g_MasterImage.size.h);
if (PgBlit(&area, &offset) < 0)
{
printf("Blit failed");
}
PgFlush();
PmMemStop(mc);
PmMemReleaseMC(mc);
}
// Update image
PtSetResource(ABW_ImageView, Pt_ARG_IMAGEAREA_IMAGE, &g_MasterImage, 0);
|
|
|