Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How to blit insttead of overwite using gf_draw_blit2?: (5 Items)
   
How to blit insttead of overwite using gf_draw_blit2?  
Hi All,

I am trying to blit two .png files.  I have attached the .png files to two seperate surfaces and am using the following 
code(only the important calls):

rc = gf_surface_attach(&img_surf1, gdev, image1.w, image1.h, 			image1.access.direct.stride, img_fmt_to_gf(image1.
format),
				        &palette, image1.access.direct.data, 0);

rc = gf_surface_attach(&img_surf2, gdev, image2.w, image2.h,  	image2.access.direct.stride, img_fmt_to_gf(image2.format)
,
					        &palette2, image2.access.direct.data, 0);

gf_context_create(&context);
gf_context_set_surface(context, img_surf1);
gf_draw_begin(context);
gf_draw_blit2( context,  img_surf2, NULL, 107, 4, 334, 222, 0, 0);
gf_draw_end(context);
rc = img_write_file(ilib, "/tmp/reza.png", NULL, &image1);

The two images are getting combined.  However, the target image is overwriting (covering) the target image.  

Can someone please tell me what I need to do (probably to the context) to have the source image blited into the target 
image, instead of overwriting it?

Thanks in advance,

Reza.
Re: How to blit insttead of overwite using gf_draw_blit2?  
You'll probably want to enable blending and use a source over blending mode.

-Joel

----- Original Message -----
From: Reza Salehi [mailto:community-noreply@qnx.com]
Sent: Wednesday, June 01, 2011 04:51 PM
To: advanced-graphics <post86355@community.qnx.com>
Subject: How to blit insttead of overwite using gf_draw_blit2?

Hi All,

I am trying to blit two .png files.  I have attached the .png files to two seperate surfaces and am using the following 
code(only the important calls):

rc = gf_surface_attach(&img_surf1, gdev, image1.w, image1.h, 			image1.access.direct.stride, img_fmt_to_gf(image1.
format),
				        &palette, image1.access.direct.data, 0);

rc = gf_surface_attach(&img_surf2, gdev, image2.w, image2.h,  	image2.access.direct.stride, img_fmt_to_gf(image2.format)
,
					        &palette2, image2.access.direct.data, 0);

gf_context_create(&context);
gf_context_set_surface(context, img_surf1);
gf_draw_begin(context);
gf_draw_blit2( context,  img_surf2, NULL, 107, 4, 334, 222, 0, 0);
gf_draw_end(context);
rc = img_write_file(ilib, "/tmp/reza.png", NULL, &image1);

The two images are getting combined.  However, the target image is overwriting (covering) the target image.  

Can someone please tell me what I need to do (probably to the context) to have the source image blited into the target 
image, instead of overwriting it?

Thanks in advance,

Reza.



_______________________________________________

Advanced Graphics
http://community.qnx.com/sf/go/post86355
Re: How to blit insttead of overwite using gf_draw_blit2?  
Thanks for the quick reply Joel.  However, I guess my problem is that I can not figure out how to enable blending!  I 
have looked at the document and I found the gf_context_set_alpha.  However, my images are RGB888 and not ARGB888.  
Should I read the original image as ARGB8888 (by setting the img_t format field).  

I would appreciate it if you can point me to small code snipet or site, as I have been trying to figure this out for 
past two days.

Regards,

Reza.
Re: How to blit insttead of overwite using gf_draw_blit2?  
Correct, you'll need an alpha channel for source alpha blending.

----- Original Message -----
From: Reza Salehi [mailto:community-noreply@qnx.com]
Sent: Wednesday, June 01, 2011 05:17 PM
To: advanced-graphics <post86357@community.qnx.com>
Subject: Re: How to blit insttead of overwite using gf_draw_blit2?

Thanks for the quick reply Joel.  However, I guess my problem is that I can not figure out how to enable blending!  I 
have looked at the document and I found the gf_context_set_alpha.  However, my images are RGB888 and not ARGB888.  
Should I read the original image as ARGB8888 (by setting the img_t format field).  

I would appreciate it if you can point me to small code snipet or site, as I have been trying to figure this out for 
past two days.

Regards,

Reza.



_______________________________________________

Advanced Graphics
http://community.qnx.com/sf/go/post86357
Re: How to blit insttead of overwite using gf_draw_blit2?  
For some reason, when I do:
image2.flags  |= IMG_FORMAT;
image2.format =	GF_FORMAT_ARGB8888;
rc = img_load_file(ilib, "/tmp/Day_24hr.png", NULL, &image1);
rc = gf_surface_attach(&img_surf1, gdev, image1.w, image1.h,				image1.access.direct.stride, img_fmt_to_gf(image1.
format),
				        &palette, image1.access.direct.data, 0);
gf_context_create(&context);

Then my call to rc = gf_context_set_surface(context, img_surf1); hangs and never returns!!! 

I am running out of ideas to try!!!

Thanks,

Reza.