Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - How to use PgBlit correctly?: Page 1 of 5 (5 Items)
   
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);