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);
|
|
|
Derek Leach
|
RE: How to use PgBlit correctly?
|
Derek Leach
01/30/2012 8:37 AM
post91229
|
RE: How to use PgBlit correctly?
Does the PgBlit() return -1? I would put a PgFlush() and a PgWaitHWIdle() right after the PgDrawLine() ... you have to
make sure everything is flushed out before blitting ... give it a try.
-----Original Message-----
From: David McMinn [mailto:community-noreply@qnx.com]
Sent: January 28, 2012 5:38 PM
To: photon-graphics
Subject: 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);
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post91220
|
|
|
David McMinn(deleted)
|
Re: RE: How to use PgBlit correctly?
|
David McMinn(deleted)
01/30/2012 9:55 AM
post91233
|
Re: RE: How to use PgBlit correctly?
Hi Derek,
Thanks for the reply.
PgBlit() never returns -1, always something >= 0 which according to the documentation is a success.
I added PgFlush() and PgWaitHWIdle() after drawing the line but it did not make a difference.
However, your reply got me thinking that I am maybe still doing something wrong or trying to use PgBlit() in an
unsupported way. Just to re-iterate, this is through a memory context.
My code to create the image is below. Note that I don't use shared memory. I'm trying to draw to an in memory image so
that I can display the image it in a widget, save it to a file and stream it to a printer (currently unsupported so I'm
sending raw printer commands to an LPT port rather than use a printer context). I'm assuming that PhCreateImage()
without the shared memory flag and the fact that I'm using a memory context means the image is all in CPU memory rather
than video memory. Does PgBlit() work in that way (I assumed it would be done by the CPU rather than a GPU)?
PhDim_t image_size = {100, 100};
if (PhCreateImage(&g_MasterImage, image_size.w, image_size.h, Pg_IMAGE_DIRECT_888, NULL, 0, 0))
> Does the PgBlit() return -1? I would put a PgFlush() and a PgWaitHWIdle()
> right after the PgDrawLine() ... you have to make sure everything is flushed
> out before blitting ... give it a try.
>
> -----Original Message-----
> From: David McMinn [mailto:community-noreply@qnx.com]
> Sent: January 28, 2012 5:38 PM
> To: photon-graphics
> Subject: 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);
>
>
>
>
> _______________________________________________
>
> Photon microGUI
> http://community.qnx.com/sf/go/post91220
|
|
|
Derek Leach
|
RE: RE: How to use PgBlit correctly?
|
Derek Leach
01/30/2012 12:38 PM
post91234
|
RE: RE: How to use PgBlit correctly?
what versions? what gpu?
No, it will go to the GPU ... for a blit, try the shared memory flag ... failing this, create and offscreen context, and
use it instead of a memory context .to see what happens.
-----Original Message-----
From: David McMinn [mailto:community-noreply@qnx.com]
Sent: January 30, 2012 9:55 AM
To: photon-graphics
Subject: Re: RE: How to use PgBlit correctly?
Hi Derek,
Thanks for the reply.
PgBlit() never returns -1, always something >= 0 which according to the documentation is a success.
I added PgFlush() and PgWaitHWIdle() after drawing the line but it did not make a difference.
However, your reply got me thinking that I am maybe still doing something wrong or trying to use PgBlit() in an
unsupported way. Just to re-iterate, this is through a memory context.
My code to create the image is below. Note that I don't use shared memory. I'm trying to draw to an in memory image so
that I can display the image it in a widget, save it to a file and stream it to a printer (currently unsupported so I'm
sending raw printer commands to an LPT port rather than use a printer context). I'm assuming that PhCreateImage()
without the shared memory flag and the fact that I'm using a memory context means the image is all in CPU memory rather
than video memory. Does PgBlit() work in that way (I assumed it would be done by the CPU rather than a GPU)?
PhDim_t image_size = {100, 100};
if (PhCreateImage(&g_MasterImage, image_size.w, image_size.h, Pg_IMAGE_DIRECT_888, NULL, 0, 0))
> Does the PgBlit() return -1? I would put a PgFlush() and a
> PgWaitHWIdle() right after the PgDrawLine() ... you have to make sure
> everything is flushed out before blitting ... give it a try.
>
> -----Original Message-----
> From: David McMinn [mailto:community-noreply@qnx.com]
> Sent: January 28, 2012 5:38 PM
> To: photon-graphics
> Subject: 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);
>
>
>
>
> _______________________________________________
>
> Photon...
|
|
|
David McMinn(deleted)
|
Re: RE: RE: How to use PgBlit correctly?
|
David McMinn(deleted)
03/25/2012 7:44 AM
post92269
|
Re: RE: RE: How to use PgBlit correctly?
Hi Derek,
I know it's late but thanks for the help. Been up to my eyes in all sorts of other things so haven't had a chance to try
out your suggestions and unfortunately I'm going to have to leave it where it is for now. I hadn't realised that PgBlit
was GPU only, so that will be my problem.
Cheers.
|
|
|
|